don't quit the FZ editor if no layout is selected when clicking on the "Edit selected layout" (#548)

don't exit when clicking on "Apply" if no layout is selected

Credit to @AlexR3 for the fix. Alex provided a more extensive fix that  disable the button when no layout  is selected, but it requires more changes to the XAML and we preferred to avoid that now.
This commit is contained in:
Enrico Giordani
2019-10-23 21:22:36 +02:00
committed by GitHub
parent 8f8f4506ff
commit 57cd5b5b10
2 changed files with 14 additions and 12 deletions

View File

@@ -78,17 +78,15 @@ namespace FancyZonesEditor
private void EditLayout_Click(object sender, RoutedEventArgs e)
{
_editing = true;
this.Close();
EditorOverlay mainEditor = EditorOverlay.Current;
LayoutModel model = mainEditor.DataContext as LayoutModel;
if (model == null)
{
mainEditor.Close();
return;
}
model.IsSelected = false;
_editing = true;
this.Close();
bool isPredefinedLayout = Settings.IsPredefinedLayout(model);
@@ -150,9 +148,8 @@ namespace FancyZonesEditor
{
model.Apply((model as CanvasLayoutModel).Zones.ToArray());
}
this.Close();
}
this.Close();
}
private void OnClosed(object sender, EventArgs e)
@@ -163,13 +160,18 @@ namespace FancyZonesEditor
}
}
private void OnLoaded(object sender, RoutedEventArgs e)
private void InitializedEventHandler(object sender, EventArgs e)
{
foreach(LayoutModel model in _settings.CustomModels)
SetSelectedItem();
}
private void SetSelectedItem()
{
foreach (LayoutModel model in _settings.CustomModels)
{
if (model.IsSelected)
{
TemplateTab.SelectedIndex = 1;
TemplateTab.SelectedItem = model;
return;
}
}
@@ -180,7 +182,7 @@ namespace FancyZonesEditor
LayoutModel model = ((FrameworkElement)sender).DataContext as LayoutModel;
if (model.IsSelected)
{
OnLoaded(null, null);
SetSelectedItem();
}
model.Delete();
}