From 69a554cb7902d703cb70e08ff067ca87fd3df01e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 25 Oct 2025 06:56:07 +0000
Subject: [PATCH] Add template deletion functionality to FancyZones Editor
- Created LayoutTypeDeletableToVisibilityConverter to show delete button for templates (except Blank)
- Updated MainWindow.xaml to use new converter for delete buttons and menu items
- Modified LayoutModel.Delete() to handle both custom and template layout deletion
- Changed TemplateModels from IList to ObservableCollection for UI updates
- Updated all index-based TemplateModels access to use LINQ queries
- Enhanced DefaultLayoutsModel.Reset() to handle missing templates gracefully
- Added fallback logic when templates are deleted
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
---
...ayoutTypeDeletableToVisibilityConverter.cs | 28 +++++++++
.../editor/FancyZonesEditor/MainWindow.xaml | 7 ++-
.../Models/DefaultLayoutsModel.cs | 21 +++++--
.../FancyZonesEditor/Models/LayoutModel.cs | 12 +++-
.../Models/MainWindowSettingsModel.cs | 17 ++---
.../Utils/FancyZonesEditorIO.cs | 63 +++++++++++--------
6 files changed, 106 insertions(+), 42 deletions(-)
create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/Converters/LayoutTypeDeletableToVisibilityConverter.cs
diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Converters/LayoutTypeDeletableToVisibilityConverter.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/LayoutTypeDeletableToVisibilityConverter.cs
new file mode 100644
index 0000000000..8be0913e83
--- /dev/null
+++ b/src/modules/fancyzones/editor/FancyZonesEditor/Converters/LayoutTypeDeletableToVisibilityConverter.cs
@@ -0,0 +1,28 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+using FancyZonesEditor.Models;
+
+namespace FancyZonesEditor.Converters
+{
+ public class LayoutTypeDeletableToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ // Allow deletion for custom layouts and all template layouts except Blank
+ LayoutType type = (LayoutType)value;
+ return (type == LayoutType.Custom || (type != LayoutType.Blank && type != LayoutType.Custom)) ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml
index d7d53e2725..aa40f32041 100644
--- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml
+++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml
@@ -33,6 +33,7 @@
+
@@ -68,11 +69,11 @@
-
+