Toasts – Diff between revs 10 and 11
?pathlinks?
Rev 10 | Rev 11 | |||
---|---|---|---|---|
Line 5... | Line 5... | |||
5 | using System; |
5 | using System; |
|
6 | using System.Collections.Generic; |
6 | using System.Collections.Generic; |
|
7 | using System.Drawing; |
7 | using System.Drawing; |
|
8 | using System.IO; |
8 | using System.IO; |
|
9 | using System.Media; |
9 | using System.Media; |
|
10 | using System.Reflection; |
- | ||
11 | using System.Threading.Tasks; |
- | ||
12 | using System.Windows.Forms; |
10 | using System.Windows.Forms; |
|
- | 11 | using Toasts.Properties; |
||
Line 13... | Line 12... | |||
13 | |
12 | |
|
14 | namespace Toasts |
13 | namespace Toasts |
|
15 | { |
14 | { |
|
16 | public partial class ToastForm : Form |
15 | public partial class ToastForm : Form |
|
Line 39... | Line 38... | |||
39 | |
38 | |
|
Line 40... | Line 39... | |||
40 | #endregion |
39 | #endregion |
|
Line 41... | Line 40... | |||
41 | |
40 | |
|
42 | #region Constructors, Destructors and Finalizers |
41 | #region Constructors, Destructors and Finalizers |
|
43 | |
42 | |
|
44 | private ToastForm() |
43 | private ToastForm() |
|
45 | { |
44 | { |
|
46 | InitializeComponent(); |
45 | InitializeComponent(); |
|
47 | } |
46 | } |
|
48 | |
47 | |
|
49 | /// <summary> |
48 | /// <summary> |
|
50 | /// </summary> |
49 | /// </summary> |
|
Line 125... | Line 124... | |||
125 | |
124 | |
|
126 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
125 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
Line 127... | Line 126... | |||
127 | } |
126 | } |
|
128 | |
127 | |
|
129 | /// <summary> |
128 | /// <summary> |
|
130 | /// Clean up any resources being used. |
129 | /// Clean up any resources being used. |
|
131 | /// </summary> |
130 | /// </summary> |
|
132 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
131 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
|
133 | protected override void Dispose(bool disposing) |
132 | protected override void Dispose(bool disposing) |
|
134 | { |
- | ||
135 | if (disposing && (components != null)) |
- | ||
136 | { |
- | ||
137 | components.Dispose(); |
133 | { |
|
138 | } |
134 | if (disposing && components != null) components.Dispose(); |
|
Line 139... | Line 135... | |||
139 | base.Dispose(disposing); |
135 | base.Dispose(disposing); |
|
Line 157... | Line 153... | |||
157 | |
153 | |
|
158 | private void Notification_Load(object sender, EventArgs e) |
154 | private void Notification_Load(object sender, EventArgs e) |
|
159 | { |
155 | { |
|
160 | // Play the sound. |
156 | // Play the sound. |
|
161 | if (_sound == null) |
- | ||
162 | { |
157 | if (_sound == null) |
|
163 | using (var memoryStream = new MemoryStream()) |
158 | using (var memoryStream = new MemoryStream()) |
|
164 | { |
159 | { |
|
Line 165... | Line 160... | |||
165 | Properties.Resources.normal.CopyTo(memoryStream); |
160 | Resources.normal.CopyTo(memoryStream); |
|
Line 166... | Line 161... | |||
166 | |
161 | |
|
167 | memoryStream.Position = 0L; |
162 | memoryStream.Position = 0L; |
|
168 | |
- | ||
Line 169... | Line 163... | |||
169 | _sound = memoryStream.ToArray(); |
163 | |
|
170 | } |
164 | _sound = memoryStream.ToArray(); |
|
171 | } |
165 | } |
|
172 | |
166 | |
|
Line 202... | Line 196... | |||
202 | |
196 | |
|
203 | private void Notification_Activated(object sender, EventArgs e) |
197 | private void Notification_Activated(object sender, EventArgs e) |
|
204 | { |
198 | { |
|
205 | // Prevent the form taking focus when it is initially shown |
199 | // Prevent the form taking focus when it is initially shown |
|
206 | if (!_allowFocus) |
- | ||
207 | { |
200 | if (!_allowFocus) |
|
208 | // Activate the window that previously had focus |
201 | // Activate the window that previously had focus |
|
209 | NativeMethods.SetForegroundWindow(_currentForegroundWindow); |
- | ||
210 | } |
202 | NativeMethods.SetForegroundWindow(_currentForegroundWindow); |
|
Line 211... | Line 203... | |||
211 | } |
203 | } |
|
212 | |
204 | |
|
213 | private void Notification_Shown(object sender, EventArgs e) |
205 | private void Notification_Shown(object sender, EventArgs e) |
|
Line 231... | Line 223... | |||
231 | |
223 | |
|
232 | if (openForm.InvokeRequired) |
224 | if (openForm.InvokeRequired) |
|
233 | { |
225 | { |
|
234 | Action action = delegate { openForm.Top += Height; }; |
226 | Action action = delegate { openForm.Top += Height; }; |
|
235 | openForm.Invoke(action); |
- | ||
236 | |
- | ||
237 | continue; |
227 | openForm.Invoke(action); |
|
238 | } |
228 | } |
|
Line 239... | Line 229... | |||
239 | } |
229 | } |
|
240 | |
230 | |