Skip to content

Commit

Permalink
Import full customed title bar
Browse files Browse the repository at this point in the history
1.Import full customed title bar
2.Remove Windows App SDK dependency
  • Loading branch information
Gaoyifei1011 committed Dec 4, 2024
1 parent 04abc72 commit 6c747c6
Show file tree
Hide file tree
Showing 53 changed files with 3,883 additions and 285 deletions.
1 change: 1 addition & 0 deletions WindowsTools/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Application.Resources>
<controls:XamlControlsResources>
<controls:XamlControlsResources.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Styles/Button.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/AppBarButton.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/DateTimePicker.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/HyperlinkButton.xaml" />
Expand Down
6 changes: 3 additions & 3 deletions WindowsTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[assembly: AssemblyCompany("高怡飞")]
[assembly: AssemblyCopyright("Copyright ©2024 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("Windows 工具箱")]
[assembly: AssemblyFileVersion("3.2.1128.0")]
[assembly: AssemblyInformationalVersion("3.2.1128.0")]
[assembly: AssemblyFileVersion("3.2.1204.0")]
[assembly: AssemblyInformationalVersion("3.2.1204.0")]
[assembly: AssemblyProduct("Windows 工具箱")]
[assembly: AssemblyTitle("Windows 工具箱")]
[assembly: AssemblyVersion("3.2.1128.0")]
[assembly: AssemblyVersion("3.2.1204.0")]

// 应用程序默认区域性的资源控制器设置
[assembly: NeutralResourcesLanguage("en-us")]
198 changes: 198 additions & 0 deletions WindowsTools/Styles/Button.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<!-- 标题栏按钮资源值定义 -->
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<Color x:Key="CloseButtonColor">#C42B1C</Color>
<StaticResource x:Key="CaptionButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="CaptionButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonForegroundColor" ResourceKey="SystemBaseHighColor" />
<StaticResource x:Key="CaptionButtonForegroundPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonForegroundPressed" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="CaptionButtonBackground" Color="Transparent" />
<Color x:Key="CaptionButtonBackgroundColor">Transparent</Color>
<Color x:Key="CaptionButtonNotActiveColor">Black</Color>
<Color x:Key="CaptionButtonDisabledColor">Black</Color>
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver" Color="{ThemeResource CloseButtonColor}" />
<SolidColorBrush x:Key="CloseButtonForegroundPointerOver" Color="White" />
<SolidColorBrush
x:Key="CaptionButtonForegroundNotActive"
Opacity="0.38"
Color="{StaticResource CaptionButtonNotActiveColor}" />
<SolidColorBrush
x:Key="CaptionButtonForegroundDisabled"
Opacity="0.38"
Color="{StaticResource CaptionButtonDisabledColor}" />
<SolidColorBrush
x:Key="CloseButtonBackgroundPressed"
Opacity="0.9"
Color="{ThemeResource CloseButtonColor}" />
<SolidColorBrush
x:Key="CloseButtonForegroundPressed"
Opacity="0.7"
Color="White" />
<SolidColorBrush x:Key="CloseButtonBackground" Color="#00C42B1C" />
<Color x:Key="CloseButtonBackgroundColor">#00C42B1C</Color>
<StaticResource x:Key="RestoreButtonGlyph" ResourceKey="RestoreGlyph" />
</ResourceDictionary>

<ResourceDictionary x:Key="Dark">
<Color x:Key="CloseButtonColor">#C42B1C</Color>
<StaticResource x:Key="CaptionButtonBackgroundPointerOver" ResourceKey="SubtleFillColorSecondary" />
<StaticResource x:Key="CaptionButtonBackgroundPressed" ResourceKey="SubtleFillColorTertiary" />
<StaticResource x:Key="CaptionButtonForeground" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonForegroundColor" ResourceKey="SystemBaseHighColor" />
<StaticResource x:Key="CaptionButtonForegroundPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CaptionButtonForegroundPressed" ResourceKey="SystemControlForegroundBaseHighBrush" />
<SolidColorBrush x:Key="CaptionButtonBackground" Color="Transparent" />
<Color x:Key="CaptionButtonBackgroundColor">Transparent</Color>
<Color x:Key="CaptionButtonNotActiveColor">White</Color>
<Color x:Key="CaptionButtonDisabledColor">White</Color>
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver" Color="{ThemeResource CloseButtonColor}" />
<SolidColorBrush x:Key="CloseButtonForegroundPointerOver" Color="White" />
<SolidColorBrush
x:Key="CaptionButtonForegroundNotActive"
Opacity="0.35"
Color="{StaticResource CaptionButtonNotActiveColor}" />
<SolidColorBrush
x:Key="CaptionButtonForegroundDisabled"
Opacity="0.35"
Color="{StaticResource CaptionButtonDisabledColor}" />
<SolidColorBrush
x:Key="CloseButtonBackgroundPressed"
Opacity="0.9"
Color="{ThemeResource CloseButtonColor}" />
<SolidColorBrush
x:Key="CloseButtonForegroundPressed"
Opacity="0.7"
Color="White" />
<SolidColorBrush x:Key="CloseButtonBackground" Color="#00C42B1C" />
<Color x:Key="CloseButtonBackgroundColor">#00C42B1C</Color>
<StaticResource x:Key="RestoreButtonGlyph" ResourceKey="RestoreGlyph" />
</ResourceDictionary>

<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="CaptionButtonBackground" Color="{ThemeResource SystemColorButtonFaceColor}" />
<StaticResource x:Key="CaptionButtonBackgroundColor" ResourceKey="SystemColorButtonFaceColor" />
<SolidColorBrush x:Key="CaptionButtonBackgroundPointerOver" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CaptionButtonBackgroundPressed" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CaptionButtonForeground" Color="{ThemeResource SystemColorButtonTextColor}" />
<StaticResource x:Key="CaptionButtonForegroundColor" ResourceKey="SystemColorButtonTextColor" />
<SolidColorBrush x:Key="CaptionButtonForegroundPointerOver" Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CaptionButtonForegroundPressed" Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CloseButtonForegroundPointerOver" Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="CloseButtonForegroundPressed" Color="{ThemeResource SystemColorHighlightTextColor}" />
<StaticResource x:Key="RestoreButtonGlyph" ResourceKey="RestoreGlyphContrast" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<x:String x:Key="CaptionButtonGlyph">&#xE8BB;</x:String>
<x:String x:Key="MinimizeGlyph">&#xE921;</x:String>
<x:String x:Key="MaximizeGlyph">&#xE922;</x:String>
<x:String x:Key="RestoreGlyph">&#xE923;</x:String>
<x:String x:Key="CloseGlyph">&#xE8BB;</x:String>
<x:String x:Key="MinimizeGlyphContrast">&#xEF2D;</x:String>
<x:String x:Key="MaximizeGlyphContrast">&#xEF2E;</x:String>
<x:String x:Key="RestoreGlyphContrast">&#xEF2F;</x:String>
<x:String x:Key="CloseGlyphContrast">&#xEF2C;</x:String>
<x:Double x:Key="CaptionButtonHeightWindowed">30.0</x:Double>
<x:Double x:Key="CaptionButtonHeightMaximized">32.0</x:Double>

<Style x:Key="CaptionButton" TargetType="Button">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="ButtonBaseElement"
Padding="{TemplateBinding Padding}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Viewbox Width="10" Height="10">
<FontIcon
x:Name="ButtonIcon"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Foreground="{ThemeResource CaptionButtonForeground}"
Glyph="{ThemeResource CaptionButtonGlyph}" />
</Viewbox>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="PointerOver" To="Normal">
<Storyboard>
<ColorAnimation
Storyboard.TargetName="ButtonBaseElement"
Storyboard.TargetProperty="(UIElement.Background).(SolidColorBrush.Color)"
To="{ThemeResource CaptionButtonBackgroundColor}"
Duration="0:0:0.15" />
<ColorAnimation
Storyboard.TargetName="ButtonIcon"
Storyboard.TargetProperty="(UIElement.Foreground).(SolidColorBrush.Color)"
To="{ThemeResource CaptionButtonForegroundColor}"
Duration="0:0:0.1" />
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>

<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Target="ButtonIcon.Foreground" Value="{ThemeResource CaptionButtonForeground}" />
</VisualState.Setters>
</VisualState>

<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackgroundPointerOver}" />
<Setter Target="ButtonIcon.Foreground" Value="{ThemeResource CaptionButtonForegroundPointerOver}" />
</VisualState.Setters>
</VisualState>

<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackgroundPressed}" />
<Setter Target="ButtonIcon.Foreground" Value="{ThemeResource CaptionButtonForegroundPressed}" />
</VisualState.Setters>
</VisualState>

<VisualState x:Name="NotActive">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Target="ButtonIcon.Foreground" Value="{ThemeResource CaptionButtonForegroundNotActive}" />
</VisualState.Setters>
</VisualState>

<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="ButtonBaseElement.Background" Value="{ThemeResource CaptionButtonBackground}" />
<Setter Target="ButtonIcon.Foreground" Value="{ThemeResource CaptionButtonForegroundDisabled}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>

<VisualStateGroup x:Name="MinMaxStates">
<VisualState x:Name="WindowStateNormal" />

<VisualState x:Name="WindowStateMaximized">
<VisualState.Setters>
<Setter Target="ButtonIcon.Glyph" Value="{ThemeResource RestoreButtonGlyph}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Loading

0 comments on commit 6c747c6

Please sign in to comment.