Updated main menu controls' layout to be almost pixel perfect with v1

This commit is contained in:
Peter Kirmeier 2023-08-16 22:45:43 +02:00
parent 748d992727
commit 0143a0a690
2 changed files with 16 additions and 16 deletions

View file

@ -101,22 +101,23 @@
Background="{x:Static stm:MenuDefines.ColorBackground}"
BorderBrush="{x:Static stm:MenuDefines.ColorBackgroundBorder}">
<DockPanel x:Name="tableLayoutPanelMenu">
<Label x:Name="labelTitle" DockPanel.Dock="Top" HorizontalContentAlignment="Center" Padding="1" Margin="6,0" FontWeight="Bold"
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{x:Static stm:MenuDefines.ColorForeground}">
<TextBlock x:Name="txtTitle" TextTrimming="CharacterEllipsis" Margin="14,0"><Run Text="title"/></TextBlock>
<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"/></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="1" BorderThickness="0" Background="{x:Null}" Foreground="{x:Static stm:MenuDefines.ColorForeground}" CaretBrush="{x:Static stm:MenuDefines.ColorForeground}" SelectionTextBrush="Red" SelectionBrush="#FFDAFF00" VerticalContentAlignment="Center"/>
<TextBox x:Name="textBoxSearch" Margin="0" BorderThickness="0" VerticalContentAlignment="Center"
Foreground="{x:Static stm:MenuDefines.ColorForeground}" CaretBrush="{x:Static stm:MenuDefines.ColorForeground}"
Background="{x:Null}" SelectionTextBrush="Red" SelectionBrush="#FFDAFF00"/>
</DockPanel>
<DockPanel x:Name="tableLayoutPanelBottom" DockPanel.Dock="Bottom" Margin="12,4">
<DockPanel x:Name="tableLayoutPanelBottom" DockPanel.Dock="Bottom" Margin="12,6,14,5">
<DockPanel.Resources>
<SolidColorBrush x:Key="ButtonHoverColor" Color="LightGray" Opacity="0.15"/>
<Style TargetType="{x:Type Button}">
<!-- TODO: Find better solution instead of re-implementing the control template of a button,
only to manage changing the mouse hover border color. -->
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
@ -171,16 +172,16 @@
</Button>
</DockPanel>
<ListView x:Name="dgv" x:FieldModifier="internal" Margin="6,0" d:ItemsSource="{d:SampleData ItemCount=5}" SelectionMode="Single" HorizontalContentAlignment="Stretch"
Foreground="{x:Static stm:MenuDefines.ColorForeground}" BorderBrush="{x:Null}" Background="{x:Null}"
<ListView x:Name="dgv" x:FieldModifier="internal" Margin="7,0" d:ItemsSource="{d:SampleData ItemCount=5}" SelectionMode="Single" HorizontalContentAlignment="Stretch"
Foreground="{x:Static stm:MenuDefines.ColorForeground}" Background="{x:Null}" BorderThickness="0"
SelectionChanged="ListView_SelectionChanged" MouseLeave="ListView_MouseLeave"
ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.ScrollChanged="HandleScrollChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{Binding BorderBrush}" Background="{Binding BackgroundBrush}" BorderThickness="1">
<StackPanel Orientation="Horizontal" Height="{DynamicResource RowHeight}">
<Image Width="{DynamicResource ColumnIconWidth}" Margin="0,1,0,2" Source="{Binding ColumnIcon}" />
<TextBlock Width="{DynamicResource ColumnTextWidth}" Margin="5,0,2,1" Padding="0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
<Border Height="{DynamicResource RowHeight}" BorderBrush="{Binding BorderBrush}" Background="{Binding BackgroundBrush}" BorderThickness="1">
<StackPanel Orientation="Horizontal">
<Image Width="{DynamicResource ColumnIconWidth}" Margin="0" Source="{Binding ColumnIcon}" />
<TextBlock Width="{DynamicResource ColumnTextWidth}" Margin="5,0,2,0" Padding="0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Text="{Binding ColumnText}" Foreground="{x:Static stm:MenuDefines.ColorForeground}" />
<!-- TODO: Optional or only for trimmed entries: ToolTip="{Binding ColumnText}" -->
</StackPanel>

View file

@ -48,7 +48,7 @@ namespace SystemTrayMenu.UserInterface
if (!Config.ShowDirectoryTitleAtTop)
{
txtTitle.Visibility = Visibility.Hidden;
txtTitle.Visibility = Visibility.Collapsed;
}
if (!Config.ShowSearchBar)
@ -883,9 +883,8 @@ namespace SystemTrayMenu.UserInterface
// 125% = 23 instead 27, 150% = 28 instead 32
// 175% = 33 instead 37, 200% = 35 instead 42
// #418 use 21 as default and scale it manually
// 2px less due to subtracted boarder around list view item
double rowHeightDefault = 21.24d * Scaling.FactorByDpi;
Resources["RowHeight"] = Math.Ceiling((rowHeightDefault * factor * Scaling.Factor) - 2.0d);
Resources["RowHeight"] = Math.Round(rowHeightDefault * factor * Scaling.Factor);
dgv.Tag = true;
}
}