2024-09-01 01:54:20 -07:00
|
|
|
using Avalonia;
|
2024-02-05 23:08:37 -08:00
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Avalonia.VisualTree;
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class CaptionButtonsMacOS : UserControl
|
|
|
|
{
|
2024-09-01 01:54:20 -07:00
|
|
|
public static readonly StyledProperty<bool> IsCloseButtonOnlyProperty =
|
|
|
|
AvaloniaProperty.Register<CaptionButtonsMacOS, bool>(nameof(IsCloseButtonOnly));
|
|
|
|
|
|
|
|
public bool IsCloseButtonOnly
|
|
|
|
{
|
|
|
|
get => GetValue(IsCloseButtonOnlyProperty);
|
|
|
|
set => SetValue(IsCloseButtonOnlyProperty, value);
|
|
|
|
}
|
2024-09-02 05:27:12 -07:00
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
public CaptionButtonsMacOS()
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
2024-08-06 00:12:44 -07:00
|
|
|
private void MinimizeWindow(object _, RoutedEventArgs e)
|
2024-03-17 18:37:06 -07:00
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var window = this.FindAncestorOfType<Window>();
|
2024-03-17 18:37:06 -07:00
|
|
|
if (window != null)
|
2024-02-05 23:08:37 -08:00
|
|
|
window.WindowState = WindowState.Minimized;
|
2024-08-06 00:12:44 -07:00
|
|
|
|
|
|
|
e.Handled = true;
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
|
|
|
|
2024-08-06 00:12:44 -07:00
|
|
|
private void MaximizeOrRestoreWindow(object _, RoutedEventArgs e)
|
2024-03-17 18:37:06 -07:00
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var window = this.FindAncestorOfType<Window>();
|
2024-03-17 18:37:06 -07:00
|
|
|
if (window != null)
|
2024-02-05 23:08:37 -08:00
|
|
|
window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
2024-08-06 00:12:44 -07:00
|
|
|
|
|
|
|
e.Handled = true;
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
|
|
|
|
2024-08-06 00:12:44 -07:00
|
|
|
private void CloseWindow(object _, RoutedEventArgs e)
|
2024-03-17 18:37:06 -07:00
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var window = this.FindAncestorOfType<Window>();
|
2024-09-01 01:54:20 -07:00
|
|
|
window?.Close();
|
2024-08-06 00:12:44 -07:00
|
|
|
e.Handled = true;
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
}
|