Toasts – Diff between revs 16 and 18
?pathlinks?
Rev 16 | Rev 18 | |||
---|---|---|---|---|
Line 68... | Line 68... | |||
68 | memoryStream.Position = 0L; |
68 | memoryStream.Position = 0L; |
|
Line 69... | Line 69... | |||
69 | |
69 | |
|
70 | _sound = memoryStream.ToArray(); |
70 | _sound = memoryStream.ToArray(); |
|
Line -... | Line 71... | |||
- | 71 | } |
||
- | 72 | |
||
71 | } |
73 | _showFormTaskCompletionSource = new TaskCompletionSource<object>(); |
|
72 | |
74 | |
|
73 | _toastTimer = new System.Timers.Timer(); |
75 | _toastTimer = new System.Timers.Timer(); |
|
74 | _toastTimer.Elapsed += ToastTimer_Elapsed; |
76 | _toastTimer.Elapsed += ToastTimer_Elapsed; |
|
Line 181... | Line 183... | |||
181 | /// <param name="body">the toast body</param> |
183 | /// <param name="body">the toast body</param> |
|
182 | /// <param name="duration">the duration in milliseconds to display the toast on screen for</param> |
184 | /// <param name="duration">the duration in milliseconds to display the toast on screen for</param> |
|
183 | /// <param name="logo">the toast logo</param> |
185 | /// <param name="logo">the toast logo</param> |
|
184 | public ToastForm(string title, string body, int duration, Icon logo) : this() |
186 | public ToastForm(string title, string body, int duration, Icon logo) : this() |
|
185 | { |
187 | { |
|
- | 188 | _toastTimer.Enabled = true; |
||
186 | _toastTimer.Interval = duration; |
189 | _toastTimer.Interval = duration; |
|
187 | labelTitle.Text = title; |
190 | labelTitle.Text = title; |
|
188 | labelBody.Text = body; |
191 | labelBody.Text = body; |
|
189 | imageBox.Image = logo.ToBitmap(); |
192 | imageBox.Image = logo.ToBitmap(); |
|
190 | } |
193 | } |
|
Line 219... | Line 222... | |||
219 | private System.Timers.Timer _toastTimer; |
222 | private System.Timers.Timer _toastTimer; |
|
Line 220... | Line 223... | |||
220 | |
223 | |
|
Line 221... | Line 224... | |||
221 | private readonly int _screenWidth; |
224 | private readonly int _screenWidth; |
|
- | 225 | |
||
Line 222... | Line 226... | |||
222 | |
226 | private readonly int _screenHeight; |
|
Line 223... | Line 227... | |||
223 | private readonly int _screenHeight; |
227 | private readonly TaskCompletionSource<object> _showFormTaskCompletionSource; |
|
Line 335... | Line 339... | |||
335 | break; |
339 | break; |
|
336 | case FormAnimator.AnimationDirection.Right: |
340 | case FormAnimator.AnimationDirection.Right: |
|
337 | _formAnimator.Direction = FormAnimator.AnimationDirection.Left; |
341 | _formAnimator.Direction = FormAnimator.AnimationDirection.Left; |
|
338 | break; |
342 | break; |
|
339 | } |
343 | } |
|
- | 344 | |
||
- | 345 | _showFormTaskCompletionSource.TrySetResult(new { }); |
||
340 | } |
346 | } |
|
Line 341... | Line 347... | |||
341 | |
347 | |
|
342 | private void ToastTimer_Elapsed(object sender, EventArgs e) |
348 | private async void ToastTimer_Elapsed(object sender, EventArgs e) |
|
- | 349 | { |
||
- | 350 | await _showFormTaskCompletionSource.Task; |
||
343 | { |
351 | |
|
344 | if (IsDisposed) |
352 | if (IsDisposed) |
|
345 | { |
353 | { |
|
346 | return; |
354 | return; |