refactor: replace all window with custom ChromelessWindow

This commit is contained in:
leo 2024-06-13 11:54:10 +08:00
parent 68061f82b1
commit f5b35d3db2
No known key found for this signature in database
GPG key ID: B528468E49CD0E58
23 changed files with 414 additions and 649 deletions

View file

@ -18,6 +18,129 @@
<Setter Property="HideDelay" Value="0:0:0.2"/>
</Style>
<Style Selector="Window">
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/>
<Setter Property="ExtendClientAreaChromeHints" Value="NoChrome"/>
<Setter Property="ExtendClientAreaToDecorationsHint" Value="True"/>
<Setter Property="SystemDecorations" Value="Full"/>
<Setter Property="Padding" Value="0"/>
</Style>
<Style Selector="Window[WindowState=Maximized]">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="6"/>
</Style>
<Style Selector="Window.custom_window_frame">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="ExtendClientAreaChromeHints" Value="Default"/>
<Setter Property="ExtendClientAreaToDecorationsHint" Value="False"/>
<Setter Property="SystemDecorations" Value="None"/>
<Setter Property="Padding" Value="12"/>
<Setter Property="Template">
<ControlTemplate>
<Grid>
<Border x:Name="PART_ContentRoot"
Background="{DynamicResource Brush.Window}"
BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="1"
Margin="{TemplateBinding Padding}"
CornerRadius="8"
Effect="drop-shadow(0 0 12 #90000000)"
ClipToBounds="True">
<VisualLayerManager>
<ContentPresenter Name="PART_ContentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</VisualLayerManager>
</Border>
<Grid x:Name="PART_ResizeBorderContainer" Margin="{TemplateBinding Padding}" IsHitTestVisible="True">
<Border x:Name="PART_BorderTopLeft"
Width="4" Height="4"
Background="Transparent"
HorizontalAlignment="Left" VerticalAlignment="Top"
Cursor="TopLeftCorner"
Tag="{x:Static WindowEdge.NorthWest}"/>
<Border x:Name="PART_BorderTop"
Height="4" Margin="4,0"
Background="Transparent"
HorizontalAlignment="Stretch" VerticalAlignment="Top"
Cursor="TopSide"
Tag="{x:Static WindowEdge.North}"/>
<Border x:Name="PART_BorderTopRight"
Width="4" Height="4"
Background="Transparent"
HorizontalAlignment="Right" VerticalAlignment="Top"
Cursor="TopRightCorner"
Tag="{x:Static WindowEdge.NorthEast}"/>
<Border x:Name="PART_BorderLeft"
Width="4" Margin="0,4"
Background="Transparent"
HorizontalAlignment="Left" VerticalAlignment="Stretch"
Cursor="LeftSide"
Tag="{x:Static WindowEdge.West}"/>
<Border x:Name="PART_BorderRight"
Width="4" Margin="0,4"
Background="Transparent"
HorizontalAlignment="Right" VerticalAlignment="Stretch"
Cursor="RightSide"
Tag="{x:Static WindowEdge.East}"/>
<Border x:Name="PART_BorderBottomLeft"
Width="4" Height="4"
Background="Transparent"
HorizontalAlignment="Left" VerticalAlignment="Bottom"
Cursor="BottomLeftCorner"
Tag="{x:Static WindowEdge.SouthWest}"/>
<Border x:Name="PART_BorderBottom"
Height="4" Margin="4,0"
Background="Transparent"
HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
Cursor="BottomSide"
Tag="{x:Static WindowEdge.South}"/>
<Border x:Name="PART_BorderBottomRight"
Width="4" Height="4"
Background="Transparent"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Cursor="BottomRightCorner"
Tag="{x:Static WindowEdge.SouthEast}"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="Window.custom_window_frame[WindowState=Maximized]">
<Setter Property="Padding" Value="0"/>
</Style>
<Style Selector="Window.custom_window_frame[WindowState=Maximized] /template/ Border#PART_ContentRoot">
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style Selector="Window.custom_window_frame[WindowState=Maximized] /template/ Grid#PART_ResizeBorderContainer">
<Setter Property="IsVisible" Value="False"/>
<Setter Property="IsHitTestVisible" Value="False"/>
</Style>
<Style Selector="Window.custom_window_frame[CanResize=False] /template/ Grid#PART_ResizeBorderContainer">
<Setter Property="IsVisible" Value="False"/>
<Setter Property="IsHitTestVisible" Value="False"/>
</Style>
<Style Selector="ContentPresenter">
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFont}"/>
<Setter Property="FontSize" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize}"/>