5
5
using System . Windows . Input ;
6
6
using System . Windows . Media . Animation ;
7
7
using System . Windows . Media . Imaging ;
8
+ using System . Windows . Media ;
8
9
using Flow . Launcher . Helper ;
9
10
using Flow . Launcher . Infrastructure ;
10
11
using Flow . Launcher . Infrastructure . Image ;
12
+ using Windows . UI ;
13
+ using Windows . Data ;
14
+ using Windows . Data . Xml . Dom ;
15
+ using Windows . UI . Notifications ;
11
16
12
17
namespace Flow . Launcher
13
18
{
14
19
public partial class Msg : Window
15
20
{
16
- Storyboard fadeOutStoryboard = new Storyboard ( ) ;
17
- private bool closing ;
18
21
19
22
public Msg ( )
20
23
{
21
24
InitializeComponent ( ) ;
22
- var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
23
- var dipWorkingArea = WindowsInteropHelper . TransformPixelsToDIP ( this ,
24
- screen . WorkingArea . Width ,
25
- screen . WorkingArea . Height ) ;
26
- Left = dipWorkingArea . X - Width ;
27
- Top = dipWorkingArea . Y ;
28
- showAnimation . From = dipWorkingArea . Y ;
29
- showAnimation . To = dipWorkingArea . Y - Height ;
30
25
31
- // Create the fade out storyboard
32
- fadeOutStoryboard . Completed += fadeOutStoryboard_Completed ;
33
- DoubleAnimation fadeOutAnimation = new DoubleAnimation ( dipWorkingArea . Y - Height , dipWorkingArea . Y , new Duration ( TimeSpan . FromSeconds ( 5 ) ) )
34
- {
35
- AccelerationRatio = 0.2
36
- } ;
37
- Storyboard . SetTarget ( fadeOutAnimation , this ) ;
38
- Storyboard . SetTargetProperty ( fadeOutAnimation , new PropertyPath ( TopProperty ) ) ;
39
- fadeOutStoryboard . Children . Add ( fadeOutAnimation ) ;
40
-
41
- imgClose . Source = ImageLoader . Load ( Path . Combine ( Infrastructure . Constant . ProgramDirectory , "Images\\ close.png" ) ) ;
42
- imgClose . MouseUp += imgClose_MouseUp ;
43
26
}
44
27
45
- void imgClose_MouseUp ( object sender , MouseButtonEventArgs e )
28
+ public void Show ( string title , string subTitle , string iconPath )
46
29
{
47
- if ( ! closing )
48
- {
49
- closing = true ;
50
- fadeOutStoryboard . Begin ( ) ;
51
- }
52
- }
53
30
54
- private void fadeOutStoryboard_Completed ( object sender , EventArgs e )
55
- {
56
- Close ( ) ;
57
- }
58
31
59
- public void Show ( string title , string subTitle , string iconPath )
60
- {
61
32
tbTitle . Text = title ;
62
33
tbSubTitle . Text = subTitle ;
63
34
if ( string . IsNullOrEmpty ( subTitle ) )
@@ -68,20 +39,23 @@ public void Show(string title, string subTitle, string iconPath)
68
39
{
69
40
imgIco . Source = ImageLoader . Load ( Path . Combine ( Constant . ProgramDirectory , "Images\\ app.png" ) ) ;
70
41
}
71
- else {
42
+ else
43
+ {
72
44
imgIco . Source = ImageLoader . Load ( iconPath ) ;
73
45
}
74
46
75
- Show ( ) ;
47
+ /* Using Windows Notification System */
48
+ var ToastTitle = title ;
49
+ var ToastsubTitle = subTitle ;
50
+ var Icon = imgIco . Source ;
51
+ var xml = $ "<?xml version=\" 1.0\" ?><toast><visual><binding template=\" ToastImageAndText04\" ><image id=\" 1\" src=\" { Icon } \" alt=\" meziantou\" /><text id=\" 1\" >{ ToastTitle } </text>" +
52
+ $ "<text id=\" 2\" >{ ToastsubTitle } </text></binding></visual></toast>";
53
+ var toastXml = new XmlDocument ( ) ;
54
+ toastXml . LoadXml ( xml ) ;
55
+ var toast = new ToastNotification ( toastXml ) ;
56
+ ToastNotificationManager . CreateToastNotifier ( "Flow Launcher" ) . Show ( toast ) ;
76
57
77
- Dispatcher . InvokeAsync ( async ( ) =>
78
- {
79
- if ( ! closing )
80
- {
81
- closing = true ;
82
- await Dispatcher . InvokeAsync ( fadeOutStoryboard . Begin ) ;
83
- }
84
- } ) ;
85
58
}
59
+
86
60
}
87
61
}
0 commit comments