2024-02-05 23:08:37 -08:00
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Data.Converters;
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
using Avalonia;
|
2024-03-14 03:23:36 -07:00
|
|
|
|
using System;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
|
|
|
|
namespace SourceGit.Converters {
|
|
|
|
|
public static class WindowStateConverters {
|
|
|
|
|
public static FuncValueConverter<WindowState, Thickness> ToContentMargin =
|
|
|
|
|
new FuncValueConverter<WindowState, Thickness>(state => {
|
2024-03-14 03:23:36 -07:00
|
|
|
|
if (OperatingSystem.IsWindows() && state == WindowState.Maximized) {
|
|
|
|
|
return new Thickness(6);
|
|
|
|
|
} else if (OperatingSystem.IsLinux() && state != WindowState.Maximized) {
|
2024-02-05 23:08:37 -08:00
|
|
|
|
return new Thickness(6);
|
|
|
|
|
} else {
|
|
|
|
|
return new Thickness(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
public static FuncValueConverter<WindowState, GridLength> ToTitleBarHeight =
|
|
|
|
|
new FuncValueConverter<WindowState, GridLength>(state => {
|
2024-03-14 03:23:36 -07:00
|
|
|
|
if (state == WindowState.Maximized) {
|
2024-02-05 23:08:37 -08:00
|
|
|
|
return new GridLength(30);
|
|
|
|
|
} else {
|
|
|
|
|
return new GridLength(38);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
public static FuncValueConverter<WindowState, StreamGeometry> ToMaxOrRestoreIcon =
|
|
|
|
|
new FuncValueConverter<WindowState, StreamGeometry>(state => {
|
|
|
|
|
if (state == WindowState.Maximized) {
|
|
|
|
|
return Application.Current?.FindResource("Icons.Window.Restore") as StreamGeometry;
|
|
|
|
|
} else {
|
|
|
|
|
return Application.Current?.FindResource("Icons.Window.Maximize") as StreamGeometry;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|