11using Avalonia . Controls ;
2+ using Avalonia . Input ;
23using Avalonia . Media ;
34using Avalonia . Threading ;
45using ColorMC . Gui . Manager ;
@@ -9,7 +10,7 @@ namespace ColorMC.Gui.UI.Controls.HeadControl;
910public partial class MacosHeadControl : UserControl
1011{
1112 /// <summary>
12- /// ˛ËľĽ°´ĹĽ
13+ /// 菜单按钮
1314 /// </summary>
1415 private class ButtonBack
1516 {
@@ -26,14 +27,7 @@ public ButtonBack(Button button, IBrush basecolor)
2627
2728 public void SetColor ( bool hide )
2829 {
29- if ( hide )
30- {
31- _button . Background = ThemeManager . GetColor ( nameof ( ThemeObj . ProgressBarBG ) ) ;
32- }
33- else
34- {
35- _button . Background = _color ;
36- }
30+ _button . Background = hide ? ThemeManager . GetColor ( nameof ( ThemeObj . ProgressBarBG ) ) : _color ;
3731 }
3832 }
3933
@@ -44,16 +38,16 @@ public MacosHeadControl()
4438 InitializeComponent ( ) ;
4539
4640 var select1 = new ButtonBack ( ButtonMin , Brush . Parse ( "#febb2c" ) ) ;
47- ButtonMin . PointerEntered += ( a , b ) => { Img1 . IsVisible = true ; } ;
48- ButtonMin . PointerExited += ( a , b ) => { Img1 . IsVisible = false ; } ;
41+ ButtonMin . PointerEntered += ButtonMinOnPointerEntered ;
42+ ButtonMin . PointerExited += ButtonMinOnPointerExited ;
4943
5044 var select2 = new ButtonBack ( ButtonMax , Brush . Parse ( "#29c73f" ) ) ;
51- ButtonMax . PointerEntered += ( a , b ) => { Img2 . IsVisible = true ; } ;
52- ButtonMax . PointerExited += ( a , b ) => { Img2 . IsVisible = false ; } ;
45+ ButtonMax . PointerEntered += ButtonMinOnPointerEntered ;
46+ ButtonMax . PointerExited += ButtonMinOnPointerExited ;
5347
5448 var select3 = new ButtonBack ( ButtonClose , Brush . Parse ( "#fe5f59" ) ) ;
55- ButtonClose . PointerEntered += ( a , b ) => { Img3 . IsVisible = true ; } ;
56- ButtonClose . PointerExited += ( a , b ) => { Img3 . IsVisible = false ; } ;
49+ ButtonClose . PointerEntered += ButtonMinOnPointerEntered ;
50+ ButtonClose . PointerExited += ButtonMinOnPointerExited ;
5751
5852 PointerEntered += ( a , b ) =>
5953 {
@@ -97,4 +91,19 @@ public MacosHeadControl()
9791 }
9892 } ) ;
9993 }
94+
95+ private void ButtonMinOnPointerExited ( object ? sender , PointerEventArgs e )
96+ {
97+ Image ( false ) ;
98+ }
99+
100+ private void ButtonMinOnPointerEntered ( object ? sender , PointerEventArgs e )
101+ {
102+ Image ( true ) ;
103+ }
104+
105+ private void Image ( bool show )
106+ {
107+ Img1 . IsVisible = Img2 . IsVisible = Img3 . IsVisible = show ;
108+ }
100109}
0 commit comments