Skip to content

Commit a9a0f13

Browse files
committed
Code style
1 parent 4377054 commit a9a0f13

10 files changed

Lines changed: 52 additions & 69 deletions

File tree

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ private void ClearOutputImages()
349349
public async Task UpdatePreviewsAsync()
350350
{
351351
PreviewStackPanel.Children.Clear();
352-
352+
353353
string originalName = Path.GetFileNameWithoutExtension(imagePath);
354-
354+
355355
// Sort imagePaths based on the sort order
356356
List<(string sideLength, string path)> sortedPaths = SortOrder switch
357357
{
@@ -362,10 +362,8 @@ public async Task UpdatePreviewsAsync()
362362

363363
foreach ((string sideLength, string path) pair in sortedPaths)
364364
{
365-
if (pair.path is not string imagePath)
366-
continue;
367-
368-
if (!int.TryParse(pair.sideLength, out int sideLength))
365+
if (pair.path is not string imagePath
366+
|| !int.TryParse(pair.sideLength, out int sideLength))
369367
continue;
370368

371369
StorageFile imageSF = await StorageFile.GetFileFromPathAsync(imagePath);
@@ -410,12 +408,12 @@ public void UpdateSizeAndZoom()
410408

411409
foreach (UIElement? child in previewBoxes)
412410
{
413-
if (child is PreviewImage img)
414-
{
415-
if (!double.IsNaN(ActualWidth) && ActualWidth > 40)
416-
img.ZoomedWidthSpace = (int)ActualWidth - 40;
417-
img.ZoomPreview = IsZoomingPreview;
418-
}
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;
419417
}
420418
}
421419
}

Simple Icon File Maker/Simple Icon File Maker/Controls/SizesControl.xaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<UserControl
33
x:Class="Simple_Icon_File_Maker.Controls.SizesControl"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:local="using:Simple_Icon_File_Maker.Controls"
7-
xmlns:models="using:Simple_Icon_File_Maker.Models"
86
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:local="using:Simple_Icon_File_Maker.Controls"
98
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:models="using:Simple_Icon_File_Maker.Models"
1010
mc:Ignorable="d">
1111

1212
<Grid RowSpacing="0">
@@ -16,22 +16,22 @@
1616
<RowDefinition Height="*" />
1717
</Grid.RowDefinitions>
1818

19-
<!-- Header with title and action buttons -->
19+
<!-- Header with title and action buttons -->
2020
<Grid Grid.Row="0">
2121
<TextBlock
2222
Margin="16,0,0,0"
2323
VerticalAlignment="Center"
2424
Style="{StaticResource BodyStrongTextBlockStyle}"
2525
Text="Icon sizes" />
26-
26+
2727
<StackPanel
2828
Margin="0,0,8,0"
2929
HorizontalAlignment="Right"
3030
VerticalAlignment="Center"
3131
Orientation="Horizontal"
3232
Spacing="8">
33-
34-
<!-- Edit Sizes Button (Pro) -->
33+
34+
<!-- Edit Sizes Button (Pro) -->
3535
<Button
3636
x:Name="EditSizesButton"
3737
Height="32"
@@ -52,25 +52,21 @@
5252
</Grid>
5353
</Button>
5454

55-
<!-- Sort Order Button -->
55+
<!-- Sort Order Button -->
5656
<DropDownButton
5757
x:Name="SortOrderButton"
5858
Height="32"
5959
ToolTipService.ToolTip="Sort order for .ico file">
6060
<FontIcon FontSize="16" Glyph="&#xE8CB;" />
6161
<DropDownButton.Flyout>
6262
<MenuFlyout>
63-
<MenuFlyoutItem
64-
Command="{x:Bind ViewModel.ChangeSortOrderCommand}"
65-
CommandParameter="{x:Bind models:IconSortOrder.LargestFirst}">
63+
<MenuFlyoutItem Command="{x:Bind ViewModel.ChangeSortOrderCommand}" CommandParameter="{x:Bind models:IconSortOrder.LargestFirst}">
6664
<MenuFlyoutItem.Icon>
6765
<FontIcon Glyph="&#xE70E;" />
6866
</MenuFlyoutItem.Icon>
6967
<MenuFlyoutItem.Text>Largest First</MenuFlyoutItem.Text>
7068
</MenuFlyoutItem>
71-
<MenuFlyoutItem
72-
Command="{x:Bind ViewModel.ChangeSortOrderCommand}"
73-
CommandParameter="{x:Bind models:IconSortOrder.SmallestFirst}">
69+
<MenuFlyoutItem Command="{x:Bind ViewModel.ChangeSortOrderCommand}" CommandParameter="{x:Bind models:IconSortOrder.SmallestFirst}">
7470
<MenuFlyoutItem.Icon>
7571
<FontIcon Glyph="&#xE70D;" />
7672
</MenuFlyoutItem.Icon>
@@ -80,7 +76,7 @@
8076
</DropDownButton.Flyout>
8177
</DropDownButton>
8278

83-
<!-- Select Sizes Button -->
79+
<!-- Select Sizes Button -->
8480
<DropDownButton
8581
x:Name="SelectSizesButton"
8682
Height="32"
@@ -119,7 +115,7 @@
119115
</StackPanel>
120116
</Grid>
121117

122-
<!-- Warning InfoBar -->
118+
<!-- Warning InfoBar -->
123119
<InfoBar
124120
x:Name="SizeDisabledWarning"
125121
Grid.Row="1"
@@ -130,7 +126,7 @@
130126
</TextBlock>
131127
</InfoBar>
132128

133-
<!-- Icon Sizes ListView -->
129+
<!-- Icon Sizes ListView -->
134130
<ListView
135131
x:Name="IconSizesListView"
136132
Grid.Row="2"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ public SizesControl()
1414
DataContext = ViewModel;
1515
}
1616

17-
// Method to update enabled sizes from parent
1817
public void UpdateEnabledSizes(int smallerImageSide)
1918
{
2019
ViewModel.UpdateEnabledSizes(smallerImageSide);
2120
}
2221

23-
// Method to reload icon sizes (e.g., after editing)
2422
public void ReloadIconSizes()
2523
{
2624
ViewModel.LoadIconSizes();

Simple Icon File Maker/Simple Icon File Maker/Models/IconSize.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Simple_Icon_File_Maker.Models;
66

77
[DebuggerDisplay("SideLength = {SideLength}, IsSelected = {IsSelected}")]
8-
public class IconSize : INotifyPropertyChanged, IEquatable<IconSize>
8+
public partial class IconSize : INotifyPropertyChanged, IEquatable<IconSize>
99
{
1010
public int SideLength { get; set; }
1111
public bool IsSelected { get; set; } = true;
@@ -60,7 +60,7 @@ public IconSize(IconSize iconSize)
6060
public static IconSize[] GetAllSizes()
6161
{
6262
return
63-
new IconSize[] {
63+
[
6464
//new() { SideLength = 1024, IsSelected = false },
6565
//new() { SideLength = 512, IsSelected = false },
6666
new() { SideLength = 256 },
@@ -76,42 +76,42 @@ public static IconSize[] GetAllSizes()
7676
new() { SideLength = 24, IsSelected = false},
7777
new() { SideLength = 20, IsSelected = false},
7878
new() { SideLength = 16 },
79-
};
79+
];
8080
}
8181

8282
public static IconSize[] GetWindowsSizesFull()
8383
{
8484
return
85-
new IconSize[] {
85+
[
8686
new() { SideLength = 256 },
8787
new() { SideLength = 128 },
8888
new() { SideLength = 64 },
8989
new() { SideLength = 32 },
9090
new() { SideLength = 16 },
91-
};
91+
];
9292
}
9393

9494
public static IconSize[] GetIdealWebSizesFull()
9595
{
9696
return
97-
new IconSize[] {
97+
[
9898
new() { SideLength = 192 },
9999
new() { SideLength = 180 },
100100
new() { SideLength = 48 },
101101
new() { SideLength = 32 },
102102
new() { SideLength = 24 },
103103
new() { SideLength = 16 },
104-
};
104+
];
105105
}
106106

107107
public static IconSize[] GetIdealWebSizesShort()
108108
{
109109
return
110-
new IconSize[] {
110+
[
111111
new() { SideLength = 48 },
112112
new() { SideLength = 32 },
113113
new() { SideLength = 16 },
114-
};
114+
];
115115
}
116116

117117
public override int GetHashCode()

Simple Icon File Maker/Simple Icon File Maker/Services/IconSizesService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public IconSizesService(ILocalSettingsService localSettingsService)
2020
public async Task InitializeAsync()
2121
{
2222
IconSizes = await IconSizeHelper.GetIconSizes();
23-
23+
2424
try
2525
{
2626
SortOrder = await _localSettingsService.ReadSettingAsync<IconSortOrder>(SortOrderKey);

Simple Icon File Maker/Simple Icon File Maker/ViewModels/MainViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public async Task UpdatePreviewsSortOrder()
325325
return;
326326

327327
UIElementCollection uIElements = PreviewsGrid.Children;
328-
328+
329329
// Get current sort order
330330
IconSortOrder sortOrder = _iconSizesService.SortOrder;
331331

Simple Icon File Maker/Simple Icon File Maker/ViewModels/MultiViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public async Task RegenPreviews()
113113
SizesGenerating = SizesControl.ViewModel.IconSizes.Count(x => x.IsSelected && x.IsEnabled && !x.IsHidden);
114114

115115
LoadingImages = false;
116-
116+
117117
// Reset refresh needed state after regeneration is complete
118118
IsRefreshNeeded = false;
119119
}
@@ -288,8 +288,8 @@ private async Task LoadFiles()
288288
FileLoadProgress = 0;
289289
CurrentImageRendering = 0;
290290

291-
List<IconSize> sizes = SizesControl.ViewModel.IconSizes.Where(x => x.IsSelected && x.IsEnabled && !x.IsHidden).ToList();
292-
291+
List<IconSize> sizes = [.. SizesControl.ViewModel.IconSizes.Where(x => x.IsSelected && x.IsEnabled && !x.IsHidden)];
292+
293293
// Get current sort order
294294
IIconSizesService iconSizesService = App.GetService<IIconSizesService>();
295295
IconSortOrder sortOrder = iconSizesService.SortOrder;

Simple Icon File Maker/Simple Icon File Maker/ViewModels/SizesControlViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public SizesControlViewModel(IIconSizesService iconSizesService, IStoreService s
2727
{
2828
_iconSizesService = iconSizesService;
2929
_storeService = storeService;
30-
30+
3131
currentSortOrder = _iconSizesService.SortOrder;
3232
LoadIconSizes();
3333
}
@@ -51,7 +51,7 @@ private async Task ChangeSortOrder(IconSortOrder newSortOrder)
5151
private async Task EditIconSizes()
5252
{
5353
bool ownsPro = _storeService.OwnsPro;
54-
54+
5555
if (ownsPro)
5656
{
5757
EditIconSizesRequested?.Invoke(this, EventArgs.Empty);

Simple Icon File Maker/Simple Icon File Maker/Views/MainPage.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
x:Class="Simple_Icon_File_Maker.MainPage"
66
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
77
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
8+
xmlns:controls="using:Simple_Icon_File_Maker.Controls"
89
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
910
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1011
xmlns:models="using:Simple_Icon_File_Maker.Models"
11-
xmlns:controls="using:Simple_Icon_File_Maker.Controls"
1212
xmlns:toolkitConverters="using:CommunityToolkit.WinUI.Converters"
1313
SizeChanged="Page_SizeChanged"
1414
mc:Ignorable="d">
@@ -332,10 +332,10 @@
332332
<RowDefinition Height="*" />
333333
<RowDefinition Height="Auto" />
334334
</Grid.RowDefinitions>
335-
336-
<!-- Use the new SizesControl -->
335+
336+
<!-- Use the new SizesControl -->
337337
<controls:SizesControl x:Name="SizesControlInstance" Grid.Row="0" />
338-
338+
339339
<Grid
340340
Grid.Row="1"
341341
Padding="8"

Simple Icon File Maker/Simple Icon File Maker/Views/MultiPage.xaml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
x:Class="Simple_Icon_File_Maker.Views.MultiPage"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6-
xmlns:converters="using:Simple_Icon_File_Maker.Converters"
76
xmlns:controls="using:Simple_Icon_File_Maker.Controls"
7+
xmlns:converters="using:Simple_Icon_File_Maker.Converters"
88
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
99
xmlns:local="using:Simple_Icon_File_Maker.Views"
1010
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -116,8 +116,8 @@
116116
Grid.Row="1"
117117
Style="{StaticResource CardStyle}"
118118
Visibility="Visible">
119-
120-
<!-- Use the new SizesControl -->
119+
120+
<!-- Use the new SizesControl -->
121121
<controls:SizesControl x:Name="SizesControlInstance" />
122122
</Grid>
123123

@@ -129,9 +129,7 @@
129129
<tk:SettingsExpander Description="Expand for more options" HeaderIcon="{ui:FontIcon Glyph=&#xEA35;}">
130130
<Button
131131
Command="{x:Bind ViewModel.SaveAllIconsCommand}"
132-
IsEnabled="{x:Bind ViewModel.LoadingImages,
133-
Mode=OneWay,
134-
Converter={StaticResource BoolInv}}"
132+
IsEnabled="{x:Bind ViewModel.LoadingImages, Mode=OneWay, Converter={StaticResource BoolInv}}"
135133
Style="{StaticResource AccentButtonStyle}">
136134
<TextBlock>
137135
<Run Text="Save" />
@@ -203,9 +201,7 @@
203201
<Button
204202
Height="32"
205203
Command="{x:Bind ViewModel.RegenPreviewsCommand}"
206-
Style="{x:Bind ViewModel.IsRefreshNeeded,
207-
Mode=OneWay,
208-
Converter={StaticResource IsPrimary}}">
204+
Style="{x:Bind ViewModel.IsRefreshNeeded, Mode=OneWay, Converter={StaticResource IsPrimary}}">
209205
<StackPanel Orientation="Horizontal" Spacing="8">
210206
<TextBlock
211207
FontFamily="{StaticResource SymbolThemeFontFamily}"
@@ -221,8 +217,7 @@
221217
Content="&#xE8A3;"
222218
FontFamily="{StaticResource SymbolThemeFontFamily}"
223219
FontSize="16"
224-
IsChecked="{x:Bind ViewModel.ArePreviewsZoomed,
225-
Mode=TwoWay}"
220+
IsChecked="{x:Bind ViewModel.ArePreviewsZoomed, Mode=TwoWay}"
226221
Tapped="{x:Bind ViewModel.ZoomPreviews}" />
227222
</Grid>
228223

@@ -233,8 +228,7 @@
233228
<ItemsControl
234229
Grid.Row="1"
235230
Padding="6"
236-
ItemsSource="{x:Bind ViewModel.Previews,
237-
Mode=OneWay}">
231+
ItemsSource="{x:Bind ViewModel.Previews, Mode=OneWay}">
238232
<ItemsControl.ItemsPanel>
239233
<ItemsPanelTemplate>
240234
<VirtualizingStackPanel Orientation="Horizontal" />
@@ -247,9 +241,7 @@
247241
<Grid
248242
Grid.Row="1"
249243
Grid.Column="1"
250-
Visibility="{x:Bind ViewModel.LoadingImages,
251-
Mode=OneWay,
252-
Converter={StaticResource BoolVis}}">
244+
Visibility="{x:Bind ViewModel.LoadingImages, Mode=OneWay, Converter={StaticResource BoolVis}}">
253245
<Viewbox
254246
MaxWidth="200"
255247
MaxHeight="200"
@@ -263,8 +255,7 @@
263255
<ProgressRing
264256
x:Name="LoadingImagesProgress"
265257
IsIndeterminate="False"
266-
Value="{x:Bind ViewModel.FileLoadProgress,
267-
Mode=OneWay}" />
258+
Value="{x:Bind ViewModel.FileLoadProgress, Mode=OneWay}" />
268259
</Grid>
269260
</Viewbox>
270261
<TextBlock

0 commit comments

Comments
 (0)