[#31] AdministrationWindow: Add shortcuts
This commit is contained in:
@ -11,6 +11,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using Xceed.Wpf.Toolkit;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Elwig.Windows {
|
||||
public abstract class AdministrationWindow : ContextWindow {
|
||||
@ -48,7 +49,18 @@ namespace Elwig.Windows {
|
||||
private readonly Dictionary<Control, int?> OriginalValues;
|
||||
private readonly Dictionary<Control, int?> DefaultValues;
|
||||
|
||||
private readonly RoutedCommand AltInsert = new("AltInsert", typeof(AdministrationWindow), [new KeyGesture(Key.Insert, ModifierKeys.Alt)]);
|
||||
private readonly RoutedCommand AltDelete = new("AltDelete", typeof(AdministrationWindow), [new KeyGesture(Key.Delete, ModifierKeys.Alt)]);
|
||||
private readonly RoutedCommand CtrlZ = new("CtrlZ", typeof(AdministrationWindow), [new KeyGesture(Key.Z, ModifierKeys.Control)]);
|
||||
private readonly RoutedCommand CtrlS = new("CtrlS", typeof(AdministrationWindow), [new KeyGesture(Key.S, ModifierKeys.Control)]);
|
||||
private readonly RoutedCommand CtrlB = new("CtrlB", typeof(AdministrationWindow), [new KeyGesture(Key.B, ModifierKeys.Control)]);
|
||||
|
||||
public AdministrationWindow() : base() {
|
||||
CommandBindings.Add(new CommandBinding(AltInsert, ShortcutNew));
|
||||
CommandBindings.Add(new CommandBinding(AltDelete, ShortcutDelete));
|
||||
CommandBindings.Add(new CommandBinding(CtrlZ, ShortcutReset));
|
||||
CommandBindings.Add(new CommandBinding(CtrlS, ShortcutSave));
|
||||
CommandBindings.Add(new CommandBinding(CtrlB, ShortcutEdit));
|
||||
IsEditing = false;
|
||||
IsCreating = false;
|
||||
ExemptInputs = [];
|
||||
@ -69,6 +81,18 @@ namespace Elwig.Windows {
|
||||
Loaded += base.OnLoaded;
|
||||
}
|
||||
|
||||
abstract protected void ShortcutNew();
|
||||
abstract protected void ShortcutDelete();
|
||||
abstract protected void ShortcutReset();
|
||||
abstract protected void ShortcutSave();
|
||||
abstract protected void ShortcutEdit();
|
||||
|
||||
private void ShortcutNew(object sender, EventArgs evt) { ShortcutNew(); }
|
||||
private void ShortcutDelete(object sender, EventArgs evt) { ShortcutDelete(); }
|
||||
private void ShortcutReset(object sender, EventArgs evt) { ShortcutReset(); }
|
||||
private void ShortcutSave(object sender, EventArgs evt) { ShortcutSave(); }
|
||||
private void ShortcutEdit(object sender, EventArgs evt) { ShortcutEdit(); }
|
||||
|
||||
private new void OnLoaded(object sender, RoutedEventArgs evt) {
|
||||
TextBoxInputs = ControlUtils.FindAllChildren<TextBox>(this, ExemptInputs).ToArray();
|
||||
ComboBoxInputs = ControlUtils.FindAllChildren<ComboBox>(this, ExemptInputs).ToArray();
|
||||
|
Reference in New Issue
Block a user