Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor #10

Merged
merged 4 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Yugen.Mosaic.Uwp/Assets/Store/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Yugen.Mosaic.Uwp/Assets/Store/Screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Yugen.Mosaic.Uwp/Controls/AlignmentGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void Rebuild()
Height = ActualHeight,
Fill = brush
};
Canvas.SetLeft(line, MathHelper.RangesConverter(x, 0, ContainerWidth, 0, ActualWidth));
Canvas.SetLeft(line, MathHelper.RangeConvert(x, 0, ContainerWidth, 0, ActualWidth));

containerCanvas.Children.Add(line);
}
Expand All @@ -149,7 +149,7 @@ private void Rebuild()
Height = 1,
Fill = brush
};
Canvas.SetTop(line, MathHelper.RangesConverter(y, 0, ContainerHeight, 0, ActualHeight));
Canvas.SetTop(line, MathHelper.RangeConvert(y, 0, ContainerHeight, 0, ActualHeight));

containerCanvas.Children.Add(line);
}
Expand Down
9 changes: 8 additions & 1 deletion Yugen.Mosaic.Uwp/Enums/FileFormat.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
namespace Yugen.Mosaic.Uwp.Enums
using System.ComponentModel;

namespace Yugen.Mosaic.Uwp.Enums
{
public enum FileFormat
{
[Description(".jpg")]
Jpg,
[Description(".png")]
Png,
[Description(".bmp")]
Bmp,
[Description(".tiff")]
Tiff,
[Description(".gif")]
Gif
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace Yugen.Mosaic.Uwp.Models
namespace Yugen.Mosaic.Uwp.Enums
{
public enum MosaicTypeEnum
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Yugen.Mosaic.Uwp.Models
namespace Yugen.Mosaic.Uwp.Enums
{
public enum OnboardingStage
{
Expand Down
9 changes: 0 additions & 9 deletions Yugen.Mosaic.Uwp/Extensions/FileFormatExtensions.cs

This file was deleted.

98 changes: 0 additions & 98 deletions Yugen.Mosaic.Uwp/Extensions/SettingsStorageExtensions.cs

This file was deleted.

1 change: 0 additions & 1 deletion Yugen.Mosaic.Uwp/Helpers/ColorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private static Rgba32 GetAverageColor(Image<Rgba32> source, int startX, int star
return new Rgba32(Convert.ToByte(aR), Convert.ToByte(aG), Convert.ToByte(aB));
}


public static int GetDifference(Rgba32 source, Rgba32 target)
{
var dR = Math.Abs(source.R - target.R);
Expand Down
18 changes: 16 additions & 2 deletions Yugen.Mosaic.Uwp/Helpers/MathHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Yugen.Mosaic.Uwp.Helpers
using System;

namespace Yugen.Mosaic.Uwp.Helpers
{
public static class MathHelper
{
Expand All @@ -12,8 +14,20 @@ public static class MathHelper
/// <param name="newMin"></param>
/// <param name="newMax"></param>
/// <returns>newValue</returns>
public static double RangesConverter(double oldValue, double oldMin, double oldMax, double newMin, double newMax) =>
public static double RangeConvert(double oldValue, double oldMin, double oldMax, double newMin, double newMax) =>
(oldValue - oldMin) * (newMax - newMin) /
(oldMax - oldMin) + newMin;

public static Tuple<int, int> RatioConvert(int width, int height, int newHeight, int newWidth)
{
//calculate the ratio
var ratio = (double)width / (double)height;

//set height of image to boxHeight and check if resulting width is less than boxWidth,
//else set width of image to boxWidth and calculate new height
return (int)(newHeight * ratio) <= newWidth
? new Tuple<int, int>((int)(newHeight * ratio), newHeight)
: new Tuple<int, int>(newWidth, (int)(newWidth / ratio));
}
}
}
6 changes: 3 additions & 3 deletions Yugen.Mosaic.Uwp/Helpers/OnboardingHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Windows.UI.Xaml;
using Yugen.Mosaic.Uwp.Enums;
using Yugen.Mosaic.Uwp.Models;

namespace Yugen.Mosaic.Uwp.Helpers
Expand All @@ -7,16 +8,15 @@ namespace Yugen.Mosaic.Uwp.Helpers
public static class OnboardingHelper
{
private const string SettingsKey = "OnboardingIsEnabled";
private static OnboardingElement[] _onboardingElements;
private static int _step;

public static bool IsDisabled
{
get => SettingsHelper.Read<bool>(SettingsKey);
set => SettingsHelper.Write<bool>(SettingsKey, value);
}

private static int _step;
private static OnboardingElement[] _onboardingElements;

public static void Init(FrameworkElement[] frameworkElements) => _onboardingElements = new OnboardingElement[]
{
new OnboardingElement(
Expand Down
19 changes: 0 additions & 19 deletions Yugen.Mosaic.Uwp/Helpers/RatioHelper.cs

This file was deleted.

3 changes: 2 additions & 1 deletion Yugen.Mosaic.Uwp/Helpers/ResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public static class ResourceHelper
{
private static readonly ResourceLoader _resourceLoader = _resourceLoader ?? new ResourceLoader();

public static string GetText(string key) => _resourceLoader.GetString(key);
public static string GetText(string key) =>
_resourceLoader.GetString(key);
}
}
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Interfaces/IMosaicService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using SixLabors.ImageSharp.PixelFormats;
using System.IO;
using Windows.Storage.Streams;
using Yugen.Mosaic.Uwp.Models;
using Yugen.Mosaic.Uwp.Enums;

namespace Yugen.Mosaic.Uwp.Interfaces
{
Expand Down
3 changes: 2 additions & 1 deletion Yugen.Mosaic.Uwp/Models/MosaicType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Yugen.Mosaic.Uwp.Extensions;
using Yugen.Mosaic.Uwp.Enums;
using Yugen.Mosaic.Uwp.Extensions;

namespace Yugen.Mosaic.Uwp.Models
{
Expand Down
14 changes: 6 additions & 8 deletions Yugen.Mosaic.Uwp/Models/OnboardingElement.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
using Windows.UI.Xaml;
using Yugen.Mosaic.Uwp.Enums;
using Yugen.Mosaic.Uwp.Helpers;

namespace Yugen.Mosaic.Uwp.Models
{
public class OnboardingElement
{
public string Title { get; set; }

public string Subtitle { get; set; }

public FrameworkElement Target { get; set; }

public OnboardingStage Stage { get; set; }

public OnboardingElement(FrameworkElement target, OnboardingStage stage)
{
Title = ResourceHelper.GetText($"OnboardingStage{stage}Title");
Subtitle = ResourceHelper.GetText($"OnboardingStage{stage}Description");
Target = target;
Stage = stage;
}

public OnboardingStage Stage { get; set; }
public string Subtitle { get; set; }
public FrameworkElement Target { get; set; }
public string Title { get; set; }
}
}
26 changes: 0 additions & 26 deletions Yugen.Mosaic.Uwp/Models/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,3 @@ public Tile(Image<Rgba32> originalImage, string name)
}
}
}

//Rgba32 targetColor = _averageColor.ToPixel<Rgba32>();

//Color clAvg = Color.FromRgba(255, Convert.ToByte(R), Convert.ToByte(G), Convert.ToByte(B));
//Rgba32 clAvg = Color.FromRgba(255, Convert.ToByte(R), Convert.ToByte(G), Convert.ToByte(B));
//Rgba32 clAvg = new Rgba32(Convert.ToByte(R), Convert.ToByte(G), Convert.ToByte(B), 255);

//TPixel pixelColor = new TPixel();
//pixelColor.FromRgba32(clAvg);

//public async Task RunTasks(WriteableBitmap clone)
//{
// var tasks = new List<Task>();

// tasks.Add(Task.Run(() => DoWork(400, 1, clone)));
// tasks.Add(Task.Run(() => DoWork(200, 2, clone)));
// tasks.Add(Task.Run(() => DoWork(300, 3, clone)));

// await Task.WhenAll(tasks);
//}

//public async Task DoWork(int delay, int n, WriteableBitmap masterImageSource)
//{
// await Task.Delay(delay);
// System.Diagnostics.Debug.WriteLine($"{n} {masterImageSource.PixelHeight}");
//}
6 changes: 3 additions & 3 deletions Yugen.Mosaic.Uwp/Models/TileBmp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ namespace Yugen.Mosaic.Uwp.Models
{
public class TileBmp
{
public string Name { get; set; }
public BitmapImage Image { get; set; }

public TileBmp(string name, BitmapImage image)
{
Name = name;
Image = image;
}

public BitmapImage Image { get; set; }
public string Name { get; set; }
}
}
1 change: 1 addition & 0 deletions Yugen.Mosaic.Uwp/Services/MosaicService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Windows.Storage.Streams;
using Windows.UI.Xaml.Media.Imaging;
using Yugen.Mosaic.Uwp.Enums;
using Yugen.Mosaic.Uwp.Helpers;
using Yugen.Mosaic.Uwp.Interfaces;
using Yugen.Mosaic.Uwp.Models;
Expand Down
Loading