|
@@ -1,6 +1,8 @@
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
|
|
|
|
namespace PixiEditor.Models.Controllers.Shortcuts
|
|
namespace PixiEditor.Models.Controllers.Shortcuts
|
|
@@ -12,7 +14,9 @@ namespace PixiEditor.Models.Controllers.Shortcuts
|
|
ShortcutGroups = new ObservableCollection<ShortcutGroup>(shortcutGroups);
|
|
ShortcutGroups = new ObservableCollection<ShortcutGroup>(shortcutGroups);
|
|
}
|
|
}
|
|
|
|
|
|
- public static bool BlockShortcutExecution { get; set; }
|
|
|
|
|
|
+ public static bool ShortcutExecutionBlocked => _shortcutExecutionBlockers.Count > 0;
|
|
|
|
+
|
|
|
|
+ private static List<string> _shortcutExecutionBlockers = new List<string>();
|
|
|
|
|
|
public ObservableCollection<ShortcutGroup> ShortcutGroups { get; init; }
|
|
public ObservableCollection<ShortcutGroup> ShortcutGroups { get; init; }
|
|
|
|
|
|
@@ -20,6 +24,23 @@ namespace PixiEditor.Models.Controllers.Shortcuts
|
|
|
|
|
|
public const Key MoveViewportToolTransientChangeKey = Key.Space;
|
|
public const Key MoveViewportToolTransientChangeKey = Key.Space;
|
|
|
|
|
|
|
|
+ public static void BlockShortcutExection(string blocker)
|
|
|
|
+ {
|
|
|
|
+ if (_shortcutExecutionBlockers.Contains(blocker)) return;
|
|
|
|
+ _shortcutExecutionBlockers.Add(blocker);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void UnblockShortcutExecution(string blocker)
|
|
|
|
+ {
|
|
|
|
+ if (!_shortcutExecutionBlockers.Contains(blocker)) return;
|
|
|
|
+ _shortcutExecutionBlockers.Remove(blocker);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void UnblockShortcutExecutionAll()
|
|
|
|
+ {
|
|
|
|
+ _shortcutExecutionBlockers.Clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
public Shortcut GetToolShortcut<T>()
|
|
public Shortcut GetToolShortcut<T>()
|
|
{
|
|
{
|
|
return GetToolShortcut(typeof(T));
|
|
return GetToolShortcut(typeof(T));
|
|
@@ -43,7 +64,7 @@ namespace PixiEditor.Models.Controllers.Shortcuts
|
|
|
|
|
|
public void KeyPressed(Key key, ModifierKeys modifiers)
|
|
public void KeyPressed(Key key, ModifierKeys modifiers)
|
|
{
|
|
{
|
|
- if (!BlockShortcutExecution)
|
|
|
|
|
|
+ if (!ShortcutExecutionBlocked)
|
|
{
|
|
{
|
|
Shortcut[] shortcuts = ShortcutGroups.SelectMany(x => x.Shortcuts).ToList().FindAll(x => x.ShortcutKey == key).ToArray();
|
|
Shortcut[] shortcuts = ShortcutGroups.SelectMany(x => x.Shortcuts).ToList().FindAll(x => x.ShortcutKey == key).ToArray();
|
|
if (shortcuts.Length < 1)
|
|
if (shortcuts.Length < 1)
|