mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[FancyZones Editor] Reset layout shortcut key after canceling changes (#12613)
* don't update backup layout quick keys * cancel changes on closing
This commit is contained in:
@@ -235,6 +235,8 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
private void OnClosing(object sender, EventArgs e)
|
private void OnClosing(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
CancelLayoutChanges();
|
||||||
|
|
||||||
App.FancyZonesEditorIO.SerializeZoneSettings();
|
App.FancyZonesEditorIO.SerializeZoneSettings();
|
||||||
App.Overlay.CloseLayoutWindow();
|
App.Overlay.CloseLayoutWindow();
|
||||||
App.Current.Shutdown();
|
App.Current.Shutdown();
|
||||||
@@ -259,11 +261,11 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
if (_settings.SelectedModel is GridLayoutModel grid)
|
if (_settings.SelectedModel is GridLayoutModel grid)
|
||||||
{
|
{
|
||||||
_backup = new GridLayoutModel(grid);
|
_backup = new GridLayoutModel(grid, false);
|
||||||
}
|
}
|
||||||
else if (_settings.SelectedModel is CanvasLayoutModel canvas)
|
else if (_settings.SelectedModel is CanvasLayoutModel canvas)
|
||||||
{
|
{
|
||||||
_backup = new CanvasLayoutModel(canvas);
|
_backup = new CanvasLayoutModel(canvas, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await EditLayoutDialog.ShowAsync();
|
await EditLayoutDialog.ShowAsync();
|
||||||
@@ -354,10 +356,7 @@ namespace FancyZonesEditor
|
|||||||
// EditLayout: Cancel changes
|
// EditLayout: Cancel changes
|
||||||
private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||||
{
|
{
|
||||||
// restore model properties from settings
|
CancelLayoutChanges();
|
||||||
_settings.RestoreSelectedModel(_backup);
|
|
||||||
_backup = null;
|
|
||||||
|
|
||||||
Select(_settings.AppliedModel);
|
Select(_settings.AppliedModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,5 +466,14 @@ namespace FancyZonesEditor
|
|||||||
TextBox tb = sender as TextBox;
|
TextBox tb = sender as TextBox;
|
||||||
tb.SelectionStart = tb.Text.Length;
|
tb.SelectionStart = tb.Text.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CancelLayoutChanges()
|
||||||
|
{
|
||||||
|
if (_backup != null)
|
||||||
|
{
|
||||||
|
_settings.RestoreSelectedModel(_backup);
|
||||||
|
_backup = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public CanvasLayoutModel(CanvasLayoutModel other)
|
public CanvasLayoutModel(CanvasLayoutModel other, bool enableQuickKeysPropertyChangedSubscribe = true)
|
||||||
: base(other)
|
: base(other, enableQuickKeysPropertyChangedSubscribe)
|
||||||
{
|
{
|
||||||
CanvasRect = new Rect(other.CanvasRect.X, other.CanvasRect.Y, other.CanvasRect.Width, other.CanvasRect.Height);
|
CanvasRect = new Rect(other.CanvasRect.X, other.CanvasRect.Y, other.CanvasRect.Width, other.CanvasRect.Height);
|
||||||
|
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ namespace FancyZonesEditor.Models
|
|||||||
CellChildMap = cellChildMap;
|
CellChildMap = cellChildMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GridLayoutModel(GridLayoutModel other)
|
public GridLayoutModel(GridLayoutModel other, bool enableQuickKeysPropertyChangedSubscribe = true)
|
||||||
: base(other)
|
: base(other, enableQuickKeysPropertyChangedSubscribe)
|
||||||
{
|
{
|
||||||
_rows = other._rows;
|
_rows = other._rows;
|
||||||
_cols = other._cols;
|
_cols = other._cols;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace FancyZonesEditor.Models
|
|||||||
Type = type;
|
Type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LayoutModel(LayoutModel other)
|
protected LayoutModel(LayoutModel other, bool enableQuickKeysPropertyChangedSubscribe)
|
||||||
{
|
{
|
||||||
_guid = other._guid;
|
_guid = other._guid;
|
||||||
_name = other._name;
|
_name = other._name;
|
||||||
@@ -53,7 +53,10 @@ namespace FancyZonesEditor.Models
|
|||||||
_zoneCount = other._zoneCount;
|
_zoneCount = other._zoneCount;
|
||||||
_quickKey = other._quickKey;
|
_quickKey = other._quickKey;
|
||||||
|
|
||||||
MainWindowSettingsModel.QuickKeys.PropertyChanged += QuickSwitchKeys_PropertyChanged;
|
if (enableQuickKeysPropertyChangedSubscribe)
|
||||||
|
{
|
||||||
|
MainWindowSettingsModel.QuickKeys.PropertyChanged += QuickSwitchKeys_PropertyChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name - the display name for this layout model - is also used as the key in the registry
|
// Name - the display name for this layout model - is also used as the key in the registry
|
||||||
|
|||||||
Reference in New Issue
Block a user