Use global style for all windows

Including foreground and background color, clear type rendering and using layout rounding
This commit is contained in:
Peter Kirmeier 2023-09-01 17:34:42 +02:00
parent 0c8eec10b1
commit ae6b12600c
8 changed files with 27 additions and 23 deletions

View file

@ -24,6 +24,9 @@
<Style TargetType="{x:Type Window}">
<Setter Property="Foreground" Value="{x:Static stm:MenuDefines.ColorForeground}" />
<Setter Property="Background" Value="{x:Static stm:MenuDefines.ColorBackground}" />
<Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
<Setter Property="TextOptions.TextFormattingMode" Value="Display" />
<Setter Property="UseLayoutRounding" Value="True" />
</Style>
<Style TargetType="{x:Type TabItem}">
<!-- not working for selected TabIdem yet, so we keep default colors -->

View file

@ -7,7 +7,8 @@
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
xmlns:stm="clr-namespace:SystemTrayMenu"
x:Class="SystemTrayMenu.UserInterface.AboutBox"
mc:Ignorable="d" Title="{u:Translate 'About SystemTrayMenu'}" Background="{x:Static stm:MenuDefines.ColorBackground}" Height="513" Width="418" ResizeMode="NoResize" SizeToContent="Height">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" d:Background="{x:Static stm:MenuDefines.ColorBackground}"
Title="{u:Translate 'About SystemTrayMenu'}" Height="513" Width="418" ResizeMode="NoResize" SizeToContent="Height">
<DockPanel>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" DockPanel.Dock="Top">
<Image Width="32" Height="32" Margin="3" Source="{StaticResource ApplicationImage}" />

View file

@ -9,8 +9,8 @@
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
xmlns:stm="clr-namespace:SystemTrayMenu"
x:Class="SystemTrayMenu.UserInterface.ColorPickerWindow"
mc:Ignorable="d" Title="{u:Translate 'Choose color'}"
Background="{x:Static stm:MenuDefines.ColorBackground}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" ResizeMode="CanResizeWithGrip">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" d:Background="{x:Static stm:MenuDefines.ColorBackground}"
Title="{u:Translate 'Choose color'}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" ResizeMode="CanResizeWithGrip">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View file

@ -7,13 +7,14 @@
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
xmlns:stm="clr-namespace:SystemTrayMenu"
x:Class="SystemTrayMenu.UserInterface.HowToOpenSettingsWindow"
mc:Ignorable="d" Title="{u:Translate 'Hint'}" Background="{x:Static stm:MenuDefines.ColorBackground}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" WindowStyle="SingleBorderWindow" ShowInTaskbar="True" ResizeMode="NoResize">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" d:Foreground="{x:Static stm:MenuDefines.ColorForeground}" d:Background="{x:Static stm:MenuDefines.ColorBackground}"
Title="{u:Translate 'Hint'}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" WindowStyle="SingleBorderWindow" ShowInTaskbar="True" ResizeMode="NoResize">
<Window.Resources>
<BitmapImage x:Key="HowToOpenSettingsImage" UriSource="../Resources/HowToOpenSettings.png" />
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{x:Static stm:MenuDefines.ColorForeground}" />
<Setter Property="Background" Value="{x:Static stm:MenuDefines.ColorBackground}" />
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=Foreground}" />
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=Background}" />
</Style>
</Window.Resources>

View file

@ -10,8 +10,9 @@
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
xmlns:local="clr-namespace:SystemTrayMenu.UserInterface"
x:Class="SystemTrayMenu.UserInterface.Menu"
mc:Ignorable="d" ResizeMode="NoResize" WindowStyle="None" Topmost="True" Background="Transparent" AllowsTransparency="True" SizeToContent="WidthAndHeight" ShowInTaskbar="False" SnapsToDevicePixels="True" UseLayoutRounding="True"
PreviewKeyDown="HandlePreviewKeyDown" d:MaxHeight="200">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" Background="Transparent" d:MaxHeight="200"
ResizeMode="NoResize" WindowStyle="None" Topmost="True" AllowsTransparency="True" SizeToContent="WidthAndHeight" ShowInTaskbar="False" SnapsToDevicePixels="True"
PreviewKeyDown="HandlePreviewKeyDown">
<Window.Effect>
<!-- Remember to adjust the windowFrame accordingly to the size of the shadow -->
<DropShadowEffect Direction="315" ShadowDepth="2" BlurRadius="4" Color="{Binding Source={x:Static stm:MenuDefines.ColorBackgroundBorder},Path=Color}"/>
@ -105,18 +106,14 @@
BorderBrush="{x:Static stm:MenuDefines.ColorBackgroundBorder}">
<DockPanel x:Name="tableLayoutPanelMenu">
<Label x:Name="labelTitle" DockPanel.Dock="Top" Padding="0" Margin="20,0" MinHeight="12"
HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="{x:Static stm:MenuDefines.ColorForeground}" FontWeight="Bold">
<TextBlock x:Name="txtTitle" TextTrimming="CharacterEllipsis"><Run Text="title"
TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display"/>
</TextBlock>
HorizontalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold">
<TextBlock x:Name="txtTitle" TextTrimming="CharacterEllipsis"><Run Text="title"/></TextBlock>
</Label>
<DockPanel x:Name="searchPanel" DockPanel.Dock="Top" Margin="6,0" Background="{x:Static stm:MenuDefines.ColorSearchField}">
<Separator x:Name="panelLine" Height="1" Margin="0" DockPanel.Dock="Bottom" Background="{x:Static stm:MenuDefines.ColorIcons}"/>
<Image x:Name="pictureBoxSearch" Width="22" Height="22" Margin="0" DockPanel.Dock="Left" Source="{StaticResource ic_fluent_search_48_regularDrawingImage}"/>
<TextBox x:Name="textBoxSearch" Margin="0" BorderThickness="0" VerticalContentAlignment="Center"
Background="{x:Null}" Foreground="{x:Static stm:MenuDefines.ColorForeground}" CaretBrush="{x:Static stm:MenuDefines.ColorForeground}"
TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display"/>
Background="{x:Null}" Foreground="{x:Static stm:MenuDefines.ColorForeground}" CaretBrush="{x:Static stm:MenuDefines.ColorForeground}" />
</DockPanel>
<DockPanel x:Name="tableLayoutPanelBottom" DockPanel.Dock="Bottom" Margin="12,6,14,5">
@ -143,8 +140,8 @@
</Setter>
</Style>
</DockPanel.Resources>
<Label x:Name="labelStatus" Content="{u:Translate 'loading'}" Padding="0" DockPanel.Dock="Left" FontWeight="Bold" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="{x:Static stm:MenuDefines.ColorIcons}"
TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display"/>
<Label x:Name="labelStatus" Content="{u:Translate 'loading'}" Padding="0" DockPanel.Dock="Left" FontWeight="Bold" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="{x:Static stm:MenuDefines.ColorIcons}"/>
<Image x:Name="pictureBoxLoading" Width="18" Height="18" DockPanel.Dock="Right" Source="{StaticResource LoadingIconImage}"
HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
@ -178,7 +175,7 @@
</DockPanel>
<ListView x:Name="dgv" x:FieldModifier="internal" Margin="8,1,6,1" Padding="0" d:ItemsSource="{d:SampleData ItemCount=50}" SelectionMode="Single" HorizontalContentAlignment="Stretch"
Foreground="{x:Static stm:MenuDefines.ColorForeground}" Background="{x:Null}" BorderThickness="0" VirtualizingStackPanel.IsVirtualizing="False"
Background="{x:Null}" BorderThickness="0" VirtualizingStackPanel.IsVirtualizing="False"
SelectionChanged="ListView_SelectionChanged" MouseLeave="ListView_MouseLeave"
ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.ScrollChanged="HandleScrollChanged">
<!--ListView."Childs".Border.Padding="0" // In ctor, see: dgv_border -->
@ -193,8 +190,7 @@
<StackPanel Orientation="Horizontal">
<Image Width="{DynamicResource ColumnIconWidth}" Margin="0" Source="{Binding ColumnIcon}" />
<TextBlock MaxWidth="{DynamicResource ColumnTextMaxWidth}" Margin="5,0,2,0" Padding="0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Text="{Binding ColumnText}" Foreground="{x:Static stm:MenuDefines.ColorForeground}"
TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display"/>
Text="{Binding ColumnText}" Foreground="{x:Static stm:MenuDefines.ColorForeground}" />
<!-- TODO: Optional or only for trimmed entries: ToolTip="{Binding ColumnText}" -->
</StackPanel>
</Border>

View file

@ -8,7 +8,8 @@
xmlns:stm="clr-namespace:SystemTrayMenu"
xmlns:local="clr-namespace:SystemTrayMenu.UserInterface"
x:Class="SystemTrayMenu.UserInterface.SettingsWindow"
mc:Ignorable="d" Title="{u:Translate 'Settings'}" Background="{x:Static stm:MenuDefines.ColorBackground}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" MinWidth="200" MinHeight="250">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" d:Background="{x:Static stm:MenuDefines.ColorBackground}"
Title="{u:Translate 'Settings'}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" MinWidth="200" MinHeight="250">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />

View file

@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="SystemTrayMenu.UserInterface.TaskbarLogo"
mc:Ignorable="d" WindowStyle="None" ResizeMode="NoResize" Width="38" Height="38" Topmost="True" Background="Transparent" AllowsTransparency="True">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" Background="Transparent"
WindowStyle="None" ResizeMode="NoResize" Width="38" Height="38" Topmost="True" AllowsTransparency="True">
<Image Width="32" Height="32" Margin="3" Source="{StaticResource ApplicationImage}"/>
</Window>

View file

@ -7,7 +7,8 @@
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
xmlns:stm="clr-namespace:SystemTrayMenu"
x:Class="SystemTrayMenu.UserInterface.UpdateWindow"
mc:Ignorable="d" Title="{u:Translate 'New version available!'}" Background="{x:Static stm:MenuDefines.ColorBackground}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" MinWidth="600" MaxHeight="600" WindowStyle="ToolWindow" ShowInTaskbar="False">
Style="{StaticResource {x:Type Window}}" mc:Ignorable="d" d:Background="{x:Static stm:MenuDefines.ColorBackground}"
Title="{u:Translate 'New version available!'}" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" MinWidth="600" MaxHeight="600" WindowStyle="ToolWindow" ShowInTaskbar="False">
<DockPanel>
<Label DockPanel.Dock="Top" x:Name="label" Content="{u:Translate 'Latest available version:'}" />