Skip to content

Commit

Permalink
Merge branch 'release/store' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Emiliano84 authored May 5, 2020
2 parents aea8b2a + 1ac79e0 commit c49fa4f
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 188 deletions.
13 changes: 5 additions & 8 deletions Yugen.Mosaic.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ namespace Yugen.Mosaic.Uwp
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
public sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
InitializeComponent();
Suspending += OnSuspending;

AppCenter.Start("7df4b441-69ae-49c5-b27d-5a532f33b554",
typeof(Analytics), typeof(Crashes));
Expand Down Expand Up @@ -76,10 +76,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e) => throw new Exception("Failed to load Page " + e.SourcePageType.FullName);

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
Expand All @@ -90,7 +87,7 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
Expand Down
27 changes: 12 additions & 15 deletions Yugen.Mosaic.Uwp/Controls/AlignmentGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,44 @@ private static void OnPropertyChanged(DependencyObject dependencyObject, Depende
/// </summary>
public Brush LineBrush
{
get { return (Brush)GetValue(LineBrushProperty); }
set { SetValue(LineBrushProperty, value); }
get => (Brush)GetValue(LineBrushProperty);
set => SetValue(LineBrushProperty, value);
}

/// <summary>
/// Gets or sets the step to use horizontally.
/// </summary>
public double HorizontalStep
{
get { return (double)GetValue(HorizontalStepProperty); }
set { SetValue(HorizontalStepProperty, value); }
get => (double)GetValue(HorizontalStepProperty);
set => SetValue(HorizontalStepProperty, value);
}

/// <summary>
/// Gets or sets the step to use horizontally.
/// </summary>
public double VerticalStep
{
get { return (double)GetValue(VerticalStepProperty); }
set { SetValue(VerticalStepProperty, value); }
get => (double)GetValue(VerticalStepProperty);
set => SetValue(VerticalStepProperty, value);
}

/// <summary>
/// Get or set the container width.
/// </summary>
public double ContainerWidth
{
get { return (double)GetValue(ContainerWidthProperty); }
set { SetValue(ContainerWidthProperty, value); }
get => (double)GetValue(ContainerWidthProperty);
set => SetValue(ContainerWidthProperty, value);
}

/// <summary>
/// Get or set the container height.
/// </summary>
public double ContainerHeight
{
get { return (double)GetValue(ContainerHeightProperty); }
set { SetValue(ContainerHeightProperty, value); }
get => (double)GetValue(ContainerHeightProperty);
set => SetValue(ContainerHeightProperty, value);
}

/// <summary>
Expand All @@ -121,7 +121,7 @@ private void Rebuild()
containerCanvas.Children.Clear();
var horizontalStep = HorizontalStep;
var verticalStep = VerticalStep;
var brush = LineBrush ?? (Brush)Application.Current.Resources["ApplicationForegroundThemeBrush"];
Brush brush = LineBrush ?? (Brush)Application.Current.Resources["ApplicationForegroundThemeBrush"];

if (horizontalStep > 0)
{
Expand Down Expand Up @@ -156,9 +156,6 @@ private void Rebuild()
}
}

private void AlignmentGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
Rebuild();
}
private void AlignmentGrid_SizeChanged(object sender, SizeChangedEventArgs e) => Rebuild();
}
}
14 changes: 4 additions & 10 deletions Yugen.Mosaic.Uwp/Extensions/SettingsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ public static void Write<T>(string key, T value)
LocalSettings.Values[key] = valueString;
}

public static async Task<T> ReadAsync<T>(string key)
{
return LocalSettings.Values.TryGetValue(key, out object value)
? await JsonProvider.ToObjectAsync<T>((string) value)
public static async Task<T> ReadAsync<T>(string key) => LocalSettings.Values.TryGetValue(key, out var value)
? await JsonProvider.ToObjectAsync<T>((string)value)
: default;
}

public static T Read<T>(string key)
{
return LocalSettings.Values.TryGetValue(key, out object value)
? JsonConvert.DeserializeObject<T>((string) value)
public static T Read<T>(string key) => LocalSettings.Values.TryGetValue(key, out var value)
? JsonConvert.DeserializeObject<T>((string)value)
: default;
}
}
}
14 changes: 7 additions & 7 deletions Yugen.Mosaic.Uwp/Helpers/ColorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ private static Rgba32 GetAverageColor(Image<Rgba32> source, int startX, int star

Parallel.For(startY, endY, h =>
{
var rowSpan = source.GetPixelRowSpan(h);
Span<Rgba32> rowSpan = source.GetPixelRowSpan(h);

for (int w = startX; w < endX; w++)
for (var w = startX; w < endX; w++)
{
Rgba32 pixel = new Rgba32();
var pixel = new Rgba32();
rowSpan[w].ToRgba32(ref pixel);

aR += pixel.R;
Expand All @@ -43,10 +43,10 @@ private static Rgba32 GetAverageColor(Image<Rgba32> source, int startX, int star

public static int GetDifference(Rgba32 source, Rgba32 target)
{
int dR = Math.Abs(source.R - target.R);
int dG = Math.Abs(source.G - target.G);
int dB = Math.Abs(source.B - target.B);
int diff = Math.Max(dR, dG);
var dR = Math.Abs(source.R - target.R);
var dG = Math.Abs(source.G - target.G);
var dB = Math.Abs(source.B - target.B);
var diff = Math.Max(dR, dG);
return Math.Max(diff, dB);
}
}
Expand Down
7 changes: 3 additions & 4 deletions Yugen.Mosaic.Uwp/Helpers/OnboardingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public static bool IsDisabled
private static int _step;
private static OnboardingElement[] _onboardingElements;

public static void Init(FrameworkElement[] frameworkElements)
{
_onboardingElements = new OnboardingElement[]
public static void Init(FrameworkElement[] frameworkElements) => _onboardingElements = new OnboardingElement[]
{
new OnboardingElement(
frameworkElements[0],
Expand All @@ -44,14 +42,15 @@ public static void Init(FrameworkElement[] frameworkElements)
frameworkElements[6],
OnboardingStage.Save),
};
}

public static OnboardingElement ShowTeachingTip()
{
OnboardingElement onboardingElement = null;

if (_step < 0 || IsDisabled)
{
return onboardingElement;
}

if (_step < _onboardingElements.Length)
{
Expand Down
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Helpers/RatioHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class RatioHelper
public static Tuple<int, int> Convert(int width, int height, int newHeight, int newWidth)
{
//calculate the ratio
double ratio = (double)width / (double)height;
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
Expand Down
5 changes: 1 addition & 4 deletions Yugen.Mosaic.Uwp/Helpers/ResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ public static class ResourceHelper
{
private static readonly ResourceLoader _resourceLoader = _resourceLoader ?? new ResourceLoader();

public static string GetText(string key)
{
return _resourceLoader.GetString(key);
}
public static string GetText(string key) => _resourceLoader.GetString(key);
}
}
18 changes: 18 additions & 0 deletions Yugen.Mosaic.Uwp/Interfaces/IMosaicService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System.IO;
using Windows.Storage.Streams;

namespace Yugen.Mosaic.Uwp.Interfaces
{
public interface IMosaicService
{
Image<Rgba32> AddMasterImage(Stream stream);
Image<Rgba32> AddTileImage(string name, Stream stream);
Image<Rgba32> GenerateMosaic(Size outputSize, Size tileSize, int mosaicType);
Image<Rgba32> GetResizedImage(Image<Rgba32> image, int size);
InMemoryRandomAccessStream GetStream(Image<Rgba32> image);
void RemoveTileImage(string name);
void Reset();
}
}
4 changes: 2 additions & 2 deletions Yugen.Mosaic.Uwp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public sealed partial class MainPage : Page

public MainPage()
{
this.InitializeComponent();
InitializeComponent();
ExtendToTitleBar();
}

private void ExtendToTitleBar()
{
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
}

Expand Down
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Processors/AdjustHueProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
// int B = Math.Min(255, Math.Max(0, (pixel.B + _averageColor.B) / 2));

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

// TPixel pixelColor = clAvg.ToPixel<TPixel>();
// _source[w, h] = pixelColor;
// }
Expand Down
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Processors/ApplyTileFoundProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

// _outputImage = definition.OutputImage;
// }

// /// <inheritdoc/>
// public void Execute()
// {
Expand Down
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Processors/GetTileAverageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
// _resizedImage = definition.ResizedImage;
// _averageColor = definition.AverageColor;
// }

// /// <inheritdoc/>
// public void Execute()
// {
Expand Down
1 change: 0 additions & 1 deletion Yugen.Mosaic.Uwp/Processors/GetTilesAverageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//using System;
//using System.Threading.Tasks;
//using Rectangle = SixLabors.ImageSharp.Rectangle;
//using Size = SixLabors.ImageSharp.Size;

//namespace Yugen.Mosaic.Uwp.Processors
//{
Expand Down
1 change: 0 additions & 1 deletion Yugen.Mosaic.Uwp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
15 changes: 7 additions & 8 deletions Yugen.Mosaic.Uwp/Services/AdjustHueSearchAndReplaceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Yugen.Mosaic.Uwp.Models;
using Size = SixLabors.ImageSharp.Size;

namespace Yugen.Mosaic.Uwp.Services
{
Expand All @@ -18,17 +17,17 @@ public AdjustHueSearchAndReplaceService(Image<Rgba32> outputImage, Size tileSize
// Adjust hue - get the first (random) tile found and adjust its colours to suit the average
public override void SearchAndReplace()
{
Random r = new Random();
List<Tile> tileQueue = new List<Tile>();
var r = new Random();
var tileQueue = new List<Tile>();
//int maxQueueLength = Math.Min(1000, Math.Max(0, _tileImageList.Count - 50));

Parallel.For(0, _tX * _tY, xy =>
{
int y = xy / _tX;
int x = xy % _tX;
var y = xy / _tX;
var x = xy % _tX;

// (R * ColCount) + C
int index = ((y * _tX) + x) % _tileImageList.Count;
var index = ((y * _tX) + x) % _tileImageList.Count;

// Check if it's the same as the last (X)?
//if (tileQueue.Count > 1)
Expand All @@ -46,7 +45,7 @@ public override void SearchAndReplace()
//tileQueue.Add(tileFound);

// Adjust the hue
Image<Rgba32> adjustedImage = new Image<Rgba32>(tileFound.ResizedImage.Width, tileFound.ResizedImage.Height);
var adjustedImage = new Image<Rgba32>(tileFound.ResizedImage.Width, tileFound.ResizedImage.Height);

//var adjustHueProcessor = new AdjustHueProcessor(tileFound.ResizedImage, _avgsMaster[x, y]);
//adjustedImage.Mutate(c => c.ApplyProcessor(adjustHueProcessor));
Expand All @@ -57,7 +56,7 @@ public override void SearchAndReplace()
//var applyTileFoundProcessor = new ApplyTileFoundProcessor(x, y, tileSize.Width, tileSize.Height, outputImage);
//adjustedImage.Mutate(c => c.ApplyProcessor(applyTileFoundProcessor));

this.ApplyTileFoundProcessor(x, y, adjustedImage);
ApplyTileFoundProcessor(x, y, adjustedImage);

//_progress++;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;
using Yugen.Mosaic.Uwp.Helpers;
using Yugen.Mosaic.Uwp.Models;
using Size = SixLabors.ImageSharp.Size;

namespace Yugen.Mosaic.Uwp.Services
{
Expand Down
Loading

0 comments on commit c49fa4f

Please sign in to comment.