Toasts – Diff between revs 1 and 2
?pathlinks?
Rev 1 | Rev 2 | |||
---|---|---|---|---|
Line 7... | Line 7... | |||
7 | using System.Drawing; |
7 | using System.Drawing; |
|
8 | using System.Windows.Forms; |
8 | using System.Windows.Forms; |
|
Line 9... | Line 9... | |||
9 | |
9 | |
|
10 | namespace Toasts |
10 | namespace Toasts |
|
11 | { |
11 | { |
|
12 | public partial class Notification : Form |
12 | public partial class ToastForm : Form |
|
13 | { |
13 | { |
|
Line 14... | Line 14... | |||
14 | #region Static Fields and Constants |
14 | #region Static Fields and Constants |
|
- | 15 | |
||
- | 16 | private static readonly List<ToastForm> OpenNotifications = new List<ToastForm>(); |
||
- | 17 | |
||
- | 18 | #endregion |
||
- | 19 | |
||
- | 20 | #region Public Methods |
||
- | 21 | |
||
- | 22 | /// <summary> |
||
- | 23 | /// Displays the form |
||
- | 24 | /// </summary> |
||
- | 25 | /// <remarks> |
||
- | 26 | /// Required to allow the form to determine the current foreground window before being displayed |
||
- | 27 | /// </remarks> |
||
- | 28 | public new void Show() |
||
- | 29 | { |
||
- | 30 | // Determine the current foreground window so it can be reactivated each time this form tries to get the focus |
||
- | 31 | _currentForegroundWindow = NativeMethods.GetForegroundWindow(); |
||
- | 32 | |
||
Line 15... | Line 33... | |||
15 | |
33 | base.Show(); |
|
Line 16... | Line 34... | |||
16 | private static readonly List<Notification> OpenNotifications = new List<Notification>(); |
34 | } |
|
Line 25... | Line 43... | |||
25 | /// <param name="body"></param> |
43 | /// <param name="body"></param> |
|
26 | /// <param name="duration"></param> |
44 | /// <param name="duration"></param> |
|
27 | /// <param name="image"></param> |
45 | /// <param name="image"></param> |
|
28 | /// <param name="animation"></param> |
46 | /// <param name="animation"></param> |
|
29 | /// <param name="direction"></param> |
47 | /// <param name="direction"></param> |
|
30 | public Notification(string title, string body, int duration, Image logo, Image background, |
48 | public ToastForm(string title, string body, int duration, Image logo, Image background, |
|
31 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) |
49 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) |
|
32 | { |
50 | { |
|
33 | InitializeComponent(); |
51 | InitializeComponent(); |
|
Line 34... | Line 52... | |||
34 | |
52 | |
|
Line 41... | Line 59... | |||
41 | _animator = new FormAnimator(this, animation, direction, 500); |
59 | _animator = new FormAnimator(this, animation, direction, 500); |
|
Line 42... | Line 60... | |||
42 | |
60 | |
|
43 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
61 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
Line -... | Line 62... | |||
- | 62 | } |
||
- | 63 | |
||
44 | } |
64 | public ToastForm(string title, string body, int duration, Image logo, |
|
- | 65 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) |
||
Line -... | Line 66... | |||
- | 66 | { |
||
- | 67 | InitializeComponent(); |
||
- | 68 | |
||
45 | |
69 | lifeTimer.Interval = duration; |
|
Line 46... | Line -... | |||
46 | #endregion |
- | ||
47 | |
70 | labelTitle.Text = title; |
|
48 | #region Public Methods |
- | ||
49 | |
- | ||
- | 71 | labelBody.Text = body; |
||
50 | /// <summary> |
72 | imageBox.Image = logo; |
|
51 | /// Displays the form |
73 | |
|
- | 74 | _animator = new FormAnimator(this, animation, direction, 500); |
||
52 | /// </summary> |
75 | |
|
53 | /// <remarks> |
76 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
54 | /// Required to allow the form to determine the current foreground window before being displayed |
- | ||
55 | /// </remarks> |
77 | } |
|
Line -... | Line 78... | |||
- | 78 | |
||
- | 79 | public ToastForm(string title, string body, int duration, Image logo) |
||
- | 80 | { |
||
- | 81 | InitializeComponent(); |
||
- | 82 | |
||
- | 83 | lifeTimer.Interval = duration; |
||
56 | public new void Show() |
84 | labelTitle.Text = title; |
|
- | 85 | labelBody.Text = body; |
||
- | 86 | imageBox.Image = logo; |
||
57 | { |
87 | |
|
Line 58... | Line 88... | |||
58 | // Determine the current foreground window so it can be reactivated each time this form tries to get the focus |
88 | _animator = new FormAnimator(this, FormAnimator.AnimationMethod.Slide, FormAnimator.AnimationDirection.Up, |
|
Line 59... | Line 89... | |||
59 | _currentForegroundWindow = NativeMethods.GetForegroundWindow(); |
89 | 500); |