diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editor.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editor.cs index 0647136a..9e77f854 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editor.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editor.cs @@ -82,7 +82,8 @@ namespace UniversalEditor.UserInterface } public void Delete() { - foreach (EditorSelection sel in Selections) + EditorSelection[] sels = GetSelections(); + foreach (EditorSelection sel in sels) { sel.Content = null; } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs index fb8123ea..70b6348a 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs @@ -36,7 +36,20 @@ namespace UniversalEditor.Editors.FileSystem { this.InitializeComponent(); } - + + internal void ClearSelectionContent(FileSystemSelection sel) + { + while (tv.SelectedRows.Count > 0) + { + if (tv.SelectedRows[0].GetExtraData("item") == sel.Item) + { + tmTreeView.Rows.Remove(tv.SelectedRows[0]); + break; + } + } + } + + protected override void OnCreated(EventArgs e) { this.tv.RegisterDragSource(new DragDropTarget[] @@ -67,9 +80,9 @@ namespace UniversalEditor.Editors.FileSystem for (int i = 0; i < tv.SelectedRows.Count; i++) { TreeModelRow row = tv.SelectedRows[i]; + if (row == null) continue; - FileSystemSelection sel = new FileSystemSelection(row.GetExtraData("item")); - Selections.Add(sel); + Selections.Add(new FileSystemSelection(this, row.GetExtraData("item"))); } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs index df77542c..4aed0b28 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemSelection.cs @@ -26,10 +26,22 @@ namespace UniversalEditor.Editors.FileSystem internal class FileSystemSelection : EditorSelection { public IFileSystemObject Item { get; set; } = null; - public override object Content { get => Item; set => Item = (value is IFileSystemObject ? (value as IFileSystemObject) : null); } - - public FileSystemSelection(IFileSystemObject item) + public override object Content { + get => Item; + set + { + if (value == null) + _parent.ClearSelectionContent(this); + + Item = (value is IFileSystemObject ? (value as IFileSystemObject) : null); + } + } + + private FileSystemEditor _parent = null; + internal FileSystemSelection(FileSystemEditor parent, IFileSystemObject item) + { + _parent = parent; Item = item; } }