From 4cd07d90a5b2b163c271a66c4eb305fcb693ca0f Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 4 Nov 2022 12:48:41 +0800 Subject: [PATCH] style: add IconButton.IconSize to control size of icon --- src/Resources/Styles/IconButton.xaml | 9 ++++++--- src/Views/About.xaml | 2 +- src/Views/Blame.xaml | 4 ++-- src/Views/Clone.xaml | 6 +++--- src/Views/Controls/IconButton.cs | 12 ++++++++++++ src/Views/FileHistories.xaml | 4 ++-- src/Views/Launcher.xaml | 4 ++-- src/Views/Popups/Remote.xaml | 2 +- src/Views/Preference.xaml | 10 +++++----- src/Views/Statistics.xaml | 2 +- src/Views/Widgets/Dashboard.xaml | 24 ++++++++++++------------ src/Views/Widgets/PageTabBar.xaml | 6 +++--- 12 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/Resources/Styles/IconButton.xaml b/src/Resources/Styles/IconButton.xaml index 31f4e801..f530df8f 100644 --- a/src/Resources/Styles/IconButton.xaml +++ b/src/Resources/Styles/IconButton.xaml @@ -17,11 +17,14 @@ x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" - Background="{TemplateBinding Background}" - Padding="{TemplateBinding Padding}"> + Background="{TemplateBinding Background}"> + Data="{TemplateBinding Icon}" + HorizontalAlignment="Center" + VerticalAlignment="Center"/> diff --git a/src/Views/About.xaml b/src/Views/About.xaml index 49fb3064..927f2213 100644 --- a/src/Views/About.xaml +++ b/src/Views/About.xaml @@ -37,7 +37,7 @@ Grid.Column="3" Click="Quit" Width="28" - Padding="10" + IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" WindowChrome.IsHitTestVisibleInChrome="True"/> diff --git a/src/Views/Blame.xaml b/src/Views/Blame.xaml index 2798a6c1..c5a5cdec 100644 --- a/src/Views/Blame.xaml +++ b/src/Views/Blame.xaml @@ -36,9 +36,9 @@ - + - + diff --git a/src/Views/Clone.xaml b/src/Views/Clone.xaml index f3f58faa..b257885a 100644 --- a/src/Views/Clone.xaml +++ b/src/Views/Clone.xaml @@ -39,7 +39,7 @@ Grid.Column="3" Click="OnQuit" Width="28" - Padding="10" + IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" WindowChrome.IsHitTestVisibleInChrome="True"/> @@ -110,7 +110,7 @@ Grid.Column="1" Click="OnSelectSSHKey" Width="24" Height="24" - Margin="2,0,0,0" Padding="4" + Margin="2,0,0,0" IconSize="16" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" Icon="{StaticResource Icon.Folder.Open}"/> @@ -145,7 +145,7 @@ Grid.Column="1" Click="OnFolderSelectorClick" Width="24" Height="24" - Margin="2,0,0,0" Padding="4" + Margin="2,0,0,0" IconSize="16" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" Icon="{StaticResource Icon.Folder.Open}"/> diff --git a/src/Views/Controls/IconButton.cs b/src/Views/Controls/IconButton.cs index 2b506bc2..af9efc61 100644 --- a/src/Views/Controls/IconButton.cs +++ b/src/Views/Controls/IconButton.cs @@ -1,3 +1,4 @@ +using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -20,6 +21,17 @@ namespace SourceGit.Views.Controls { set { SetValue(IconProperty, value); } } + public static readonly DependencyProperty IconSizeProperty = DependencyProperty.Register( + "IconSize", + typeof(double), + typeof(IconButton), + new PropertyMetadata(14.0)); + + public double IconSize { + get { return (double)GetValue(IconSizeProperty); } + set { SetValue(IconSizeProperty, value); } + } + public static readonly DependencyProperty HoverBackgroundProperty = DependencyProperty.Register( "HoverBackground", typeof(Brush), diff --git a/src/Views/FileHistories.xaml b/src/Views/FileHistories.xaml index 7880be56..ad2a461a 100644 --- a/src/Views/FileHistories.xaml +++ b/src/Views/FileHistories.xaml @@ -36,9 +36,9 @@ - + - + diff --git a/src/Views/Launcher.xaml b/src/Views/Launcher.xaml index 94492176..e9d10855 100644 --- a/src/Views/Launcher.xaml +++ b/src/Views/Launcher.xaml @@ -55,9 +55,9 @@ - + - + diff --git a/src/Views/Popups/Remote.xaml b/src/Views/Popups/Remote.xaml index 4c2aaa2a..62a80f74 100644 --- a/src/Views/Popups/Remote.xaml +++ b/src/Views/Popups/Remote.xaml @@ -81,7 +81,7 @@ Grid.Column="1" Click="OnSelectSSHKey" Width="24" Height="24" - Margin="2,0,0,0" Padding="4" + Margin="2,0,0,0" IconSize="16" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" Icon="{StaticResource Icon.Folder.Open}"/> diff --git a/src/Views/Preference.xaml b/src/Views/Preference.xaml index e0225983..ec9b371a 100644 --- a/src/Views/Preference.xaml +++ b/src/Views/Preference.xaml @@ -42,7 +42,7 @@ @@ -186,7 +186,7 @@ Grid.Column="1" Click="SelectGitPath" Width="24" Height="24" - Margin="4,0,0,0" Padding="4" + Margin="4,0,0,0" IconSize="16" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Icon="{StaticResource Icon.Folder.Open}"/> @@ -224,7 +224,7 @@ Grid.Column="1" Click="SelectGitCloneDir" Width="24" Height="24" - Margin="4,0,0,0" Padding="4" + Margin="4,0,0,0" IconSize="16" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Icon="{StaticResource Icon.Folder.Open}"/> @@ -331,7 +331,7 @@ Grid.Column="1" Click="SelectGPGExec" Width="24" Height="24" - Margin="4,0,0,0" Padding="4" + Margin="4,0,0,0" IconSize="16" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Icon="{StaticResource Icon.Folder.Open}"/> @@ -399,7 +399,7 @@ Grid.Column="1" Click="SelectMergeTool" Width="24" Height="24" - Margin="4,0,0,0" Padding="4" + Margin="4,0,0,0" IconSize="16" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" Icon="{StaticResource Icon.Folder.Open}"/> diff --git a/src/Views/Statistics.xaml b/src/Views/Statistics.xaml index 401cd4c9..da3ba1c4 100644 --- a/src/Views/Statistics.xaml +++ b/src/Views/Statistics.xaml @@ -35,7 +35,7 @@ - + diff --git a/src/Views/Widgets/Dashboard.xaml b/src/Views/Widgets/Dashboard.xaml index 530bf665..72d1192c 100644 --- a/src/Views/Widgets/Dashboard.xaml +++ b/src/Views/Widgets/Dashboard.xaml @@ -32,21 +32,21 @@ @@ -55,31 +55,31 @@ @@ -92,7 +92,7 @@ @@ -110,21 +110,21 @@ diff --git a/src/Views/Widgets/PageTabBar.xaml b/src/Views/Widgets/PageTabBar.xaml index ae503bf4..958689e3 100644 --- a/src/Views/Widgets/PageTabBar.xaml +++ b/src/Views/Widgets/PageTabBar.xaml @@ -29,7 +29,7 @@ Grid.Column="1" x:Name="leftScroller" Click="ScrollLeft" - Width="18" Padding="6" + Width="18" HoverBackground="{DynamicResource Brush.TabButtonHover}" BorderThickness="0" Icon="{StaticResource Icon.ScrollLeft}" @@ -92,7 +92,7 @@ Click="CloseTab" x:Name="closer" Width="16" Height="16" - Margin="0,1,8,0" Padding="4" + Margin="0,1,8,0" IconSize="8" ToolTip="{DynamicResource Text.Close}" Icon="{StaticResource Icon.Close}" HoverBackground="{DynamicResource Brush.TabButtonHover}" @@ -151,7 +151,7 @@ Grid.Column="3" x:Name="rightScroller" Click="ScrollRight" - Width="18" Padding="6" + Width="18" HoverBackground="{DynamicResource Brush.TabButtonHover}" BorderThickness="0" Icon="{StaticResource Icon.ScrollRight}"