Winify – Diff between revs 10 and 11
?pathlinks?
Rev 10 | Rev 11 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
2 | using System.Diagnostics; |
2 | using System.Diagnostics; |
|
3 | using System.Drawing; |
3 | using System.Drawing; |
|
4 | using System.IO; |
- | ||
5 | using System.Media; |
- | ||
6 | using System.Threading.Tasks; |
4 | using System.Threading.Tasks; |
|
7 | using System.Windows.Forms; |
5 | using System.Windows.Forms; |
|
8 | using Winify.Utilities; |
6 | using Winify.Utilities; |
|
Line 9... | Line 7... | |||
9 | |
7 | |
|
10 | namespace Winify |
8 | namespace Winify |
|
11 | { |
9 | { |
|
12 | public partial class NotificationForm : Form |
10 | public partial class NotificationForm : Form |
|
- | 11 | { |
||
- | 12 | #region Public Enums, Properties and Fields |
||
- | 13 | |
||
- | 14 | public int Index { get; } |
||
- | 15 | |
||
- | 16 | #endregion |
||
13 | { |
17 | |
|
Line -... | Line 18... | |||
- | 18 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
- | 19 | |
||
14 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
20 | private Point _displayLocation; |
|
Line 15... | Line 21... | |||
15 | |
21 | |
|
Line 16... | Line 22... | |||
16 | private Image _image; |
22 | private Image _image; |
|
Line 17... | Line 23... | |||
17 | |
23 | |
|
18 | #endregion |
24 | #endregion |
|
19 | |
25 | |
|
20 | #region Constructors, Destructors and Finalizers |
26 | #region Constructors, Destructors and Finalizers |
|
Line 21... | Line 27... | |||
21 | |
27 | |
|
22 | private NotificationForm() |
28 | public NotificationForm() |
|
- | 29 | { |
||
- | 30 | InitializeComponent(); |
||
23 | { |
31 | } |
|
Line 24... | Line 32... | |||
24 | InitializeComponent(); |
32 | |
|
Line 25... | Line 33... | |||
25 | } |
33 | public NotificationForm(int i, Image image, string title, string text, int milliseconds) : this() |
|
Line 35... | Line 43... | |||
35 | |
43 | |
|
36 | Task.Delay(milliseconds).ContinueWith(task => |
44 | Task.Delay(milliseconds).ContinueWith(task => |
|
37 | this.InvokeIfRequired(form => { form.Close(); })); |
45 | this.InvokeIfRequired(form => { form.Close(); })); |
|
Line 38... | Line -... | |||
38 | } |
- | ||
39 | |
- | ||
40 | public NotificationForm(Image image, string title, string text, Stream sound, int milliseconds) : this(image, |
- | ||
41 | title, text, |
- | ||
42 | milliseconds) |
- | ||
43 | { |
- | ||
44 | using (var soundPlayer = new SoundPlayer(sound)) |
- | ||
45 | { |
- | ||
46 | soundPlayer.Play(); |
- | ||
47 | } |
- | ||
48 | } |
46 | } |
|
49 | |
47 | |
|
50 | /// <summary> |
48 | /// <summary> |
|
51 | /// Clean up any resources being used. |
49 | /// Clean up any resources being used. |
|
52 | /// </summary> |
50 | /// </summary> |
|
Line 73... | Line 71... | |||
73 | |
71 | |
|
Line 74... | Line 72... | |||
74 | protected override bool ShowWithoutActivation => true; |
72 | protected override bool ShowWithoutActivation => true; |
|
75 | |
73 | |
|
76 | protected override void OnLoad(EventArgs e) |
74 | protected override void OnLoad(EventArgs e) |
|
77 | { |
- | ||
78 | var screen = Screen.FromPoint(Location); |
75 | { |
|
79 | Location = new Point(screen.WorkingArea.Right - Width, screen.WorkingArea.Bottom - Height); |
76 | Location = _displayLocation; |
|
Line 80... | Line 77... | |||
80 | base.OnLoad(e); |
77 | base.OnLoad(e); |
|
Line 107... | Line 104... | |||
107 | { |
104 | { |
|
108 | Process.Start(e.LinkText); |
105 | Process.Start(e.LinkText); |
|
109 | } |
106 | } |
|
Line 110... | Line 107... | |||
110 | |
107 | |
|
- | 108 | #endregion |
||
- | 109 | |
||
- | 110 | #region Public Methods |
||
- | 111 | |
||
- | 112 | public void UpdateLocation(int x, int y) |
||
- | 113 | { |
||
- | 114 | _displayLocation = new Point(x, y); |
||
- | 115 | } |
||
- | 116 | |
||
111 | #endregion |
117 | #endregion |
|
112 | } |
118 | } |
|
113 | } |
119 | } |