first commit

This commit is contained in:
Beyhan Oğur
2026-09-03 04:45:36 +03:00
commit d5f52cc3d3
1038 changed files with 169579 additions and 0 deletions
@@ -0,0 +1,80 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
namespace ClassicAssist.UI.Misc
{
public enum WindowCommand
{
Minimize,
Maximize,
Close
}
public class WindowCommandBehaviour : Behavior<Button>
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register( "Command",
typeof( WindowCommand ), typeof( WindowCommandBehaviour ),
new FrameworkPropertyMetadata( WindowCommand.Close ) );
public WindowCommand Command
{
get => (WindowCommand) GetValue( CommandProperty );
set => SetValue( CommandProperty, value );
}
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Click += OnClick;
}
private void OnClick( object sender, RoutedEventArgs e )
{
if ( !( sender is UIElement element ) )
{
return;
}
Window window = Window.GetWindow( element );
if ( window == null )
{
return;
}
switch ( Command )
{
case WindowCommand.Minimize:
{
window.WindowState = WindowState.Minimized;
break;
}
case WindowCommand.Maximize:
{
window.WindowState = window.WindowState == WindowState.Maximized
? WindowState.Normal
: WindowState.Maximized;
break;
}
case WindowCommand.Close:
{
window.Close();
break;
}
default:
throw new ArgumentOutOfRangeException();
}
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.Click -= OnClick;
}
}
}