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,98 @@
using System.Linq;
using System.Windows;
using System.Windows.Input;
using ClassicAssist.Data.Hotkeys;
using Key = ClassicAssist.Misc.Key;
namespace ClassicAssist.UI.Controls
{
/// <inheritdoc cref="TextBox" />
/// <summary>
/// Interaction logic for TestBoxKey.xaml
/// </summary>
public partial class TextBoxKey
{
public static readonly DependencyProperty ShortcutProperty = DependencyProperty.Register( nameof( Shortcut ),
typeof( ShortcutKeys ), typeof( TextBoxKey ),
new FrameworkPropertyMetadata( default( ShortcutKeys ),
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault ) );
private readonly Key[] _modifiers =
{
Key.LeftCtrl, Key.RightCtrl, Key.LeftShift, Key.RightShift, Key.LeftAlt, Key.RightAlt
};
public TextBoxKey()
{
InitializeComponent();
}
public Key Key { get; private set; }
public Key Modifier { get; set; }
public object Shortcut
{
get => GetValue( ShortcutProperty );
set => SetValue( ShortcutProperty, value );
}
private Key CheckModifiers()
{
return _modifiers.FirstOrDefault( e => Keyboard.IsKeyDown( (System.Windows.Input.Key) e ) );
}
private bool IsModifier( Key key )
{
return _modifiers.Any( k => key == k );
}
private void TextBox_PreviewKeyDown( object sender, KeyEventArgs e )
{
e.Handled = true;
Key key = (Key) e.Key;
if ( key == Key.System )
{
key = (Key) e.SystemKey;
}
if ( IsModifier( key ) )
{
e.Handled = true;
return;
}
Modifier = CheckModifiers();
Key = key;
Shortcut = new ShortcutKeys { Modifier = Modifier, Key = Key };
}
private void UIElement_OnPreviewMouseDown( object sender, MouseButtonEventArgs e )
{
if ( ( e.ChangedButton == MouseButton.Left ) | ( e.ChangedButton == MouseButton.Right ) )
{
return;
}
e.Handled = true;
Modifier = CheckModifiers();
Shortcut = new ShortcutKeys { Mouse = (MouseOptions) e.ChangedButton };
}
private void UIElement_OnMouseWheel( object sender, MouseWheelEventArgs e )
{
e.Handled = true;
Modifier = CheckModifiers();
Shortcut = e.Delta < 0
? new ShortcutKeys { Mouse = MouseOptions.MouseWheelDown, Modifier = Modifier }
: new ShortcutKeys { Mouse = MouseOptions.MouseWheelUp, Modifier = Modifier };
}
}
}