Skip to content

Commit 0742d03

Browse files
committed
Revert "- Change the popup to windows notification"
This reverts commit 1317077.
1 parent 886d7aa commit 0742d03

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

Flow.Launcher/Msg.xaml.cs

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,59 @@
55
using System.Windows.Input;
66
using System.Windows.Media.Animation;
77
using System.Windows.Media.Imaging;
8-
using System.Windows.Media;
98
using Flow.Launcher.Helper;
109
using Flow.Launcher.Infrastructure;
1110
using Flow.Launcher.Infrastructure.Image;
12-
using Windows.UI;
13-
using Windows.Data;
14-
using Windows.Data.Xml.Dom;
15-
using Windows.UI.Notifications;
1611

1712
namespace Flow.Launcher
1813
{
1914
public partial class Msg : Window
2015
{
16+
Storyboard fadeOutStoryboard = new Storyboard();
17+
private bool closing;
2118

2219
public Msg()
2320
{
2421
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;
2530

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;
2643
}
2744

28-
public void Show(string title, string subTitle, string iconPath)
45+
void imgClose_MouseUp(object sender, MouseButtonEventArgs e)
2946
{
47+
if (!closing)
48+
{
49+
closing = true;
50+
fadeOutStoryboard.Begin();
51+
}
52+
}
3053

54+
private void fadeOutStoryboard_Completed(object sender, EventArgs e)
55+
{
56+
Close();
57+
}
3158

59+
public void Show(string title, string subTitle, string iconPath)
60+
{
3261
tbTitle.Text = title;
3362
tbSubTitle.Text = subTitle;
3463
if (string.IsNullOrEmpty(subTitle))
@@ -39,23 +68,20 @@ public void Show(string title, string subTitle, string iconPath)
3968
{
4069
imgIco.Source = ImageLoader.Load(Path.Combine(Constant.ProgramDirectory, "Images\\app.png"));
4170
}
42-
else
43-
{
71+
else {
4472
imgIco.Source = ImageLoader.Load(iconPath);
4573
}
4674

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);
75+
Show();
5776

77+
Dispatcher.InvokeAsync(async () =>
78+
{
79+
if (!closing)
80+
{
81+
closing = true;
82+
await Dispatcher.InvokeAsync(fadeOutStoryboard.Begin);
83+
}
84+
});
5885
}
59-
6086
}
6187
}

0 commit comments

Comments
 (0)