Skip to content

Commit b703081

Browse files
authored
Merge pull request #62 from TheJoeFin/dev
v 1.14
2 parents cb17e0e + 342d064 commit b703081

42 files changed

Lines changed: 2023 additions & 1174 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: windows-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '9.0.x'
22+
23+
- name: Add MSBuild to PATH
24+
uses: microsoft/setup-msbuild@v2
25+
26+
- name: Restore dependencies
27+
run: dotnet restore "Simple Icon File Maker.sln"
28+
29+
- name: Build solution
30+
run: dotnet build "Simple Icon File Maker.sln" --configuration Release --no-restore

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A small lightweight Windows app which creates .ico files with different resoluti
2121

2222
## How to use
2323

24-
1. Open an image or drag an image on to the app
24+
1. Open an image or drag an image on to the app, or paste from clipboard (Ctrl+V)
2525
2. Review the preview images at each size
2626
3. Save .ico to a folder
2727

Simple Icon File Maker/Simple Icon File Maker (Package)/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Identity
1010
Name="40087JoeFinApps.SimpleIconFileMaker"
1111
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
12-
Version="1.13.2.0" />
12+
Version="1.14.0.0" />
1313

1414
<Properties>
1515
<DisplayName>Simple Icon File Maker</DisplayName>

Simple Icon File Maker/Simple Icon File Maker (Package)/Simple Icon File Maker (Package).wapproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@
120120
</ProjectReference>
121121
</ItemGroup>
122122
<ItemGroup>
123-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001">
123+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.251106002">
124124
<IncludeAssets>build</IncludeAssets>
125125
</PackageReference>
126-
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4948">
126+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.7175">
127127
<IncludeAssets>build</IncludeAssets>
128128
</PackageReference>
129-
<PackageReference Include="WinUIEx" Version="2.6.0" />
129+
<PackageReference Include="WinUIEx" Version="2.9.0" />
130130
</ItemGroup>
131131
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
132132
</Project>

Simple Icon File Maker/Simple Icon File Maker/Activation/ActivationHandler.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ public abstract class ActivationHandler<T> : IActivationHandler
44
where T : class
55
{
66
// Override this method to add the logic for whether to handle the activation.
7-
protected virtual bool CanHandleInternal(T args) => true;
7+
protected virtual bool CanHandleInternal(T args)
8+
{
9+
return true;
10+
}
811

912
// Override this method to add the logic for your activation handler.
1013
protected abstract Task HandleInternalAsync(T args);
1114

12-
public bool CanHandle(object args) => args is T && CanHandleInternal((args as T)!);
15+
public bool CanHandle(object args)
16+
{
17+
return args is T && CanHandleInternal((args as T)!);
18+
}
1319

14-
public async Task HandleAsync(object args) => await HandleInternalAsync((args as T)!);
20+
public async Task HandleAsync(object args)
21+
{
22+
await HandleInternalAsync((args as T)!);
23+
}
1524
}

Simple Icon File Maker/Simple Icon File Maker/Activation/DefaultActivationHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected override bool CanHandleInternal(LaunchActivatedEventArgs args)
2121
return _navigationService.Frame?.Content == null;
2222
}
2323

24-
protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args)
24+
protected override async Task HandleInternalAsync(LaunchActivatedEventArgs args)
2525
{
2626
_navigationService.NavigateTo(typeof(MainViewModel).FullName!, args.Arguments);
2727

Simple Icon File Maker/Simple Icon File Maker/App.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Microsoft.Extensions.Hosting;
33
using Microsoft.UI.Xaml;
4-
5-
using Simple_Icon_File_Maker.Contracts.Services;
6-
using Simple_Icon_File_Maker.Services;
74
using Simple_Icon_File_Maker.Activation;
5+
using Simple_Icon_File_Maker.Contracts.Services;
86
using Simple_Icon_File_Maker.Models;
9-
using Simple_Icon_File_Maker.Views;
7+
using Simple_Icon_File_Maker.Services;
108
using Simple_Icon_File_Maker.ViewModels;
9+
using Simple_Icon_File_Maker.Views;
1110

1211
namespace Simple_Icon_File_Maker;
1312

@@ -73,6 +72,7 @@ public App()
7372
services.AddTransient<AboutViewModel>();
7473
services.AddTransient<MultiPage>();
7574
services.AddTransient<MultiViewModel>();
75+
services.AddTransient<SizesControlViewModel>();
7676

7777
// Configuration
7878
services.Configure<LocalSettingsOptions>(context.Configuration.GetSection(nameof(LocalSettingsOptions)));
@@ -90,7 +90,7 @@ private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledEx
9090
e.Handled = true;
9191
}
9292

93-
protected async override void OnLaunched(LaunchActivatedEventArgs args)
93+
protected override async void OnLaunched(LaunchActivatedEventArgs args)
9494
{
9595
base.OnLaunched(args);
9696
await App.GetService<IActivationService>().ActivateAsync(args);

Simple Icon File Maker/Simple Icon File Maker/Contracts/Services/IIconSizesService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ namespace Simple_Icon_File_Maker.Contracts.Services;
55
public interface IIconSizesService
66
{
77
List<IconSize> IconSizes { get; }
8+
IconSortOrder SortOrder { get; }
89
Task Save(IEnumerable<IconSize> iconSizes);
10+
Task SaveSortOrder(IconSortOrder sortOrder);
911

1012
Task InitializeAsync();
1113
}

Simple Icon File Maker/Simple Icon File Maker/Controls/PreviewImage.xaml.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ namespace Simple_Icon_File_Maker.Controls;
1717

1818
public sealed partial class PreviewImage : UserControl
1919
{
20-
readonly string OriginalName = string.Empty;
21-
readonly StorageFile _imageFile;
22-
readonly int _sideLength = 0;
20+
private readonly string OriginalName = string.Empty;
21+
private readonly StorageFile _imageFile;
22+
private readonly int _sideLength = 0;
2323

2424
public PreviewImage(StorageFile imageFile, int sideLength, string originalName)
2525
{
@@ -35,10 +35,7 @@ public PreviewImage(StorageFile imageFile, int sideLength, string originalName)
3535

3636
public bool ZoomPreview
3737
{
38-
get
39-
{
40-
return isZooming;
41-
}
38+
get => isZooming;
4239
set
4340
{
4441
if (value != isZooming)
@@ -148,8 +145,10 @@ private void LoadImageOnToCanvas()
148145
};
149146

150147
// add the visual as a child to canvas
151-
Grid tempGrid = new();
152-
tempGrid.Background = new SolidColorBrush(Colors.Transparent);
148+
Grid tempGrid = new()
149+
{
150+
Background = new SolidColorBrush(Colors.Transparent)
151+
};
153152
ElementCompositionPreview.SetElementChildVisual(tempGrid, imageVisual);
154153
mainImageCanvas.Children.Add(tempGrid);
155154
}

Simple Icon File Maker/Simple Icon File Maker/Controls/PreviewStack.xaml.cs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public sealed partial class PreviewStack : UserControl
2525

2626
public int SmallerSourceSide { get; private set; }
2727

28+
public IconSortOrder SortOrder { get; set; } = IconSortOrder.LargestFirst;
29+
2830
public PreviewStack(string path, List<IconSize> sizes, bool showTitle = false)
2931
{
3032
StorageFolder sf = ApplicationData.Current.LocalCacheFolder;
@@ -70,11 +72,19 @@ public void ClearChildren()
7072
PreviewStackPanel.Children.Clear();
7173
}
7274

73-
public async Task SaveIconAsync(string outputPath = "")
75+
public async Task SaveIconAsync(string outputPath = "", IconSortOrder sortOrder = IconSortOrder.LargestFirst)
7476
{
7577
MagickImageCollection collection = [];
7678

77-
foreach ((_, string path) in imagePaths)
79+
// Sort the imagePaths based on the sort order
80+
List<(string sideLength, string path)> sortedPaths = sortOrder switch
81+
{
82+
IconSortOrder.LargestFirst => [.. imagePaths.OrderByDescending(p => int.TryParse(p.Item1, out int size) ? size : 0)],
83+
IconSortOrder.SmallestFirst => [.. imagePaths.OrderBy(p => int.TryParse(p.Item1, out int size) ? size : 0)],
84+
_ => [.. imagePaths.OrderByDescending(p => int.TryParse(p.Item1, out int size) ? size : 0)]
85+
};
86+
87+
foreach ((_, string path) in sortedPaths)
7888
collection.Add(path);
7989

8090
if (string.IsNullOrWhiteSpace(outputPath))
@@ -95,15 +105,15 @@ await Task.Run(async () =>
95105
});
96106
}
97107

98-
public async Task SaveAllImagesAsync(string outputPath = "")
108+
public async Task SaveAllImagesAsync(string outputPath = "", IconSortOrder sortOrder = IconSortOrder.LargestFirst)
99109
{
100110
if (string.IsNullOrWhiteSpace(outputPath))
101111
{
102112
outputPath = Path.Combine(Path.GetDirectoryName(imagePath) ?? string.Empty,
103113
$"{Path.GetFileNameWithoutExtension(imagePath)}.ico");
104114
}
105115

106-
await SaveIconAsync(outputPath);
116+
await SaveIconAsync(outputPath, sortOrder);
107117

108118
string outputFolderPath = Path.GetDirectoryName(outputPath) ?? string.Empty;
109119

@@ -338,13 +348,22 @@ private void ClearOutputImages()
338348

339349
public async Task UpdatePreviewsAsync()
340350
{
351+
PreviewStackPanel.Children.Clear();
352+
341353
string originalName = Path.GetFileNameWithoutExtension(imagePath);
342-
foreach ((string sideLength, string path) pair in imagePaths)
354+
355+
// Sort imagePaths based on the sort order
356+
List<(string sideLength, string path)> sortedPaths = SortOrder switch
343357
{
344-
if (pair.path is not string imagePath)
345-
continue;
358+
IconSortOrder.LargestFirst => [.. imagePaths.OrderByDescending(p => int.TryParse(p.Item1, out int size) ? size : 0)],
359+
IconSortOrder.SmallestFirst => [.. imagePaths.OrderBy(p => int.TryParse(p.Item1, out int size) ? size : 0)],
360+
_ => [.. imagePaths.OrderByDescending(p => int.TryParse(p.Item1, out int size) ? size : 0)]
361+
};
346362

347-
if (!int.TryParse(pair.sideLength, out int sideLength))
363+
foreach ((string sideLength, string path) pair in sortedPaths)
364+
{
365+
if (pair.path is not string imagePath
366+
|| !int.TryParse(pair.sideLength, out int sideLength))
348367
continue;
349368

350369
StorageFile imageSF = await StorageFile.GetFileFromPathAsync(imagePath);
@@ -357,6 +376,11 @@ public async Task UpdatePreviewsAsync()
357376
await Task.CompletedTask;
358377
}
359378

379+
public async Task RefreshPreviewsWithSortOrder()
380+
{
381+
await UpdatePreviewsAsync();
382+
}
383+
360384
private bool CheckIfRefreshIsNeeded()
361385
{
362386
if (imagePaths.Count < 1)
@@ -384,12 +408,12 @@ public void UpdateSizeAndZoom()
384408

385409
foreach (UIElement? child in previewBoxes)
386410
{
387-
if (child is PreviewImage img)
388-
{
389-
if (!double.IsNaN(ActualWidth) && ActualWidth > 40)
390-
img.ZoomedWidthSpace = (int)ActualWidth - 40;
391-
img.ZoomPreview = IsZoomingPreview;
392-
}
411+
if (child is not PreviewImage img)
412+
continue;
413+
414+
if (!double.IsNaN(ActualWidth) && ActualWidth > 40)
415+
img.ZoomedWidthSpace = (int)ActualWidth - 40;
416+
img.ZoomPreview = IsZoomingPreview;
393417
}
394418
}
395419
}

0 commit comments

Comments
 (0)