-
Notifications
You must be signed in to change notification settings - Fork 6
/
ToastForm.cs
51 lines (41 loc) · 1.46 KB
/
ToastForm.cs
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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace ReLink {
public partial class ToastForm : Form {
int blinkCount = 0;
const int DURATION = 5;
public ToastForm() {
InitializeComponent();
}
internal static void ShowToast(string message) {
ShowToast(message, false);
}
internal static void ShowToast(string message, bool isDialog) {
ToastForm toast = new ToastForm();
toast.lblMessage.Text = message;
toast.tmrClose.Interval = DURATION * 1000;
toast.tmrClose.Start();
toast.TopMost = true;
int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
toast.Size = new Size(screenWidth / 5, screenHeight/5);
toast.Location = new Point((screenWidth - toast.Size.Width) - 10, (screenHeight - toast.Size.Height) - 10);
if (isDialog) {
toast.ShowDialog();
} else {
toast.Show();
}
}
private void TmrBlinkTick(object sender, EventArgs e) {
/* blinkCount++;
if (blinkCount <= 4) {
Opacity = Opacity == 1 ? 0 : 1;
Refresh();
}*/
}
private void TmrCloseTick(object sender, EventArgs e) {
this.Close();
}
}
}