provide a way to open embedded files with the default editor now that we're Accessor-agnostic

This commit is contained in:
Michael Becker 2019-12-28 21:16:58 -05:00
parent de3279201f
commit 3d1c95aca3
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
2 changed files with 21 additions and 0 deletions

View File

@ -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);

View File

@ -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<IFileSystemObject>("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);
}
}
}
/// <summary>
/// Creates a new folder in the current directory of the currently-loaded <see cref="FileSystemObjectModel"/>.
/// </summary>