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