GalleryShortcut.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. using System.Windows.Media.Animation;
  6. namespace PicView.UserControls
  7. {
  8. /// <summary>
  9. /// Cool shady close button!
  10. /// </summary>
  11. public partial class GalleryShortcut : UserControl
  12. {
  13. private static ColorAnimation ccAnim;
  14. private static ColorAnimation ccAnim2;
  15. private static Color bb;
  16. private static Color bg;
  17. private static Color bg2;
  18. private static Color fg;
  19. public GalleryShortcut()
  20. {
  21. InitializeComponent();
  22. bb = (Color)Application.Current.Resources["BorderColor"];
  23. bg = (Color)Application.Current.Resources["AltInterface"];
  24. bg2 = (Color)Application.Current.Resources["AltInterfaceW"];
  25. fg = (Color)Application.Current.Resources["MainColor"];
  26. PreviewMouseLeftButtonDown += (sender, e) =>
  27. {
  28. if (ccAnim == null)
  29. {
  30. ccAnim = new ColorAnimation
  31. {
  32. Duration = TimeSpan.FromSeconds(.32)
  33. };
  34. }
  35. var alpha = AnimationHelper.GetPrefferedColorOver();
  36. ccAnim.From = alpha;
  37. ccAnim.To = AnimationHelper.GetPrefferedColorDown();
  38. ImagePath1Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  39. ImagePath2Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  40. ImagePath3Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  41. AnimationHelper.MouseEnterColorEvent(alpha.A, alpha.R, alpha.G, alpha.B, BorderBrushKey, true);
  42. };
  43. MouseEnter += (sender, e) =>
  44. {
  45. if (ccAnim == null)
  46. {
  47. ccAnim = new ColorAnimation
  48. {
  49. Duration = TimeSpan.FromSeconds(.32)
  50. };
  51. ccAnim2 = new ColorAnimation
  52. {
  53. Duration = TimeSpan.FromSeconds(.2)
  54. };
  55. }
  56. ccAnim.From = fg;
  57. ccAnim.To = AnimationHelper.GetPrefferedColorOver();
  58. ImagePath1Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  59. ImagePath2Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  60. ImagePath3Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  61. ccAnim2.From = bg;
  62. ccAnim2.To = bg2;
  63. CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2);
  64. AnimationHelper.MouseEnterColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true);
  65. };
  66. MouseLeave += (sender, e) =>
  67. {
  68. if (ccAnim == null)
  69. {
  70. ccAnim = new ColorAnimation
  71. {
  72. Duration = TimeSpan.FromSeconds(.32)
  73. };
  74. ccAnim2 = new ColorAnimation
  75. {
  76. Duration = TimeSpan.FromSeconds(.2)
  77. };
  78. }
  79. ccAnim.From = AnimationHelper.GetPrefferedColorOver();
  80. ccAnim.To = fg;
  81. ImagePath1Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  82. ImagePath2Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  83. ImagePath3Fill.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim);
  84. ccAnim2.From = bg2;
  85. ccAnim2.To = bg;
  86. CanvasBGcolor.BeginAnimation(SolidColorBrush.ColorProperty, ccAnim2);
  87. AnimationHelper.MouseLeaveColorEvent(bb.A, bb.R, bb.G, bb.B, BorderBrushKey, true);
  88. };
  89. }
  90. }
  91. }