Skip to content
Closed
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
21 changes: 21 additions & 0 deletions DeskFrame/Converters/IconSizeToImageHeightConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Windows.Data;

namespace DeskFrame
{
public class IconSizeToImageHeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is int iconSize)
{
return iconSize;
}
return 32; // Default size
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
21 changes: 21 additions & 0 deletions DeskFrame/Converters/IconSizeToImageWidthConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Windows.Data;

namespace DeskFrame
{
public class IconSizeToImageWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is int iconSize)
{
return iconSize;
}
return 32; // Default size
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
21 changes: 21 additions & 0 deletions DeskFrame/Converters/IconSizeToItemHeightConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Windows.Data;

namespace DeskFrame
{
public class IconSizeToItemHeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is int iconSize)
{
return iconSize + 40 + iconSize / 4;
}
return 72; // 32 + 40
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
21 changes: 21 additions & 0 deletions DeskFrame/Converters/IconSizeToItemWidthConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Windows.Data;

namespace DeskFrame
{
public class IconSizeToItemWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is int iconSize)
{
return iconSize + 20;
}
return 85;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
3 changes: 2 additions & 1 deletion DeskFrame/Converters/OffsetConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace DeskFrame
Expand Down
32 changes: 31 additions & 1 deletion DeskFrame/Core/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ public class Instance : INotifyPropertyChanged
private int _folderOrder = 0;
private int[] _showOnVirtualDesktops;
private double _titleFontSize = 13;
private int _iconSize = 32;
private string _id;

public string Id
{
get => _id;
set
{
if (_id != value)
{
_id = value;
OnPropertyChanged(nameof(Id), value);
}
}
}

public int IconSize
{
get => _iconSize;
set
{
if (_iconSize != value)
{
_iconSize = value;
OnPropertyChanged(nameof(IconSize), value.ToString());
}
}
}

public double PosX
{
get => _posX;
Expand Down Expand Up @@ -466,6 +495,7 @@ public Instance(Instance instance)
_sortBy = instance._sortBy;
_titleFontSize = instance._titleFontSize;
_titleFontFamily = instance._titleFontFamily;
_iconSize = instance._iconSize;
}

public Instance(string name) // default instance
Expand All @@ -479,7 +509,7 @@ public Instance(Instance instance)
_folder = "empty";
_showHiddenFiles = false;
_isLocked = false;

_id = Guid.NewGuid().ToString();
}
protected void OnPropertyChanged(string propertyName, string value)
{
Expand Down
9 changes: 9 additions & 0 deletions DeskFrame/Core/InstanceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void WriteOverInstanceToKey(Instance instance, string oldKey)
key.SetValue("FolderOrder", instance.FolderOrder);
key.SetValue("ShowOnVirtualDesktops", string.Join(",", instance.ShowOnVirtualDesktops));
key.SetValue("TitleFontSize", instance.TitleFontSize);
key.SetValue("IconSize", instance.IconSize);
}
Registry.CurrentUser.DeleteSubKey(@$"SOFTWARE\{appName}\Instances\{oldKey}", throwOnMissingSubKey: false);
}
Expand Down Expand Up @@ -103,6 +104,7 @@ public void WriteInstanceToKey(Instance instance)
key.SetValue("FolderOrder", instance.FolderOrder);
key.SetValue("ShowOnVirtualDesktops", string.Join(",", instance.ShowOnVirtualDesktops));
key.SetValue("TitleFontSize", instance.TitleFontSize);
key.SetValue("IconSize", instance.IconSize);
}
}
catch { }
Expand Down Expand Up @@ -364,6 +366,13 @@ public void InitInstances()
Debug.WriteLine($"TitleFontSize loaded: {temp.TitleFontSize}");
}
break;
case "IconSize":
if (int.TryParse(value.ToString(), out int parsedIconSize))
{
temp.IconSize = parsedIconSize;
Debug.WriteLine($"IconSize loaded: {temp.IconSize}");
}
break;
default:
Debug.WriteLine($"Unknown value: {valueName}");
break;
Expand Down
1 change: 1 addition & 0 deletions DeskFrame/DeskFrame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.0.1" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Svg" Version="3.4.7" />
Expand Down
18 changes: 14 additions & 4 deletions DeskFrame/DeskFrameWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
LocationChanged="Window_LocationChanged"
KeyDown="Window_KeyDown"
MouseLeave="Window_MouseLeave"
MouseEnter="Window_MouseEnter">
MouseEnter="Window_MouseEnter"
MouseWheel="Window_MouseWheel">

<Window.Resources>

Expand All @@ -38,15 +39,22 @@
<local:TitleTextAlignmentToMarginConverter x:Key="TitleTextAlignmentToMarginConverter" />
<local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<local:OffsetConverter x:Key="OffsetConverter"/>
<local:IconSizeToItemWidthConverter x:Key="IconSizeToItemWidthConverter"/>
<local:IconSizeToImageWidthConverter x:Key="IconSizeToImageWidthConverter"/>
<local:IconSizeToImageHeightConverter x:Key="IconSizeToImageHeightConverter"/>
<local:IconSizeToItemHeightConverter x:Key="IconSizeToItemHeightConverter"/>

<!-- DataTemplate to display each file item -->
<DataTemplate x:Key="FileItemTemplate">
<Border Background="{Binding Background}" Margin="4,0,0,5" CornerRadius="5"
MouseLeftButtonDown="FileItem_Click" MinHeight="50" MaxHeight="77"
MouseLeftButtonDown="FileItem_Click" MinHeight="50"
MouseEnter="FileItem_MouseEnter" MouseLeave="FileItem_MouseLeave"
BorderThickness="1" MouseRightButtonDown="FileItem_RightClick">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Image Margin="0,5,0,0" MaxHeight="30" Source="{Binding Thumbnail}" Stretch="Uniform" />
<Image Margin="0,5,0,0" Source="{Binding Thumbnail}"
Width="{Binding DataContext.Instance.IconSize, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource IconSizeToImageWidthConverter}}"
Height="{Binding DataContext.Instance.IconSize, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource IconSizeToImageHeightConverter}}"
Stretch="Uniform" />
<Grid Visibility="{Binding DataContext.Instance.ShowDisplayName, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource BooleanToVisibilityConverter}}">
<TextBlock FontSize="12" Text="{Binding DisplayName}" Padding="0,2,0,0" Margin="3"
TextWrapping="Wrap" TextAlignment="Center"
Expand Down Expand Up @@ -131,7 +139,9 @@
<ItemsControl Padding="0,5,0,0" x:Name="FileWrapPanel" IsTabStop="False" ItemsSource="{Binding FileItems}" ItemTemplate="{StaticResource FileItemTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemWidth="85" HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True"/>
<WrapPanel ItemWidth="{Binding DataContext.Instance.IconSize, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource IconSizeToItemWidthConverter}}"
ItemHeight="{Binding DataContext.Instance.IconSize, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource IconSizeToItemHeightConverter}}"
HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Expand Down
Loading