style<IconButton>: add IconButton.IconSize to control size of icon

This commit is contained in:
leo 2022-11-04 12:48:41 +08:00
parent 785b2c1f82
commit 4cd07d90a5
12 changed files with 50 additions and 35 deletions

View file

@ -17,11 +17,14 @@
x:Name="Border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}">
Background="{TemplateBinding Background}">
<Path
Width="{TemplateBinding IconSize}"
Height="{TemplateBinding IconSize}"
Fill="{TemplateBinding Foreground}"
Data="{TemplateBinding Icon}"/>
Data="{TemplateBinding Icon}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>

View file

@ -37,7 +37,7 @@
Grid.Column="3"
Click="Quit"
Width="28"
Padding="10"
IconSize="10"
Icon="{StaticResource Icon.Close}"
HoverBackground="Red"
WindowChrome.IsHitTestVisibleInChrome="True"/>

View file

@ -36,9 +36,9 @@
<!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="Minimize" Width="48" Padding="13" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<controls:IconButton Click="Minimize" Width="48" IconSize="10" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="48" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
<controls:IconButton Click="Quit" Width="48" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
<controls:IconButton Click="Quit" Width="48" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
</StackPanel>
</Grid>

View file

@ -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}"/>

View file

@ -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),

View file

@ -36,9 +36,9 @@
<!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="Minimize" Width="48" Padding="13" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<controls:IconButton Click="Minimize" Width="48" IconSize="10" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="48" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
<controls:IconButton Click="Quit" Width="48" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
<controls:IconButton Click="Quit" Width="48" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
</StackPanel>
</Grid>

View file

@ -55,9 +55,9 @@
<!-- Right controls -->
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="Minimize" Width="48" Padding="13" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<controls:IconButton Click="Minimize" Width="48" IconSize="10" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="48" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
<controls:IconButton Click="Quit" Width="48" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
<controls:IconButton Click="Quit" Width="48" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
</StackPanel>
</Grid>

View file

@ -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}"/>

View file

@ -42,7 +42,7 @@
<controls:IconButton
Grid.Column="3"
Click="Quit"
Width="28" Padding="10"
Width="28" IconSize="10"
Icon="{StaticResource Icon.Close}"
HoverBackground="Red"
WindowChrome.IsHitTestVisibleInChrome="True"/>
@ -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}"/>
</Grid>
@ -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}"/>
</Grid>
@ -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}"/>
</Grid>
@ -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}"/>
</Grid>

View file

@ -35,7 +35,7 @@
<!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="Quit" Width="28" Padding="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
<controls:IconButton Click="Quit" Width="28" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
</StackPanel>
</Grid>

View file

@ -32,21 +32,21 @@
<StackPanel Grid.Column="0" Orientation="Horizontal">
<controls:IconButton
Margin="8,0"
Padding="0,9"
IconSize="14"
Icon="{DynamicResource Icon.Folder.Open}"
ToolTip="{DynamicResource Text.Dashboard.Explore}"
Click="OpenInExplorer"/>
<controls:IconButton
x:Name="btnVSCode"
Margin="8,0"
Padding="0,9"
IconSize="14"
Icon="{DynamicResource Icon.VSCode}"
ToolTip="{DynamicResource Text.Dashboard.VSCode}"
Visibility="Collapsed"
Click="OpenInVSCode"/>
<controls:IconButton
Margin="8,0"
Padding="0,9"
IconSize="14"
Icon="{DynamicResource Icon.Terminal}"
ToolTip="{DynamicResource Text.Dashboard.Terminal}"
Click="OpenInTerminal"/>
@ -55,31 +55,31 @@
<StackPanel Grid.Column="1" Orientation="Horizontal">
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Fetch}"
ToolTip="{DynamicResource Text.Fetch}"
Click="OpenFetch"/>
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Pull}"
ToolTip="{DynamicResource Text.Pull}"
Click="OpenPull"/>
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Push}"
ToolTip="{DynamicResource Text.Push}"
Click="OpenPush"/>
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Stashes}"
ToolTip="{DynamicResource Text.Stash}"
Click="OpenStash"/>
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Diff}"
ToolTip="{DynamicResource Text.Apply}"
Click="OpenApply"/>
@ -92,7 +92,7 @@
<controls:IconButton
Margin="16,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Search}"
ToolTip="{DynamicResource Text.Dashboard.Search}"
Click="OpenSearch"/>
@ -110,21 +110,21 @@
<controls:IconButton
Margin="8,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Statistics}"
ToolTip="{DynamicResource Text.Dashboard.Statistics}"
Click="OpenStatistics"/>
<controls:IconButton
Margin="8,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Clean}"
ToolTip="{DynamicResource Text.Dashboard.Clean}"
Click="OpenCleanup"/>
<controls:IconButton
Margin="8,0"
Padding="0,8"
IconSize="14"
Icon="{DynamicResource Icon.Setting}"
ToolTip="{DynamicResource Text.Dashboard.Configure}"
Click="OpenConfigure"/>

View file

@ -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}"