From 3d1c95aca349eccca378788a8b027c4238a79a21 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sat, 28 Dec 2019 21:16:58 -0500 Subject: [PATCH] provide a way to open embedded files with the default editor now that we're Accessor-agnostic --- .../FileSystem/FileSystemEditor.Designer.cs | 1 + .../Editors/FileSystem/FileSystemEditor.cs | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs index 4a3a5f0a..6a45cb92 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs @@ -43,6 +43,7 @@ namespace UniversalEditor.Editors.FileSystem this.tv.SelectionMode = SelectionMode.Multiple; this.tv.Model = this.tmTreeView; + Context.AttachCommandEventHandler("FileSystemContextMenu_Open", FileSystemContextMenu_Open_Click); Context.AttachCommandEventHandler("FileSystemContextMenu_Add_ExistingItem", FileAddExistingItem_Click); Context.AttachCommandEventHandler("FileSystemContextMenu_Add_ExistingFolder", FileAddExistingFolder_Click); Context.AttachCommandEventHandler("FileSystemContextMenu_Add_FilesFromFolder", FileAddItemsFromFolder_Click); diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs index 34534eca..95502bdb 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs @@ -29,6 +29,7 @@ using MBS.Framework.UserInterface.DragDrop; using MBS.Framework.UserInterface.Input.Keyboard; using MBS.Framework.UserInterface.Input.Mouse; using UniversalEditor.Editors.FileSystem.Dialogs; +using UniversalEditor.Accessors; namespace UniversalEditor.Editors.FileSystem { @@ -168,6 +169,25 @@ namespace UniversalEditor.Editors.FileSystem return f; } + private void FileSystemContextMenu_Open_Click(object sender, EventArgs e) + { + if (tv.SelectedRows.Count < 1) + return; + + for (int i = 0; i < tv.SelectedRows.Count; i++) + { + IFileSystemObject fso = tv.SelectedRows[i].GetExtraData("item"); + if (fso is File) + { + File f = (fso as File); + + MemoryAccessor ma = new MemoryAccessor(f.GetData(), f.Name); + Document doc = new Document(ma); + HostApplication.CurrentWindow.OpenFile(doc); + } + } + } + /// /// Creates a new folder in the current directory of the currently-loaded . ///