OptimizeButton.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using PicView.Animations;
  2. using PicView.ImageHandling;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. using static PicView.Animations.MouseOverAnimations;
  6. namespace PicView.Views.UserControls.Buttons;
  7. /// <summary>
  8. /// Interaction logic for OptimizeButton.xaml
  9. /// </summary>
  10. public partial class OptimizeButton : UserControl
  11. {
  12. public OptimizeButton()
  13. {
  14. InitializeComponent();
  15. Loaded += delegate
  16. {
  17. var IconBrush = (SolidColorBrush)Resources["IconBrush"];
  18. TheButton.PreviewMouseLeftButtonDown += delegate
  19. {
  20. ButtonMouseOverAnim(IconBrush, false, true);
  21. ButtonMouseOverAnim(ButtonBrush, false, true);
  22. AnimationHelper.MouseEnterBgTexColor(ButtonBrush);
  23. };
  24. TheButton.MouseEnter += delegate
  25. {
  26. ButtonMouseOverAnim(IconBrush);
  27. AnimationHelper.MouseEnterBgTexColor(ButtonBrush);
  28. };
  29. TheButton.MouseLeave += delegate
  30. {
  31. ButtonMouseLeaveAnim(IconBrush);
  32. AnimationHelper.MouseLeaveBgTexColor(ButtonBrush);
  33. };
  34. TheButton.Click += async (_, _) => await ImageFunctions.OptimizeImageAsyncWithErrorChecking().ConfigureAwait(false);
  35. };
  36. }
  37. }