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-03-31 01:54:29 -07:00
|
|
|
|
public static readonly 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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-03-31 01:54:29 -07:00
|
|
|
|
public static readonly 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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-03-31 01:54:29 -07:00
|
|
|
|
public static readonly 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
|
|
|
|
|
2024-03-31 01:54:29 -07:00
|
|
|
|
public static readonly FuncValueConverter<WindowState, bool> IsNormal =
|
2024-03-28 21:15:52 -07:00
|
|
|
|
new FuncValueConverter<WindowState, bool>(state => state == WindowState.Normal);
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|