diff --git a/Libraries/UniversalEditor.Core/Selection.cs b/Libraries/UniversalEditor.Core/Selection.cs
index f879a8ee..7ad2d644 100644
--- a/Libraries/UniversalEditor.Core/Selection.cs
+++ b/Libraries/UniversalEditor.Core/Selection.cs
@@ -19,6 +19,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
using System;
+using System.Collections.Generic;
+
namespace UniversalEditor
{
public abstract class Selection
@@ -41,4 +43,49 @@ namespace UniversalEditor
Content = null;
}
}
+ public abstract class Selection : Selection where TObjectModel : ObjectModel
+ {
+ public override object Content
+ {
+ get
+ {
+ if (SelectedItems.Count == 0)
+ return null;
+ if (SelectedItems.Count == 1)
+ return SelectedItems[0];
+ return SelectedItems.ToArray();
+ }
+ set
+ {
+ if (value == null)
+ {
+ SelectedItems.Clear();
+ }
+ else if (value is TSelection)
+ {
+ SelectedItems.Clear();
+ SelectedItems.Add((TSelection)value);
+ }
+ else if (value is TSelection[])
+ {
+ SelectedItems = new List((TSelection[])value);
+ }
+ }
+ }
+
+ public TObjectModel ObjectModel { get; private set; } = default(TObjectModel);
+ public TSelection SelectedItem { get { return SelectedItems[0]; } set { SelectedItems.Clear(); SelectedItems.Add(value); } }
+ public List SelectedItems { get; private set; } = new List();
+
+ protected Selection(TObjectModel objectModel, TSelection selectedItem)
+ {
+ ObjectModel = objectModel;
+ SelectedItem = selectedItem;
+ }
+ protected Selection(TObjectModel objectModel, TSelection[] selectedItems)
+ {
+ ObjectModel = objectModel;
+ SelectedItems = new List(selectedItems);
+ }
+ }
}
diff --git a/Libraries/UniversalEditor.Essential/ObjectModels/FileSystem/FileSystemObjectModel.cs b/Libraries/UniversalEditor.Essential/ObjectModels/FileSystem/FileSystemObjectModel.cs
index 1906e2b2..e1c6aaa8 100644
--- a/Libraries/UniversalEditor.Essential/ObjectModels/FileSystem/FileSystemObjectModel.cs
+++ b/Libraries/UniversalEditor.Essential/ObjectModels/FileSystem/FileSystemObjectModel.cs
@@ -587,5 +587,17 @@ namespace UniversalEditor.ObjectModels.FileSystem
}
}
}
+
+ public void Delete(IFileSystemObject fso)
+ {
+ if (fso is File)
+ {
+ fso.Parent.Files.Remove(fso as File);
+ }
+ else if (fso is Folder)
+ {
+ fso.Parent.Folders.Remove(fso as Folder);
+ }
+ }
}
}
diff --git a/Libraries/UniversalEditor.UserInterface/Editor.cs b/Libraries/UniversalEditor.UserInterface/Editor.cs
index 5990e0ca..de182341 100644
--- a/Libraries/UniversalEditor.UserInterface/Editor.cs
+++ b/Libraries/UniversalEditor.UserInterface/Editor.cs
@@ -264,6 +264,8 @@ namespace UniversalEditor.UserInterface
sel.Delete();
}
EndEdit();
+
+ OnObjectModelChanged(EventArgs.Empty);
}
}
diff --git a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs
index aee0b7ad..ba9a760b 100644
--- a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs
+++ b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs
@@ -181,7 +181,7 @@ namespace UniversalEditor.Editors.FileSystem
IFileSystemObject[] sels = GetSelectedItems();
if (sels.Length > 0)
{
- Selections.Add(new FileSystemSelection(this, GetSelectedItems()));
+ Selections.Add(new FileSystemSelection(ObjectModel as FileSystemObjectModel, GetSelectedItems()));
}
}
@@ -244,7 +244,7 @@ namespace UniversalEditor.Editors.FileSystem
{
while (tv.SelectedRows.Count > 0)
{
- if (tv.SelectedRows[0].GetExtraData("item") == sel.Items[0])
+ if (tv.SelectedRows[0].GetExtraData("item") == sel.SelectedItem)
{
tm.Rows.Remove(tv.SelectedRows[0]);
break;
@@ -623,18 +623,18 @@ namespace UniversalEditor.Editors.FileSystem
fileList.Add(fso);
}
- return new FileSystemSelection(this, fileList.ToArray());
+ return new FileSystemSelection(ObjectModel as FileSystemObjectModel, fileList.ToArray());
}
}
}
else if (content is IFileSystemObject)
{
- return new FileSystemSelection(this, content as IFileSystemObject);
+ return new FileSystemSelection(ObjectModel as FileSystemObjectModel, content as IFileSystemObject);
}
else if (content is IFileSystemObject[])
{
IFileSystemObject[] items = (IFileSystemObject[])content;
- return new FileSystemSelection(this, items);
+ return new FileSystemSelection(ObjectModel as FileSystemObjectModel, items);
/*
tv.SelectedRows.Clear();
for (int i = 0; i < tv.Model.Rows.Count; i++)
@@ -767,7 +767,7 @@ namespace UniversalEditor.Editors.FileSystem
for (int i = 0; i < e.NewItems.Count; i++)
{
FileSystemSelection sel = (e.NewItems[i] as FileSystemSelection);
- IFileSystemObject[] objs = (sel.Content as IFileSystemObject[]);
+ IFileSystemObject[] objs = sel.SelectedItems.ToArray();
for (int j = 0; j < tv.Model.Rows.Count; j++)
{
@@ -796,7 +796,7 @@ namespace UniversalEditor.Editors.FileSystem
TreeModelRow row = tv.SelectedRows[i];
if (row == null) continue;
- Selections.Add(new FileSystemSelection(this, row.GetExtraData("item")));
+ Selections.Add(new FileSystemSelection(ObjectModel as FileSystemObjectModel, row.GetExtraData("item")));
}
}
diff --git a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs
index 16201e0d..f66c6ab1 100644
--- a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs
+++ b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs
@@ -23,29 +23,21 @@ using UniversalEditor.UserInterface;
namespace UniversalEditor.Editors.FileSystem
{
- internal class FileSystemSelection : Selection
+ internal class FileSystemSelection : Selection
{
- public IFileSystemObject[] Items { get; set; } = null;
- public override object Content
+ protected override void DeleteInternal()
{
- get => Items;
- set
+ foreach (IFileSystemObject fso in SelectedItems)
{
- Items = (value is IFileSystemObject[] ? (value as IFileSystemObject[]) : null);
+ ObjectModel.Delete(fso);
}
}
- protected override void DeleteInternal()
+ internal FileSystemSelection(FileSystemObjectModel objectModel, IFileSystemObject item) : base(objectModel, item)
{
}
-
- internal FileSystemSelection(FileSystemEditor parent, IFileSystemObject item)
+ internal FileSystemSelection(FileSystemObjectModel objectModel, IFileSystemObject[] item) : base(objectModel, item)
{
- Items = new IFileSystemObject[] { item };
- }
- internal FileSystemSelection(FileSystemEditor parent, IFileSystemObject[] items)
- {
- Items = items;
}
}
}
diff --git a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs
index 50d5dd39..1fa4cca0 100644
--- a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs
+++ b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs
@@ -51,11 +51,23 @@ namespace UniversalEditor.Editors.PropertyList
protected override Selection CreateSelectionInternal(object content)
{
- throw new NotImplementedException();
+ return null;
}
public override void UpdateSelections()
{
- throw new NotImplementedException();
+ foreach (TreeModelRow row in tv.SelectedRows)
+ {
+ Group group = row.GetExtraData("group");
+ Property property = row.GetExtraData("property");
+ if (group != null)
+ {
+ Selections.Add(new PropertyListSelection(ObjectModel as PropertyListObjectModel, group));
+ }
+ else if (property != null)
+ {
+ Selections.Add(new PropertyListSelection(ObjectModel as PropertyListObjectModel, property));
+ }
+ }
}
protected override void OnCreated(EventArgs e)
diff --git a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListSelection.cs b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListSelection.cs
new file mode 100644
index 00000000..5cc2dba0
--- /dev/null
+++ b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListSelection.cs
@@ -0,0 +1,37 @@
+//
+// PropertyListSelection.cs
+//
+// Author:
+// Michael Becker
+//
+// Copyright (c) 2021 Mike Becker's Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+using System;
+using UniversalEditor.ObjectModels.PropertyList;
+
+namespace UniversalEditor.Editors.PropertyList
+{
+ public class PropertyListSelection : Selection
+ {
+ public PropertyListSelection(PropertyListObjectModel objectModel, PropertyListItem item) : base(objectModel, item)
+ {
+ }
+
+ protected override void DeleteInternal()
+ {
+
+ }
+ }
+}
diff --git a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
index 439da3a0..27715639 100644
--- a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
+++ b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj
@@ -137,6 +137,7 @@
+