Enable closing Edit Canvas Layout and Edit Grid Layout windows by pressing Esc button (#7643)

This commit is contained in:
stefansjfw
2020-10-30 16:25:27 +01:00
committed by GitHub
parent c37d08c475
commit 181db8c40a
2 changed files with 24 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Input;
using FancyZonesEditor.Models;
namespace FancyZonesEditor
@@ -15,6 +16,9 @@ namespace FancyZonesEditor
public CanvasEditorWindow()
{
InitializeComponent();
KeyUp += CanvasEditorWindow_KeyUp;
_model = EditorOverlay.Current.DataContext as CanvasLayoutModel;
_stashedModel = (CanvasLayoutModel)_model.Clone();
}
@@ -41,6 +45,14 @@ namespace FancyZonesEditor
_stashedModel.RestoreTo(_model);
}
private void CanvasEditorWindow_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
OnCancel(sender, null);
}
}
private int _offset = 100;
private CanvasLayoutModel _model;
private CanvasLayoutModel _stashedModel;

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Windows;
using System.Windows.Input;
using FancyZonesEditor.Models;
namespace FancyZonesEditor
@@ -15,6 +16,9 @@ namespace FancyZonesEditor
public GridEditorWindow()
{
InitializeComponent();
KeyUp += GridEditorWindow_KeyUp;
_stashedModel = (GridLayoutModel)(EditorOverlay.Current.DataContext as GridLayoutModel).Clone();
}
@@ -25,6 +29,14 @@ namespace FancyZonesEditor
_stashedModel.RestoreTo(model);
}
private void GridEditorWindow_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
OnCancel(sender, null);
}
}
private GridLayoutModel _stashedModel;
}
}