/
ButtonWithRepeadTemplate.xaml
114 lines (100 loc) · 5.88 KB
/
ButtonWithRepeadTemplate.xaml
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- base icon settings -->
<Style x:Key="PathIconBase" TargetType="Path">
<Setter Property="Width" Value="14" />
<Setter Property="Height" Value="14" />
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Fill" Value="White"/>
</Style>
<!-- file, can use for open file -->
<Style x:Key="PathIconFile" TargetType="Path" BasedOn="{StaticResource PathIconBase}">
<Setter Property="Width" Value="9" />
<Setter Property="Height" Value="11" />
<Setter Property="Data"
Value="F1 M 20,17L 43.25,17L 56,29.75L 56,59L 20,59L 20,17 Z M 24,21L 24,55L 52,55L 52,34L 39,34L 39,21L 24,21 Z M 43,22.25L 43,30L 50.75,30L 43,22.25 Z M 30,33L 34,33L 34,41.5L 37,38.5L 37,43.25L 32,48.25L 27,42.75L 27,38.5L 30,41.5L 30,33 Z M 38,49L 38,53L 26,53L 26,49L 38,49 Z" />
</Style>
<!-- open folder icon -->
<Style x:Key="PathIconOpenFolder" TargetType="Path" BasedOn="{StaticResource PathIconBase}">
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="8" />
<Setter Property="Data"
Value="F1 M 19,50L 28,34L 63,34L 54,50L 19,50 Z M 19,28.0001L 35,28C 36,25 37.4999,24.0001 37.4999,24.0001L 48.75,24C 49.3023,24 50,24.6977 50,25.25L 50,28L 53.9999,28.0001L 53.9999,32L 27,32L 19,46.4L 19,28.0001 Z " />
</Style>
<!-- Ellipse / ground of the Button Icon -->
<Style x:Key="ButtonBaseEllipse" TargetType="Ellipse">
<Setter Property="Fill" Value="Yellow" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
</Style>
<!-- Ellipse / Border for the Button Icon -->
<Style x:Key="ButtonBaseEllipseWithBorder" TargetType="Ellipse" BasedOn="{StaticResource ButtonBaseEllipse}">
<Setter Property="Stroke" Value="WhiteSmoke" />
<Setter Property="StrokeThickness" Value="1" />
</Style>
<!-- open file -->
<Style x:Key="ButtonOpenFile" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ButtonBase">
<Viewbox Width="{Binding RelativeSource={RelativeSource Self}, Path=Width}"
Height="{Binding RelativeSource={RelativeSource Self}, Path=Height}">
<Grid>
<Ellipse x:Name="ellipseBorder" Style="{StaticResource ButtonBaseEllipseWithBorder}" />
<Path x:Name="pathIcon" Style="{StaticResource PathIconFile}" />
</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="DodgerBlue" />
<Setter TargetName="pathIcon" Property="Fill" Value="DeepSkyBlue" />
<Setter Property="Cursor" Value="Hand" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="Blue" />
<Setter TargetName="pathIcon" Property="Fill" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="LightBlue" />
<Setter TargetName="pathIcon" Property="Fill" Value="LightCyan" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- open folder -->
<Style x:Key="ButtonOpenFolder" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ButtonBase">
<Viewbox Width="{Binding RelativeSource={RelativeSource Self}, Path=Width}"
Height="{Binding RelativeSource={RelativeSource Self}, Path=Height}">
<Grid>
<Ellipse x:Name="ellipseBorder" Style="{StaticResource ButtonBaseEllipseWithBorder}" />
<Path x:Name="pathIcon" Style="{StaticResource PathIconOpenFolder}" />
</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="DodgerBlue" />
<Setter TargetName="pathIcon" Property="Fill" Value="DeepSkyBlue" />
<Setter Property="Cursor" Value="Hand" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="Blue" />
<Setter TargetName="pathIcon" Property="Fill" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ellipseBorder" Property="Stroke" Value="LightBlue" />
<Setter TargetName="pathIcon" Property="Fill" Value="LightCyan" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>