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
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Notifications.Wpf.Controls"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="clr-namespace:Notifications.Wpf">
<Path x:Key="ErrorIcon" Data="M 2.6874995 2.8246546e-7 -4.7683716e-7 2.6855503 5.3007795 7.9863303 -4.7683716e-7 13.28516 2.6874995 15.97266 l 5.29883 -5.30079 5.3007805 5.30079 2.68554 -2.6875 -5.29882 -5.2988297 5.29882 -5.30078 L 13.28711 2.8246546e-7 7.9863295 5.2988303 2.6874995 2.8246546e-7 Z" Fill="White" x:Shared="False"/>
<Path x:Key="SuccessIcon" Data="M 15.56055 5.9323048e-7 7.53125 10.197261 2.73242 5.2304706 0 7.8710906 7.82422 15.968751 18.54492 2.3515606 15.56055 5.9323048e-7 Z" Fill="White" x:Shared="False"/>
<Path x:Key="InfoIcon" Data="M 10.968748 8.9809305e-8 C 4.9320181 8.9809305e-8 -1.9073487e-6 4.9320201 -1.9073487e-6 10.96875 c 0 6.03672 4.9322600073487 10.9668 10.9687499073487 10.9668 6.03648 0 10.96875 -4.93008 10.96875 -10.9668 C 21.937498 4.9320201 17.005458 8.9809305e-8 10.968748 8.9809305e-8 Z m 0 2.000000010190695 c 4.95043 0 8.96875 4.0183 8.96875 8.9687499 0 4.95044 -4.01809 8.9668 -8.96875 8.9668 -4.9506899 0 -8.9687499 -4.01636 -8.9687499 -8.9668 0 -4.9504499 4.0183 -8.9687499 8.9687499 -8.9687499 z m -1.4999999 2.49805 0 3 2.9999999 0 0 -3 -2.9999999 0 z m 0 4.4707 0 8.9101599 2.9999999 0 0 -8.9101599 -2.9999999 0 z" Fill="White" x:Shared="False"/>
<Path x:Key="WarningIcon" Data="M 12.414089 4.6396565e-7 C 12.128679 -9.5360343e-6 11.832699 0.06810046 11.574249 0.19726046 c -0.29252 0.14627 -0.55012 0.39584 -0.70899 0.67383 l -0.002 0.002 L 0.22067905 19.77348 l -0.0117 0.0234 C 0.08326905 20.04831 -9.5367432e-7 20.33976 -9.5367432e-7 20.64844 c 0 0.30629 0.0851000036743 0.62597 0.23633000367432 0.89063 0.13469 0.2357 0.31957 0.44504 0.5332 0.60937 l 0.0137 0.0117 0.0156 0.01 C 1.076789 22.36867 1.440719 22.48654 1.785149 22.48654 l 21.28516 0 c 0.3398 0 0.70907 -0.12364 0.98828 -0.33398 0.2208 -0.16158 0.42089 -0.3689 0.56055 -0.61328 0.15122 -0.26466 0.23633 -0.58434 0.23633 -0.89063 0 -0.30868 -0.0852 -0.60013 -0.21094 -0.85156 l -0.01 -0.0234 -10.66992 -18.90038954 -0.002 -0.002 c -0.15887 -0.27808 -0.41633 -0.52756 -0.70899 -0.67383 -0.25845 -0.12918 -0.55443 -0.19726999603 -0.83984 -0.19725999603 z m 0 2.19531003603435 10.32617 18.2910095 -20.625 0 10.29883 -18.2910095 z m -1.48633 3.84765 0 8.9121095 3 0 0 -8.9121095 -3 0 z m 0 10.3808595 0 3 3 0 0 -3 -3 0 z" Fill="White" x:Shared="False"/>
<Style TargetType="Button" x:Key="CloseButtonStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<TextBlock Text="⛌" FontSize="12" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<wpf:NotificationTemplateSelector x:Key="NotificationTemplateSelector"/>
<ControlTemplate x:Key="NotificationTemplate" TargetType="{x:Type controls:Notification}">
<ControlTemplate.Resources>
<DataTemplate DataType="{x:Type system:String}" x:Key="DefaultStringTemplate">
<Border Background="{Binding RelativeSource={RelativeSource AncestorType=controls:Notification}, Path=Background}" MinHeight="80">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding}"/>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type wpf:NotificationContent}" x:Key="DefaultNotificationTemplate">
<Border x:Name="Border" Padding="12" MinHeight="80">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentControl Margin="0,0,12,0" Width="25" Height="25" VerticalAlignment="Top">
<ContentControl x:Name="Icon" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ContentControl>
<DockPanel Grid.Column="1">
<TextBlock DockPanel.Dock="Top" Text="{Binding Title}" FontWeight="Medium" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding Message}" TextWrapping="Wrap" Opacity=".8" Margin="0,0,12,0"/>
</DockPanel>
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Type}" Value="Information">
<Setter TargetName="Icon" Property="Content" Value="{StaticResource InfoIcon}"/>
<Setter TargetName="Border" Property="Background" Value="CornflowerBlue"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Success">
<Setter TargetName="Icon" Property="Content" Value="{StaticResource SuccessIcon}"/>
<Setter TargetName="Border" Property="Background" Value="#353535"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Warning">
<Setter TargetName="Icon" Property="Content" Value="{StaticResource WarningIcon}"/>
<Setter TargetName="Border" Property="Background" Value="Orange"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Error">
<Setter TargetName="Icon" Property="Content" Value="{StaticResource ErrorIcon}"/>
<Setter TargetName="Border" Property="Background" Value="OrangeRed"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ControlTemplate.Resources>
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="8,8,0,0">
<Grid>
<ContentPresenter/>
<Button x:Name="PART_CloseButton" Style="{StaticResource CloseButtonStyle}" Margin="12" Foreground="{TemplateBinding Foreground}" Opacity=".8"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:.5" />
<DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleX" From="0" To="1" Duration="0:0:.2"/>
<DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleY" From="0" To="1" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="controls:Notification.NotificationCloseInvoked" >
<BeginStoryboard>
<Storyboard Duration="0:0:.1">
<DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleX" From="1" To="0.1" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard BeginTime="0:0:.2">
<DoubleAnimation Storyboard.TargetProperty="LayoutTransform.ScaleY" From="1" To="0" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type controls:Notification}">
<!--<Setter Property="Height" Value="100"/>-->
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Width" Value="350"/>
<Setter Property="FontSize" Value="14"></Setter>
<Setter Property="Background" Value="#444444"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template" Value="{StaticResource NotificationTemplate}"/>
<Setter Property="ContentTemplateSelector" Value="{StaticResource NotificationTemplateSelector}"/>
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="5" Direction="0" ShadowDepth="0" Opacity=".25"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:NotificationArea}">
<Setter Property="Margin" Value="0,0,8,8"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:NotificationArea}">
<controls:ReversibleStackPanel x:Name="PART_Items"/>
<ControlTemplate.Triggers>
<Trigger Property="Position" Value="TopLeft">
<Setter TargetName="PART_Items" Property="VerticalAlignment" Value="Top"/>
<Setter TargetName="PART_Items" Property="HorizontalAlignment" Value="Left"/>
</Trigger>
<Trigger Property="Position" Value="TopRight">
<Setter TargetName="PART_Items" Property="VerticalAlignment" Value="Top"/>
<Setter TargetName="PART_Items" Property="HorizontalAlignment" Value="Right"/>
</Trigger>
<Trigger Property="Position" Value="BottomLeft">
<Setter TargetName="PART_Items" Property="ReverseOrder" Value="True"/>
<Setter TargetName="PART_Items" Property="VerticalAlignment" Value="Bottom"/>
<Setter TargetName="PART_Items" Property="HorizontalAlignment" Value="Left"/>
</Trigger>
<Trigger Property="Position" Value="BottomRight">
<Setter TargetName="PART_Items" Property="ReverseOrder" Value="True"/>
<Setter TargetName="PART_Items" Property="VerticalAlignment" Value="Bottom"/>
<Setter TargetName="PART_Items" Property="HorizontalAlignment" Value="Right"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
|