Skip to content

Commit

Permalink
Merge pull request #23 from Panda-Sharp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Panda-Sharp authored Jul 9, 2021
2 parents c51b03c + cd8c1ab commit 13a7d6e
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 91 deletions.
15 changes: 3 additions & 12 deletions Yugen.Mosaic.Uwp/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Application x:Class="Yugen.Mosaic.Uwp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Yugen.Mosaic.Uwp"
xmlns:converters="using:Yugen.Toolkit.Uwp.Converters"
xmlns:validation="using:Yugen.Toolkit.Standard.Validation">
xmlns:validation="using:Yugen.Toolkit.Standard.Validation"
xmlns:converters="using:Yugen.Toolkit.Uwp.Converters">

<Application.Resources>

Expand Down Expand Up @@ -284,9 +283,7 @@
<Setter Property="Foreground"
Value="{ThemeResource AppForegroundBrush}" />
</Style>

</ResourceDictionary>

</ResourceDictionary.MergedDictionaries>

<ResourceDictionary.ThemeDictionaries>
Expand Down Expand Up @@ -318,7 +315,6 @@
<Color x:Key="TitleBarButtonForeground">#242424</Color>
<Color x:Key="TitleBarButtonHoverBackground">White</Color>
<Color x:Key="TitleBarButtonHoverForeground">#242424</Color>

</ResourceDictionary>

<ResourceDictionary x:Key="Dark">
Expand Down Expand Up @@ -348,9 +344,7 @@
<Color x:Key="TitleBarButtonForeground">#dcdcdc</Color>
<Color x:Key="TitleBarButtonHoverBackground">#262626</Color>
<Color x:Key="TitleBarButtonHoverForeground">#dcdcdc</Color>

</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
Expand All @@ -360,9 +354,6 @@
<validation:RegexValidationRule RegexPattern="^[1-9]\d*$" />
</validation:ValidationRules.Rules>
</validation:ValidationRules>

</ResourceDictionary>

</Application.Resources>

</Application>
</Application>
5 changes: 2 additions & 3 deletions Yugen.Mosaic.Uwp/Controls/SettingsDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<dialogs:YugenDialog x:Class="Yugen.Mosaic.Uwp.Controls.SettingsDialog"
x:Uid="Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xaml="using:Windows.UI.Xaml"
xmlns:converters="using:Yugen.Toolkit.Uwp.Converters"
xmlns:dialogs="using:Yugen.Toolkit.Uwp.Controls.Dialogs"
xmlns:converters="using:Yugen.Toolkit.Uwp.Converters"
mc:Ignorable="d"
Background="{ThemeResource AppDeepBackgroundBrush}"
RequestedTheme="{x:Bind ViewModel.ElementTheme, Mode=OneWay}">
Expand Down Expand Up @@ -86,5 +86,4 @@
Margin="0,-4,0,0"
Style="{ThemeResource YugenHyperlinkButtonStyle}" />
</StackPanel>

</dialogs:YugenDialog>
11 changes: 4 additions & 7 deletions Yugen.Mosaic.Uwp/Controls/WhatsNewDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<dialogs:YugenDialog x:Class="Yugen.Mosaic.Uwp.Controls.WhatsNewDialog"
x:Uid="WhatsNew"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Yugen.Mosaic.Uwp.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dialogs="using:Yugen.Toolkit.Uwp.Controls.Dialogs"
mc:Ignorable="d"
Expand All @@ -13,9 +12,9 @@

<TextBlock Text="{x:Bind ViewModel.Body}"
TextWrapping="WrapWholeWords" />

<!--Footer-->
<Image Margin="0,16,0,0"
<Image Margin="0,16,0,0"
Source="ms-appx:///Assets/Images/UWPCommunityGif.gif"
Stretch="Uniform"
Width="60" />
Expand All @@ -34,7 +33,5 @@
FontStyle="Italic"
HorizontalAlignment="Center"
Style="{ThemeResource YugenHyperlinkButtonStyle}" />

</StackPanel>

</dialogs:YugenDialog>
</dialogs:YugenDialog>
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Controls/WhatsNewDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public WhatsNewDialog()

private WhatsNewViewModel ViewModel => (WhatsNewViewModel)DataContext;
}
}
}
3 changes: 1 addition & 2 deletions Yugen.Mosaic.Uwp/Helpers/OnboardingHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml;
using Yugen.Mosaic.Uwp.Enums;
using Yugen.Mosaic.Uwp.Models;
using Yugen.Toolkit.Uwp.Helpers;
Expand Down
3 changes: 3 additions & 0 deletions Yugen.Mosaic.Uwp/Models/OnboardingElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public OnboardingElement(FrameworkElement target, OnboardingStage stage)
}

public OnboardingStage Stage { get; set; }

public string Subtitle { get; set; }

public FrameworkElement Target { get; set; }

public string Title { get; set; }
}
}
2 changes: 1 addition & 1 deletion Yugen.Mosaic.Uwp/Models/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Process(Size tileSize, IRandomAccessStream RandomAccessStream)
{
using (var stream = RandomAccessStream.AsStreamForRead())
{
ResizedImage = Image.Load<Rgba32>(stream);
ResizedImage = Image.Load<Rgba32>(stream);
}
ResizedImage.Mutate(x => x.Resize(tileSize));

Expand Down
1 change: 1 addition & 0 deletions Yugen.Mosaic.Uwp/Models/TileFound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public TileFound(Tile tile, int difference)
}

public Tile Tile { get; set; }

public int Difference { get; set; }
}
}
6 changes: 3 additions & 3 deletions Yugen.Mosaic.Uwp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Yugen.Mosaic.Uwp")]
Expand All @@ -16,11 +16,11 @@
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
Expand Down
7 changes: 3 additions & 4 deletions Yugen.Mosaic.Uwp/Properties/Default.rd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
To fully enable reflection for App1.MyClass and all of its public/private members
<Type Name="App1.MyClass" Dynamic="Required All"/>
<Type Name="App1.MyClass" Dynamic="Required All" />
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
Expand All @@ -21,9 +21,8 @@
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />

<!-- Add your application specific runtime directives here. -->
<Assembly Name="*Application*" Dynamic="Required All" />

<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>
8 changes: 4 additions & 4 deletions Yugen.Mosaic.Uwp/Services/MosaicService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ namespace Yugen.Mosaic.Uwp.Services
public class MosaicService : IMosaicService
{
private readonly IProgressService _progressService;

private readonly List<Tile> _tileImageList = new List<Tile>();
private readonly ISearchAndReplaceAsciiArtService _searchAndReplaceAsciiArtService;
private readonly ISearchAndReplaceServiceFactory _searchAndReplaceServiceFactory;
private readonly List<Tile> _tileImageList = new List<Tile>();

private Rgba32[,] _avgsMaster;
private int _tX;
private int _tY;
private Image<Rgba32> _masterImage;
private Size _tileSize;
private ISearchAndReplaceService _searchAndReplaceService;
private readonly ISearchAndReplaceServiceFactory _searchAndReplaceServiceFactory;

public MosaicService(
IProgressService progressService,
IProgressService progressService,
ISearchAndReplaceAsciiArtService searchAndReplaceAsciiArtService,
ISearchAndReplaceServiceFactory searchAndReplaceServiceFactory)
{
Expand Down
4 changes: 4 additions & 0 deletions Yugen.Mosaic.Uwp/Services/SearchAndReplaceServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ public ISearchAndReplaceService Create(MosaicTypeEnum type)
{
case MosaicTypeEnum.AdjustHue:
return _adjusthue();

case MosaicTypeEnum.Classic:
return _classic();

case MosaicTypeEnum.PlainColor:
return _plainColor();

case MosaicTypeEnum.Random:
return _random();

default:
throw new InvalidOperationException();
}
Expand Down
46 changes: 33 additions & 13 deletions Yugen.Mosaic.Uwp/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ private async Task AddMasterImageCommandBehavior()
{
StartProgressRing(true);

ResetSizes();

using (var inputStream = await masterFile.OpenReadAsync())
{
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
Expand All @@ -309,10 +311,11 @@ await dispatcherQueue.EnqueueAsync(async () =>
{
var bmp = new BitmapImage
{
DecodePixelHeight = 400
DecodePixelHeight = 400,
DecodePixelType = DecodePixelType.Logical
};
await bmp.SetSourceAsync(inputStream);
MasterBpmSource = bmp;
await bmp.SetSourceAsync(inputStream);
});
}

Expand Down Expand Up @@ -395,18 +398,25 @@ await Task.Run(() =>
{
try
{
using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(
ThumbnailMode.SingleItem, 120, ThumbnailOptions.None))
StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(
ThumbnailMode.SingleItem, 120, ThumbnailOptions.None);

if(thumbnail.Type == ThumbnailType.Icon)
{
await dispatcherQueue.EnqueueAsync(async () =>
{
BitmapImage bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(thumbnail);

TileBmpCollection.Add(new TileBmp(file.DisplayName, bitmapImage));
});
thumbnail.Dispose();
thumbnail = await file.GetThumbnailAsync(
ThumbnailMode.SingleItem, 120, ThumbnailOptions.None);
}

await dispatcherQueue.EnqueueAsync(async () =>
{
BitmapImage bitmapImage = new BitmapImage();
TileBmpCollection.Add(new TileBmp(file.DisplayName, bitmapImage));
await bitmapImage.SetSourceAsync(thumbnail);
});

thumbnail.Dispose();

_mosaicService.AddTileImage(file.DisplayName, file);
}
catch (Exception exception)
Expand Down Expand Up @@ -498,8 +508,8 @@ private async Task SaveCommandBehavior()
}

StopProgressRing();
}
}

private async Task SaveAsTextCommandBehavior()
{
StartProgressRing(false);
Expand Down Expand Up @@ -531,11 +541,21 @@ private void ResetCommandBehavior()
MasterBpmSource = new BitmapImage();
TileBmpCollection = new ObservableCollection<TileBmp>();

ResetSizes();

GC.Collect();

UpdateIsAddMasterUIVisible();
}

private void ResetSizes()
{
OutputHeight = 1000;
OutputWidth = 1000;
TileHeight = 25;
TileWidth = 25;
}

private void HelpCommandBehavior()
{
OnboardingHelper.Reset();
Expand Down
6 changes: 4 additions & 2 deletions Yugen.Mosaic.Uwp/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public SettingsViewModel(IThemeSelectorService themeSelectorService)
{
_themeSelectorService = themeSelectorService;

_elementTheme = _themeSelectorService.Theme;
_elementTheme = _themeSelectorService.Theme;

SwitchThemeCommand = new AsyncRelayCommand<ElementTheme>(SwitchThemeCommandBehavior);
}

public string AppVersion => SystemHelper.AppVersion;

public string Publisher => SystemHelper.Publisher;

public string RateAndReviewUri => SystemHelper.RateAndReviewUri;

public ElementTheme ElementTheme
Expand Down
Loading

0 comments on commit 13a7d6e

Please sign in to comment.