mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 23:19:13 +08: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:
parent
cc6a8d30b3
commit
35c8130060
@ -235,6 +235,8 @@ namespace FancyZonesEditor
|
||||
|
||||
private void OnClosing(object sender, EventArgs e)
|
||||
{
|
||||
CancelLayoutChanges();
|
||||
|
||||
App.FancyZonesEditorIO.SerializeZoneSettings();
|
||||
App.Overlay.CloseLayoutWindow();
|
||||
App.Current.Shutdown();
|
||||
@ -259,11 +261,11 @@ namespace FancyZonesEditor
|
||||
|
||||
if (_settings.SelectedModel is GridLayoutModel grid)
|
||||
{
|
||||
_backup = new GridLayoutModel(grid);
|
||||
_backup = new GridLayoutModel(grid, false);
|
||||
}
|
||||
else if (_settings.SelectedModel is CanvasLayoutModel canvas)
|
||||
{
|
||||
_backup = new CanvasLayoutModel(canvas);
|
||||
_backup = new CanvasLayoutModel(canvas, false);
|
||||
}
|
||||
|
||||
await EditLayoutDialog.ShowAsync();
|
||||
@ -354,10 +356,7 @@ namespace FancyZonesEditor
|
||||
// EditLayout: Cancel changes
|
||||
private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
// restore model properties from settings
|
||||
_settings.RestoreSelectedModel(_backup);
|
||||
_backup = null;
|
||||
|
||||
CancelLayoutChanges();
|
||||
Select(_settings.AppliedModel);
|
||||
}
|
||||
|
||||
@ -467,5 +466,14 @@ namespace FancyZonesEditor
|
||||
TextBox tb = sender as TextBox;
|
||||
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)
|
||||
: base(other)
|
||||
public CanvasLayoutModel(CanvasLayoutModel other, bool enableQuickKeysPropertyChangedSubscribe = true)
|
||||
: base(other, enableQuickKeysPropertyChangedSubscribe)
|
||||
{
|
||||
CanvasRect = new Rect(other.CanvasRect.X, other.CanvasRect.Y, other.CanvasRect.Width, other.CanvasRect.Height);
|
||||
|
||||
|
@ -146,8 +146,8 @@ namespace FancyZonesEditor.Models
|
||||
CellChildMap = cellChildMap;
|
||||
}
|
||||
|
||||
public GridLayoutModel(GridLayoutModel other)
|
||||
: base(other)
|
||||
public GridLayoutModel(GridLayoutModel other, bool enableQuickKeysPropertyChangedSubscribe = true)
|
||||
: base(other, enableQuickKeysPropertyChangedSubscribe)
|
||||
{
|
||||
_rows = other._rows;
|
||||
_cols = other._cols;
|
||||
|
@ -42,7 +42,7 @@ namespace FancyZonesEditor.Models
|
||||
Type = type;
|
||||
}
|
||||
|
||||
protected LayoutModel(LayoutModel other)
|
||||
protected LayoutModel(LayoutModel other, bool enableQuickKeysPropertyChangedSubscribe)
|
||||
{
|
||||
_guid = other._guid;
|
||||
_name = other._name;
|
||||
@ -53,7 +53,10 @@ namespace FancyZonesEditor.Models
|
||||
_zoneCount = other._zoneCount;
|
||||
_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
|
||||
|
Loading…
Reference in New Issue
Block a user