mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
Enable closing Edit Canvas Layout and Edit Grid Layout windows by pressing Esc button (#7643)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user