mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-10-02 01:57:23 +13:00
Add initial scaling to scroll bar layout
Still open: Scaling for arrow Paths
This commit is contained in:
parent
d39588b8c5
commit
79d70222cc
3 changed files with 46 additions and 17 deletions
|
@ -3,16 +3,20 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="clr-namespace:SystemTrayMenu.Utilities"
|
||||
xmlns:stm="clr-namespace:SystemTrayMenu">
|
||||
|
||||
<!-- Control Template Referene Example: -->
|
||||
<!-- https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/scrollbar-styles-and-templates -->
|
||||
<!-- Control Template: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/scrollbar-styles-and-templates -->
|
||||
<!-- Path notation: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/path-markup-syntax -->
|
||||
<!-- Transform: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/transforms-overview -->
|
||||
|
||||
<!-- TODO: Check and adjust horizontal scrollbars -->
|
||||
<!-- TODO: Take care of disabled scrollbars -->
|
||||
|
||||
|
||||
<Color x:Key="DisabledForegroundColor">Transparent</Color>
|
||||
|
||||
<ScaleTransform x:Key="ScaleFactor" ScaleX="1" ScaleY="1" /> <!-- TODO: Fill in factor on Scaling ctor ? (Mayb move to App.xaml) -->
|
||||
|
||||
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true" />
|
||||
|
@ -77,6 +81,7 @@
|
|||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Path x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
RenderTransform="{StaticResource ScaleFactor}"
|
||||
Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" >
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{Binding Source={x:Static stm:MenuDefines.ColorArrow},Path=Color}"/>
|
||||
|
@ -150,15 +155,15 @@
|
|||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid Background="{x:Static stm:MenuDefines.ColorScrollbarBackground}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<RowDefinition MaxHeight="{u:ScaleDouble 15}" />
|
||||
<RowDefinition Height="0.00001*" />
|
||||
<RowDefinition MaxHeight="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<RowDefinition MaxHeight="{u:ScaleDouble 15}" />
|
||||
</Grid.RowDefinitions>
|
||||
<RepeatButton Grid.Row="0"
|
||||
Style="{StaticResource ScrollBarLineButton}"
|
||||
Height="15"
|
||||
Height="{u:ScaleDouble 15}"
|
||||
Command="ScrollBar.LineUpCommand"
|
||||
Content="M 0 4 L 8 4 L 4 0 Z" /> <!-- TODO: Width = Scaling.Scale(15) -->
|
||||
Content="M 0 4 L 8 4 L 4 0 Z" />
|
||||
<Track x:Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
|
||||
|
@ -197,24 +202,24 @@
|
|||
</Track>
|
||||
<RepeatButton Grid.Row="2"
|
||||
Style="{StaticResource ScrollBarLineButton}"
|
||||
Height="15"
|
||||
Height="{u:ScaleDouble 15}"
|
||||
Command="ScrollBar.LineDownCommand"
|
||||
Content="M 0 0 L 4 4 L 8 0 Z" /> <!-- TODO: Width = Scaling.Scale(15) -->
|
||||
Content="M 0 0 L 4 4 L 8 0 Z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid Background="{x:Static stm:MenuDefines.ColorScrollbarBackground}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MaxWidth="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<ColumnDefinition MaxWidth="{u:ScaleDouble 15}" />
|
||||
<ColumnDefinition Width="0.00001*" />
|
||||
<ColumnDefinition MaxWidth="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<ColumnDefinition MaxWidth="{u:ScaleDouble 15}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<RepeatButton Grid.Column="0"
|
||||
Style="{StaticResource ScrollBarLineButton}"
|
||||
Width="15"
|
||||
Width="{u:ScaleDouble 15}"
|
||||
Command="ScrollBar.LineLeftCommand"
|
||||
Content="M 4 0 L 4 8 L 0 4 Z" /> <!-- TODO: Width = Scaling.Scale(15) -->
|
||||
Content="M 4 0 L 4 8 L 0 4 Z" />
|
||||
<Track x:Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" />
|
||||
|
@ -252,9 +257,9 @@
|
|||
</Track>
|
||||
<RepeatButton Grid.Column="2"
|
||||
Style="{StaticResource ScrollBarLineButton}"
|
||||
Width="15"
|
||||
Width="{u:ScaleDouble 15}"
|
||||
Command="ScrollBar.LineRightCommand"
|
||||
Content="M 0 0 L 4 4 L 0 8 Z" /> <!-- TODO: Width = Scaling.Scale(15) -->
|
||||
Content="M 0 0 L 4 4 L 0 8 Z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
|
@ -264,11 +269,11 @@
|
|||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="Width" Value="Auto" />
|
||||
<Setter Property="Height" Value="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<Setter Property="Height" Value="{u:ScaleDouble 15}" />
|
||||
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Width" Value="15" /> <!-- TODO: Scaling.Scale(15) -->
|
||||
<Setter Property="Width" Value="{u:ScaleDouble 15}" />
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
|
||||
</Trigger>
|
||||
|
|
23
Utilities/ScaleDouble.cs
Normal file
23
Utilities/ScaleDouble.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// <copyright file="ScaleDouble.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// Copyright (c) 2023-2023 Peter Kirmeier
|
||||
|
||||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
using System;
|
||||
using System.Windows.Markup;
|
||||
|
||||
internal class ScaleDouble : MarkupExtension
|
||||
{
|
||||
private readonly double value;
|
||||
|
||||
public ScaleDouble(string original)
|
||||
{
|
||||
value = double.Parse(original);
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) => Scaling.Scale(value);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ namespace SystemTrayMenu.Utilities
|
|||
|
||||
public static float Factor { get; private set; } = 1;
|
||||
|
||||
// TODO: This value is per visual element and should not be shared!
|
||||
public static double FactorByDpi { get; private set; } = 1;
|
||||
|
||||
public static void Initialize()
|
||||
|
|
Loading…
Reference in a new issue