-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFlatSlider.xaml
More file actions
195 lines (186 loc) · 10 KB
/
FlatSlider.xaml
File metadata and controls
195 lines (186 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EtherCAT_Master"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
<Style x:Key="SliderButtonStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SliderThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Grid Background="{TemplateBinding Background}" >
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
FontSize="10"
FontWeight="Bold"
Text="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type Slider}}, StringFormat=N0}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SliderTickBarStyle" TargetType="TickBar">
<Setter Property="Fill" Value="{DynamicResource SliderThumbDisabled}" />
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<Trigger Property="Placement" Value="Top">
<Setter Property="Height" Value="6" />
<Setter Property="Margin" Value="0 0 0 3" />
</Trigger>
<Trigger Property="Placement" Value="Bottom">
<Setter Property="Grid.Row" Value="2" />
<Setter Property="Height" Value="6" />
<Setter Property="Margin" Value="0 3 0 0" />
</Trigger>
<Trigger Property="Placement" Value="Left">
<Setter Property="Margin" Value="0 0 3 0" />
<Setter Property="Width" Value="6" />
</Trigger>
<Trigger Property="Placement" Value="Right">
<Setter Property="Grid.Column" Value="2" />
<Setter Property="Margin" Value="3 0 0 0" />
<Setter Property="Width" Value="6" />
</Trigger>
</Style.Triggers>
</Style>
<ControlTemplate x:Key="HorizontalSlider" TargetType="{x:Type Slider}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TickBar x:Name="TopTick"
Placement="Top"
Style="{StaticResource SliderTickBarStyle}" />
<Track x:Name="PART_Track" Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton Height="{TemplateBinding Slider.Height}"
Background="{TemplateBinding Slider.Foreground}"
Command="Slider.DecreaseLarge"
Style="{StaticResource SliderButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Controls:MetroThumb Width="{TemplateBinding Slider.Height}"
Height="{TemplateBinding Slider.Height}"
Background="{TemplateBinding Slider.BorderBrush}"
Style="{StaticResource SliderThumbStyle}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Height="{TemplateBinding Slider.Height}"
Background="{TemplateBinding Slider.Background}"
Command="Slider.IncreaseLarge"
Style="{StaticResource SliderButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>
<TickBar x:Name="BottomTick"
Placement="Bottom"
Style="{StaticResource SliderTickBarStyle}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="VerticalSlider" TargetType="{x:Type Slider}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="{TemplateBinding Slider.MinWidth}" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TickBar x:Name="TopTick"
Placement="Left"
Style="{StaticResource SliderTickBarStyle}" />
<Track x:Name="PART_Track" Grid.Column="1">
<Track.DecreaseRepeatButton>
<RepeatButton Height="{TemplateBinding Slider.Height}"
Background="{TemplateBinding Slider.Foreground}"
Command="Slider.DecreaseLarge"
Style="{StaticResource SliderButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Controls:MetroThumb Width="{TemplateBinding Slider.Width}"
Height="{TemplateBinding Slider.Width}"
Background="{TemplateBinding Slider.BorderBrush}"
Style="{StaticResource SliderThumbStyle}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Height="{TemplateBinding Slider.Height}"
Background="{TemplateBinding Slider.Background}"
Command="Slider.IncreaseLarge"
Style="{StaticResource SliderButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>
<TickBar x:Name="BottomTick"
Placement="Right"
Style="{StaticResource SliderTickBarStyle}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
<Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="FlatSlider" TargetType="{x:Type Slider}">
<Setter Property="Background" Value="{DynamicResource SliderTrackNormal}" />
<Setter Property="BorderBrush" Value="{DynamicResource BlackBrush}" />
<Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
<Setter Property="Maximum" Value="100" />
<Setter Property="Minimum" Value="0" />
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Value" Value="0" />
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource SliderTrackDisabled}" />
<Setter Property="BorderBrush" Value="{DynamicResource SliderThumbDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SliderValueDisabled}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<!--<Setter Property="Background" Value="{DynamicResource SliderTrackHover}" />-->
<Setter Property="Foreground" Value="{DynamicResource AccentColorBrush2}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Height" Value="12" />
<Setter Property="MinHeight" Value="12" />
<Setter Property="Template" Value="{StaticResource HorizontalSlider}" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="MinWidth" Value="12" />
<Setter Property="Template" Value="{StaticResource VerticalSlider}" />
<Setter Property="Width" Value="12" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>