mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-21 00:14:15 +08:00
[FZE] Fix crash when double clicking edit layout (#12609)
This commit is contained in:
parent
7751fed39e
commit
37e130a1a8
@ -26,6 +26,7 @@ namespace FancyZonesEditor
|
||||
private LayoutModel _backup;
|
||||
|
||||
private ContentDialog _openedDialog;
|
||||
private bool _openingDialog = false; // Is the dialog being opened.
|
||||
|
||||
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
|
||||
|
||||
@ -247,19 +248,32 @@ namespace FancyZonesEditor
|
||||
|
||||
private async void EditLayout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dataContext = ((FrameworkElement)sender).DataContext;
|
||||
Select((LayoutModel)dataContext);
|
||||
|
||||
if (_settings.SelectedModel is GridLayoutModel grid)
|
||||
// Avoid trying to open the same dialog twice.
|
||||
if (!_openingDialog)
|
||||
{
|
||||
_backup = new GridLayoutModel(grid);
|
||||
}
|
||||
else if (_settings.SelectedModel is CanvasLayoutModel canvas)
|
||||
{
|
||||
_backup = new CanvasLayoutModel(canvas);
|
||||
}
|
||||
_openingDialog = true;
|
||||
try
|
||||
{
|
||||
var dataContext = ((FrameworkElement)sender).DataContext;
|
||||
Select((LayoutModel)dataContext);
|
||||
|
||||
await EditLayoutDialog.ShowAsync();
|
||||
if (_settings.SelectedModel is GridLayoutModel grid)
|
||||
{
|
||||
_backup = new GridLayoutModel(grid);
|
||||
}
|
||||
else if (_settings.SelectedModel is CanvasLayoutModel canvas)
|
||||
{
|
||||
_backup = new CanvasLayoutModel(canvas);
|
||||
}
|
||||
|
||||
await EditLayoutDialog.ShowAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_openingDialog = false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EditZones_Click(object sender, RoutedEventArgs e)
|
||||
@ -411,6 +425,7 @@ namespace FancyZonesEditor
|
||||
|
||||
private void Dialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args)
|
||||
{
|
||||
_openingDialog = false;
|
||||
_openedDialog = null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user