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" x:Name="Border"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}">
Padding="{TemplateBinding Padding}">
<Path <Path
Width="{TemplateBinding IconSize}"
Height="{TemplateBinding IconSize}"
Fill="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}"
Data="{TemplateBinding Icon}"/> Data="{TemplateBinding Icon}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>

View file

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

View file

@ -36,9 +36,9 @@
<!-- Window Commands --> <!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True"> <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}"/> <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> </StackPanel>
</Grid> </Grid>

View file

@ -39,7 +39,7 @@
Grid.Column="3" Grid.Column="3"
Click="OnQuit" Click="OnQuit"
Width="28" Width="28"
Padding="10" IconSize="10"
Icon="{StaticResource Icon.Close}" Icon="{StaticResource Icon.Close}"
HoverBackground="Red" HoverBackground="Red"
WindowChrome.IsHitTestVisibleInChrome="True"/> WindowChrome.IsHitTestVisibleInChrome="True"/>
@ -110,7 +110,7 @@
Grid.Column="1" Grid.Column="1"
Click="OnSelectSSHKey" Click="OnSelectSSHKey"
Width="24" Height="24" Width="24" Height="24"
Margin="2,0,0,0" Padding="4" Margin="2,0,0,0" IconSize="16"
BorderBrush="{DynamicResource Brush.Border1}" BorderBrush="{DynamicResource Brush.Border1}"
BorderThickness="1" BorderThickness="1"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>
@ -145,7 +145,7 @@
Grid.Column="1" Grid.Column="1"
Click="OnFolderSelectorClick" Click="OnFolderSelectorClick"
Width="24" Height="24" Width="24" Height="24"
Margin="2,0,0,0" Padding="4" Margin="2,0,0,0" IconSize="16"
BorderBrush="{DynamicResource Brush.Border1}" BorderBrush="{DynamicResource Brush.Border1}"
BorderThickness="1" BorderThickness="1"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>

View file

@ -1,3 +1,4 @@
using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@ -20,6 +21,17 @@ namespace SourceGit.Views.Controls {
set { SetValue(IconProperty, value); } 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( public static readonly DependencyProperty HoverBackgroundProperty = DependencyProperty.Register(
"HoverBackground", "HoverBackground",
typeof(Brush), typeof(Brush),

View file

@ -36,9 +36,9 @@
<!-- Window Commands --> <!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True"> <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}"/> <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> </StackPanel>
</Grid> </Grid>

View file

@ -55,9 +55,9 @@
<!-- Right controls --> <!-- Right controls -->
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True"> <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}"/> <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> </StackPanel>
</Grid> </Grid>

View file

@ -81,7 +81,7 @@
Grid.Column="1" Grid.Column="1"
Click="OnSelectSSHKey" Click="OnSelectSSHKey"
Width="24" Height="24" Width="24" Height="24"
Margin="2,0,0,0" Padding="4" Margin="2,0,0,0" IconSize="16"
BorderBrush="{DynamicResource Brush.Border1}" BorderBrush="{DynamicResource Brush.Border1}"
BorderThickness="1" BorderThickness="1"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>

View file

@ -42,7 +42,7 @@
<controls:IconButton <controls:IconButton
Grid.Column="3" Grid.Column="3"
Click="Quit" Click="Quit"
Width="28" Padding="10" Width="28" IconSize="10"
Icon="{StaticResource Icon.Close}" Icon="{StaticResource Icon.Close}"
HoverBackground="Red" HoverBackground="Red"
WindowChrome.IsHitTestVisibleInChrome="True"/> WindowChrome.IsHitTestVisibleInChrome="True"/>
@ -186,7 +186,7 @@
Grid.Column="1" Grid.Column="1"
Click="SelectGitPath" Click="SelectGitPath"
Width="24" Height="24" Width="24" Height="24"
Margin="4,0,0,0" Padding="4" Margin="4,0,0,0" IconSize="16"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>
</Grid> </Grid>
@ -224,7 +224,7 @@
Grid.Column="1" Grid.Column="1"
Click="SelectGitCloneDir" Click="SelectGitCloneDir"
Width="24" Height="24" Width="24" Height="24"
Margin="4,0,0,0" Padding="4" Margin="4,0,0,0" IconSize="16"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>
</Grid> </Grid>
@ -331,7 +331,7 @@
Grid.Column="1" Grid.Column="1"
Click="SelectGPGExec" Click="SelectGPGExec"
Width="24" Height="24" Width="24" Height="24"
Margin="4,0,0,0" Padding="4" Margin="4,0,0,0" IconSize="16"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>
</Grid> </Grid>
@ -399,7 +399,7 @@
Grid.Column="1" Grid.Column="1"
Click="SelectMergeTool" Click="SelectMergeTool"
Width="24" Height="24" Width="24" Height="24"
Margin="4,0,0,0" Padding="4" Margin="4,0,0,0" IconSize="16"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
Icon="{StaticResource Icon.Folder.Open}"/> Icon="{StaticResource Icon.Folder.Open}"/>
</Grid> </Grid>

View file

@ -35,7 +35,7 @@
<!-- Window Commands --> <!-- Window Commands -->
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True"> <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> </StackPanel>
</Grid> </Grid>

View file

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

View file

@ -29,7 +29,7 @@
Grid.Column="1" Grid.Column="1"
x:Name="leftScroller" x:Name="leftScroller"
Click="ScrollLeft" Click="ScrollLeft"
Width="18" Padding="6" Width="18"
HoverBackground="{DynamicResource Brush.TabButtonHover}" HoverBackground="{DynamicResource Brush.TabButtonHover}"
BorderThickness="0" BorderThickness="0"
Icon="{StaticResource Icon.ScrollLeft}" Icon="{StaticResource Icon.ScrollLeft}"
@ -92,7 +92,7 @@
Click="CloseTab" Click="CloseTab"
x:Name="closer" x:Name="closer"
Width="16" Height="16" Width="16" Height="16"
Margin="0,1,8,0" Padding="4" Margin="0,1,8,0" IconSize="8"
ToolTip="{DynamicResource Text.Close}" ToolTip="{DynamicResource Text.Close}"
Icon="{StaticResource Icon.Close}" Icon="{StaticResource Icon.Close}"
HoverBackground="{DynamicResource Brush.TabButtonHover}" HoverBackground="{DynamicResource Brush.TabButtonHover}"
@ -151,7 +151,7 @@
Grid.Column="3" Grid.Column="3"
x:Name="rightScroller" x:Name="rightScroller"
Click="ScrollRight" Click="ScrollRight"
Width="18" Padding="6" Width="18"
HoverBackground="{DynamicResource Brush.TabButtonHover}" HoverBackground="{DynamicResource Brush.TabButtonHover}"
BorderThickness="0" BorderThickness="0"
Icon="{StaticResource Icon.ScrollRight}" Icon="{StaticResource Icon.ScrollRight}"