sourcegit/src/Views/CaptionButtons.axaml.cs
2024-08-06 15:12:44 +08:00

41 lines
1.1 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace SourceGit.Views
{
public partial class CaptionButtons : UserControl
{
public CaptionButtons()
{
InitializeComponent();
}
private void MinimizeWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
if (window != null)
window.WindowState = WindowState.Minimized;
e.Handled = true;
}
private void MaximizeOrRestoreWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
if (window != null)
window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
e.Handled = true;
}
private void CloseWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
if (window != null)
window.Close();
e.Handled = true;
}
}
}