Skip to content

Commit aeca985

Browse files
committed
up macos问题
1 parent 1c60874 commit aeca985

10 files changed

Lines changed: 79 additions & 40 deletions

File tree

src/ColorMC.Gui/App.axaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public App()
2929
Logs.Error(temp, e.ExceptionObject as Exception);
3030
WindowManager.ShowError(LangUtils.Get("App.Text103"), temp, e.ExceptionObject as Exception);
3131
};
32-
ColorMCGui.StartLock();
32+
if (ColorMCGui.RunType == RunType.Program)
33+
{
34+
ColorMCGui.StartLock();
35+
}
3336
}
3437

3538
/// <summary>

src/ColorMC.Gui/ColorMC.Gui.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@
453453
<EmbeddedResource Include="Resource\Pic\launch.png" />
454454
<EmbeddedResource Include="Resource\Pic\load.png" />
455455
<EmbeddedResource Include="Resource\Pic\update1.png" />
456+
<None Remove="Resource\Icon\Window\ArrowCollapse.svg" />
457+
<AvaloniaResource Include="Resource\Icon\Window\ArrowCollapse.svg" />
458+
<None Remove="Resource\Icon\Window\ArrowExpand.svg" />
459+
<AvaloniaResource Include="Resource\Icon\Window\ArrowExpand.svg" />
456460
</ItemGroup>
457461
<ItemGroup>
458462
<!--This helps with theme dll-s trimming.

src/ColorMC.Gui/ColorMCGui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public static AppBuilder BuildAvaloniaApp()
334334
{
335335
if (RunType == RunType.AppBuilder)
336336
{
337-
BaseDir = AppContext.BaseDirectory + "colormc\\";
337+
BaseDir = AppContext.BaseDirectory + "colormc" + Path.DirectorySeparatorChar;
338338

339339
SystemInfo.Init();
340340
GuiConfigUtils.Init();

src/ColorMC.Gui/Manager/ImageManager.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ public static WindowIcon WindowIcon
9595
/// <summary>
9696
/// 最大化最小化图标
9797
/// </summary>
98-
public static readonly string[] MaxIcon = ["/Resource/Icon/Window/Maximize.svg", "/Resource/Icon/Window/Restore.svg"];
98+
public static readonly string[] MaxWindowsIcon = ["/Resource/Icon/Window/Maximize.svg", "/Resource/Icon/Window/Restore.svg"];
99+
/// <summary>
100+
/// Macos最大化最小化图标
101+
/// </summary>
102+
public static readonly string[] MaxMacosIcon = ["/Resource/Icon/Window/ArrowExpand.svg", "/Resource/Icon/Window/ArrowCollapse.svg"];
99103
/// <summary>
100104
/// 表情图标
101105
/// </summary>
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

src/ColorMC.Gui/UI/Controls/HeadControl/MacosHeadControl.axaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</Button>
5252
</StackPanel>
5353
<Panel>
54-
<StackPanel>
54+
<StackPanel Orientation="Horizontal">
5555
<Button
5656
Name="ButtonClose"
5757
Width="13"
@@ -63,37 +63,37 @@
6363
BorderThickness="0"
6464
Classes="none"
6565
Command="{Binding CloseClick}"
66-
CornerRadius="0"
66+
CornerRadius="20"
6767
IsEnabled="{Binding HeadCloseEnable}">
68-
<svg:SvgControl Name="Img3" Path="/Resource/Icon/Head/Close.svg" />
68+
<svg:SvgControl IsVisible="False" Width="9" Name="Img3" Path="/Resource/Icon/Window/Close.svg" />
6969
</Button>
7070
<Button
7171
Name="ButtonMin"
7272
Width="13"
7373
Height="13"
74-
Margin="10,0,0,0"
74+
Margin="6,0,0,0"
7575
VerticalAlignment="Center"
7676
Background="Transparent"
7777
BorderBrush="Transparent"
7878
BorderThickness="0"
7979
Classes="none"
8080
Command="{Binding MinimizeClick}"
81-
CornerRadius="0">
82-
<svg:SvgControl Name="Img1" Path="/Resource/Icon/Head/Minimize.svg" />
81+
CornerRadius="20">
82+
<svg:SvgControl IsVisible="False" Width="9" Name="Img1" Path="/Resource/Icon/Window/Minimize.svg" />
8383
</Button>
8484
<Button
8585
Name="ButtonMax"
8686
Width="13"
8787
Height="13"
88-
Margin="10,0,0,0"
88+
Margin="6,0,0,0"
8989
VerticalAlignment="Center"
9090
Background="Transparent"
9191
BorderBrush="Transparent"
9292
BorderThickness="0"
9393
Classes="none"
9494
Command="{Binding MaximizeClick}"
95-
CornerRadius="0">
96-
<svg:SvgControl Name="Img2" Path="{Binding MaxIcon}" />
95+
CornerRadius="20">
96+
<svg:SvgControl IsVisible="False" Width="9" Name="Img2" Path="{Binding MaxIcon}" />
9797
</Button>
9898
</StackPanel>
9999
</Panel>

src/ColorMC.Gui/UI/Controls/HeadControl/MacosHeadControl.axaml.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Avalonia.Controls;
2+
using Avalonia.Input;
23
using Avalonia.Media;
34
using Avalonia.Threading;
45
using ColorMC.Gui.Manager;
@@ -9,7 +10,7 @@ namespace ColorMC.Gui.UI.Controls.HeadControl;
910
public 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
}

src/ColorMC.Gui/UI/Model/WindowModel.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Avalonia.Controls;
55
using Avalonia.Media.Imaging;
66
using Avalonia.Styling;
7+
using ColorMC.Core.Objs;
8+
using ColorMC.Core.Utils;
79
using ColorMC.Gui.Manager;
810
using ColorMC.Gui.UI.Model.Dialog;
911
using ColorMC.Gui.Utils;
@@ -91,7 +93,7 @@ public partial class WindowModel : ObservableObject
9193
/// 最大化图标
9294
/// </summary>
9395
[ObservableProperty]
94-
private string _maxIcon = ImageManager.MaxIcon[0];
96+
private string _maxIcon;
9597

9698
/// <summary>
9799
/// 是否显示背景图
@@ -203,6 +205,15 @@ public WindowModel()
203205
public WindowModel(string name)
204206
{
205207
WindowId = name;
208+
209+
if (SystemInfo.Os == OsType.MacOS)
210+
{
211+
MaxIcon = ImageManager.MaxMacosIcon[0];
212+
}
213+
else
214+
{
215+
MaxIcon = ImageManager.MaxWindowsIcon[0];
216+
}
206217
}
207218

208219
[RelayCommand]

src/ColorMC.Gui/UI/Windows/AMultiWindow.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Avalonia.Media;
99
using Avalonia.Media.Imaging;
1010
using Avalonia.Threading;
11+
using ColorMC.Core.Objs;
12+
using ColorMC.Core.Utils;
1113
using ColorMC.Gui.Manager;
1214
using ColorMC.Gui.UI.Controls;
1315
using ColorMC.Gui.UI.Controls.Error;
@@ -157,19 +159,23 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
157159
/// <param name="e"></param>
158160
private void AMultiWindow_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
159161
{
160-
if (e.Property == WindowStateProperty)
162+
if (e.Property != WindowStateProperty)
161163
{
162-
if (DataContext is WindowModel model)
163-
{
164-
if (WindowState == WindowState.Maximized)
165-
{
166-
model.MaxIcon = ImageManager.MaxIcon[1];
167-
}
168-
else
169-
{
170-
model.MaxIcon = ImageManager.MaxIcon[0];
171-
}
172-
}
164+
return;
165+
}
166+
167+
if (DataContext is not WindowModel model)
168+
{
169+
return;
170+
}
171+
172+
if (WindowState == WindowState.Maximized)
173+
{
174+
model.MaxIcon = SystemInfo.Os == OsType.MacOS ? ImageManager.MaxMacosIcon[1] : ImageManager.MaxWindowsIcon[1];
175+
}
176+
else
177+
{
178+
model.MaxIcon = SystemInfo.Os == OsType.MacOS ? ImageManager.MaxMacosIcon[0] :ImageManager.MaxWindowsIcon[0];
173179
}
174180
}
175181

0 commit comments

Comments
 (0)