Toasts – Diff between revs 53 and 54

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 53 Rev 54
Line 32... Line 32...
32   32  
Line 33... Line 33...
33 public bool EnableChime { get; set; } = true; 33 public bool EnableChime { get; set; } = true;
Line 34... Line -...
34   -  
35 public int LingerTime { get; set; } = 5000; -  
36   -  
37 public FormAnimator.AnimationMethod AnimationMethodDetached { get; set; } = FormAnimator.AnimationMethod.Fade; -  
38   -  
39 public FormAnimator.AnimationDirection AnimationDirectionDetached { get; set; } = FormAnimator.AnimationDirection.None; -  
40   -  
41 public FormAnimator.AnimationMethod AnimationMethod { get; set; } = FormAnimator.AnimationMethod.Fade; -  
42   34  
Line 43... Line 35...
43 public FormAnimator.AnimationDirection AnimationDirection { get; set; } = FormAnimator.AnimationDirection.None; 35 public int LingerTime { get; set; } = 5000;
Line 44... Line 36...
44   36  
Line 119... Line 111...
119   111  
Line 120... Line 112...
120 private static HttpClient _httpClient = new HttpClient(); 112 private static HttpClient _httpClient = new HttpClient();
Line 121... Line -...
121   -  
122 private static object _httpClientDefaultRequestHeadersLock = new object(); -  
123   113  
Line 124... Line 114...
124 private FormAnimator _formAnimator; 114 private static object _httpClientDefaultRequestHeadersLock = new object();
Line 125... Line 115...
125   115  
Line 166... Line 156...
166   156  
Line 167... Line 157...
167 HandleCreated += ToastForm_HandleCreated; 157 HandleCreated += ToastForm_HandleCreated;
168   158  
169 _screenWidth = Screen.PrimaryScreen.WorkingArea.Width; -  
170 _screenHeight = Screen.PrimaryScreen.WorkingArea.Height; -  
171   159 _screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
Line 172... Line 160...
172 _formAnimator = new FormAnimator(this, AnimationMethod, AnimationDirection, AnimationDuration); 160 _screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
173 } 161 }
Line 363... Line 351...
363 } 351 }
Line 364... Line 352...
364   352  
365 // remove top-most 353 // remove top-most
Line 366... Line -...
366 SetWindowPos(Handle, -2, 0, 0, 0, 0, 0x0001 | 0x0002); -  
367   -  
368 _formAnimator.Method = AnimationMethodDetached; -  
369 _formAnimator.Direction = AnimationDirectionDetached; 354 SetWindowPos(Handle, -2, 0, 0, 0, 0, 0x0001 | 0x0002);
370   355  
Line 371... Line 356...
371 return; 356 return;
372 } 357 }
Line 381... Line 366...
381 continue; 366 continue;
382 } 367 }
Line 383... Line 368...
383   368  
384 openForm.InvokeIfRequired(form => 369 openForm.InvokeIfRequired(form =>
-   370 {
385 { 371 // if the form will end up off-screen, then don't even bother moving it
386 foreach (Screen screen in Screen.AllScreens) 372 foreach (Screen screen in Screen.AllScreens)
387 { 373 {
388 if (!screen.WorkingArea.Contains(new Rectangle(form.Left, form.Top - Height, form.Width, form.Height))) 374 if (!screen.WorkingArea.Contains(new Rectangle(form.Left, form.Top - Height, form.Width, form.Height)))
389 { 375 {
390 form.Close(); 376 form.Close();
-   377 OpenNotifications.Remove(form);
-   378  
391 OpenNotifications.Remove(form); 379 return;
392 } 380 }
-   381 }
393 } 382  
-   383 form.Top -= Height;
394 form.Top -= Height; 384  
395 }); 385 });
Line 396... Line 386...
396 } 386 }
397   387  
Line 447... Line 437...
447 { 437 {
448 OpenNotifications.Remove(this); 438 OpenNotifications.Remove(this);
449 } 439 }
450 } 440 }
Line 451... Line -...
451   -  
452 private async void ToastForm_Shown(object sender, EventArgs e) -  
453 { -  
454 // wait for window creation -  
455 await _handleCreatedTaskCompletionSource.Task; -  
456   -  
457 // Reverse animation direction for hiding. -  
458 switch (_formAnimator.Direction) -  
459 { -  
460 case FormAnimator.AnimationDirection.Up: -  
461 _formAnimator.Direction = FormAnimator.AnimationDirection.Down; -  
462 break; -  
463 case FormAnimator.AnimationDirection.Down: -  
464 _formAnimator.Direction = FormAnimator.AnimationDirection.Up; -  
465 break; -  
466 case FormAnimator.AnimationDirection.Left: -  
467 _formAnimator.Direction = FormAnimator.AnimationDirection.Right; -  
468 break; -  
469 case FormAnimator.AnimationDirection.Right: -  
470 _formAnimator.Direction = FormAnimator.AnimationDirection.Left; -  
471 break; -  
472 } -  
473   -  
474   -  
475 } -  
476   441  
477 private void ToastTimer_Elapsed(object sender, EventArgs e) 442 private void ToastTimer_Elapsed(object sender, EventArgs e)
478 { 443 {
479 if (IsDisposed) 444 if (IsDisposed)
480 { 445 {
Line 544... Line 509...
544 OpenNotifications.Remove(this); 509 OpenNotifications.Remove(this);
545 } 510 }
Line 546... Line 511...
546   511  
547 // remove top-most 512 // remove top-most
548 SetWindowPos(Handle, -2, 0, 0, 0, 0, 0x0001 | 0x0002); -  
549   -  
550 _formAnimator.Method = AnimationMethodDetached; -  
551 _formAnimator.Direction = AnimationDirectionDetached; 513 SetWindowPos(Handle, -2, 0, 0, 0, 0, 0x0001 | 0x0002);
552 } 514 }
Line 553... Line 515...
553 } 515 }
554   516