diff --git a/Elwig/Windows/ContextWindow.cs b/Elwig/Windows/ContextWindow.cs index e16b919..aa81549 100644 --- a/Elwig/Windows/ContextWindow.cs +++ b/Elwig/Windows/ContextWindow.cs @@ -1,17 +1,38 @@ using Elwig.Helpers; +using System; using System.Threading.Tasks; using System.Windows; +using System.Windows.Input; namespace Elwig.Windows { public abstract class ContextWindow : Window { - protected bool LockContext { get; set; } = false; + private bool _lockContext = false; + protected bool LockContext { + get => _lockContext; + set { + _lockContext = value; + if (!_lockContext && _renewPending) { + Dispatcher.BeginInvoke(async () => await RenewContext()); + } + } + } + private bool _renewPending = false; + private readonly RoutedCommand CtrlR = new("CtrlR", typeof(ContextWindow), [new KeyGesture(Key.R, ModifierKeys.Control)]); + private readonly RoutedCommand F5 = new("F5", typeof(ContextWindow), [new KeyGesture(Key.F5)]); + public ContextWindow() : base() { + CommandBindings.Add(new CommandBinding(CtrlR, ForceContextReload)); + CommandBindings.Add(new CommandBinding(F5, ForceContextReload)); Loaded += OnLoaded; } + public async void ForceContextReload(object sender, EventArgs evt) { + await HintContextChange(); + } + public async Task HintContextChange() { _renewPending = true; if (LockContext) return;