SettingsMenu.axaml.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Avalonia;
  2. using Avalonia.Media;
  3. using PicView.Avalonia.CustomControls;
  4. using PicView.Avalonia.UI;
  5. namespace PicView.Avalonia.Views.UC.Menus;
  6. public partial class SettingsMenu : AnimatedMenu
  7. {
  8. public SettingsMenu()
  9. {
  10. InitializeComponent();
  11. Loaded += (_, _) =>
  12. {
  13. if (Settings.Theme.GlassTheme || !Settings.Theme.Dark)
  14. {
  15. UIHelper.SwitchHoverBorderClass(SettingsButton);
  16. UIHelper.SwitchHoverBorderClass(AboutWindowButton);
  17. }
  18. if (!Settings.Theme.Dark && !Settings.Theme.GlassTheme)
  19. {
  20. TopBorder.Background = Brushes.White;
  21. UIHelper.SwitchHoverClass(StretchButton);
  22. UIHelper.SwitchHoverClass(ScrollButton);
  23. UIHelper.SwitchHoverClass(LoopingButton);
  24. UIHelper.SwitchHoverClass(AutofitButton);
  25. UIHelper.SwitchHoverClass(TopMostButton);
  26. UIHelper.SwitchHoverClass(SubDirButton);
  27. }
  28. };
  29. if (TryGetResource("ScrollingBrush", Application.Current.RequestedThemeVariant,
  30. out var scrollingBrush))
  31. {
  32. if (scrollingBrush is SolidColorBrush brush)
  33. {
  34. UIHelper.SetButtonHover(ScrollButton, brush);
  35. }
  36. }
  37. if (TryGetResource("StretchBrush", Application.Current.RequestedThemeVariant,
  38. out var stretchBrush))
  39. {
  40. if (stretchBrush is SolidColorBrush brush)
  41. {
  42. UIHelper.SetButtonHover(StretchButton, brush);
  43. }
  44. }
  45. if (TryGetResource("LoopingBrush", Application.Current.RequestedThemeVariant,
  46. out var loopingBrush))
  47. {
  48. if (loopingBrush is SolidColorBrush brush)
  49. {
  50. UIHelper.SetButtonHover(LoopingButton, brush);
  51. }
  52. }
  53. if (TryGetResource("AutofitBrush", Application.Current.RequestedThemeVariant,
  54. out var autofitBrush))
  55. {
  56. if (autofitBrush is SolidColorBrush brush)
  57. {
  58. UIHelper.SetButtonHover(AutofitButton, brush);
  59. }
  60. }
  61. if (TryGetResource("TopMostBrush", Application.Current.RequestedThemeVariant,
  62. out var topMostBrush))
  63. {
  64. if (topMostBrush is SolidColorBrush brush)
  65. {
  66. UIHelper.SetButtonHover(TopMostButton, brush);
  67. }
  68. }
  69. if (TryGetResource("SubDirBrush", Application.Current.RequestedThemeVariant,
  70. out var subDirBrush))
  71. {
  72. if (subDirBrush is SolidColorBrush brush)
  73. {
  74. UIHelper.SetButtonHover(SubDirButton, brush);
  75. }
  76. }
  77. }
  78. }