-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToastDialog.xaml
305 lines (257 loc) · 17 KB
/
ToastDialog.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<UserControl x:Class="ToastManager.ToastDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ToastManager"
xmlns:converter="clr-namespace:ToastManager.Core.Converter"
xmlns:core="clr-namespace:ToastManager.Core"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<d:UserControl.DataContext>
<local:ToastDialog/>
</d:UserControl.DataContext>
<UserControl.Resources>
<converter:EnumFlagConverter x:Key="EnumFlagConverter"/>
<converter:EnumToBoolConverter x:Key="EnumToBoolConverter"/>
<Style TargetType="Path">
<Setter Property="Stretch" Value="Uniform" />
<Setter Property="Fill" Value="White" />
<Setter Property="Width" Value="25" />
<Setter Property="Margin" Value="3" />
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="5" />
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="100" />
<Setter Property="Background" Value="LightGray" />
</Style>
<Style TargetType="{x:Type Grid}" x:Key="CardAnimation">
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleX)"
From="0" To="1" Duration="0:0:0.25">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleY)"
From="0" To="1" Duration="0:0:0.25">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Unloaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleX)"
To="0" Duration="0:0:0"/>
<DoubleAnimation
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleY)"
To="0" Duration="0:0:0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
<Geometry x:Key="CheckCircle">m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z</Geometry>
<Geometry x:Key="Error">M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240Zm40 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z</Geometry>
<Geometry x:Key="Info">M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z</Geometry>
<Geometry x:Key="Warning">m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z</Geometry>
<Geometry x:Key="Close">m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z</Geometry>
</UserControl.Resources>
<Grid>
<Border x:Name="FrontEndBlocker" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#01010101"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsDarkBackground}" Value="true">
<Setter Property="Background" Value="#6000"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseDown">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="ToastPopup"
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleX)"
From="1" To="1.2" Duration="0:0:0.25" AutoReverse="True">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation
Storyboard.TargetName="ToastPopup"
Storyboard.TargetProperty="(Grid.RenderTransform).(ScaleTransform.ScaleY)"
From="1" To="1.2" Duration="0:0:0.25" AutoReverse="True">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Border.Triggers>
</Border>
<Grid x:Name="ToastPopup" Style="{StaticResource CardAnimation}" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center" HorizontalAlignment="Center">
<Grid.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Grid.RenderTransform>
<Border x:Name="ToastBorder" Background="#FFE8EBF3" CornerRadius="5" MaxWidth="500" MaxHeight="500">
<Border.Effect>
<DropShadowEffect BlurRadius="30" Color="Black" Opacity="0.5" ShadowDepth="0"/>
</Border.Effect>
<DockPanel LastChildFill="True">
<DockPanel DockPanel.Dock="Top" LastChildFill="True">
<Button DockPanel.Dock="Right" Width="30" Height="30" Command="{Binding ExitButtonCommand}">
<Path Data="{StaticResource Close}" Margin="6" />
</Button>
<Border DockPanel.Dock="Left" Background="#9FFF" CornerRadius="5" Margin="3,3,0,3">
<StackPanel Orientation="Horizontal">
<!--Info-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastType, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static core:ToastType.Info}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Path Data="{StaticResource Info}" Fill="#FF59697A" Margin="5" />
</Border>
<!--Warning-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastType, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static core:ToastType.Warning}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Path Data="{StaticResource Warning}" Fill="#FF59697A" Margin="5" />
</Border>
<!--Error-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastType, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static core:ToastType.Error}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Path Data="{StaticResource Error}" Fill="Red" Margin="5" />
</Border>
<!--Success-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastType, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static core:ToastType.Success}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Path Data="{StaticResource CheckCircle}" Fill="LightGreen" Margin="5" />
</Border>
<TextBlock Text="{Binding Title}" Foreground="#D000" FontSize="20" FontWeight="Medium"
VerticalAlignment="Center" Margin="10,3" />
</StackPanel>
</Border>
</DockPanel>
<!--BUTTON-->
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
<!--Ok-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastButton, Converter={StaticResource EnumFlagConverter}, ConverterParameter={x:Static core:ToastButton.Ok}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Button Command="{Binding OkButtonCommand}">
<TextBlock Text="Ok" Foreground="#D000" FontSize="15" FontWeight="Medium" />
</Button>
</Border>
<!--YES-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastButton, Converter={StaticResource EnumFlagConverter}, ConverterParameter={x:Static core:ToastButton.Yes}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Button Command="{Binding YesButtonCommand}">
<TextBlock Text="Yes" Foreground="#D000" FontSize="15" FontWeight="Medium" />
</Button>
</Border>
<!--NO-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastButton, Converter={StaticResource EnumFlagConverter}, ConverterParameter={x:Static core:ToastButton.No}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Button Command="{Binding NoButtonCommand}">
<TextBlock Text="No" Foreground="#D000" FontSize="15" FontWeight="Medium" />
</Button>
</Border>
<!--Cancel-->
<Border>
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding ToastButton, Converter={StaticResource EnumFlagConverter}, ConverterParameter={x:Static core:ToastButton.Cancel}}" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Button Command="{Binding CancelButtonCommand}">
<TextBlock Text="Cancel" Foreground="#D000" FontSize="15" FontWeight="Medium" />
</Button>
</Border>
</StackPanel>
<Border DockPanel.Dock="Top" Margin="5">
<TextBlock Text="{Binding Message}" TextWrapping="WrapWithOverflow" Foreground="#D000" FontSize="15" FontWeight="Medium"
VerticalAlignment="Center" Margin="5" />
</Border>
</DockPanel>
</Border>
</Grid>
</Grid>
</UserControl>