From 439fb9eac8da3443a857504b7bc88edb6955d4fc Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 5 Sep 2019 23:56:34 -0400 Subject: [PATCH] Implement Extract Files (Copy To) in FileSystemEditor --- .../Associations/NewWorldComputing/AGG.uexml | 20 +++++ ...lEditor.Content.PlatformIndependent.csproj | 2 + .../FileSystem/FileSystemEditor.Designer.cs | 27 ++----- .../Editors/FileSystem/FileSystemEditor.cs | 77 +++++++++++++++++++ 4 files changed, 105 insertions(+), 21 deletions(-) create mode 100644 CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/FileSystem/Associations/NewWorldComputing/AGG.uexml diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/FileSystem/Associations/NewWorldComputing/AGG.uexml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/FileSystem/Associations/NewWorldComputing/AGG.uexml new file mode 100644 index 00000000..d9c8ffb2 --- /dev/null +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Extensions/FileSystem/Associations/NewWorldComputing/AGG.uexml @@ -0,0 +1,20 @@ + + + + + + + + *.agg + + + + + + + + + + + + \ No newline at end of file diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index af9eaa9a..c4381b16 100644 --- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -637,6 +637,7 @@ + @@ -649,6 +650,7 @@ + diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs index 9070e8db..320a02b1 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.Designer.cs @@ -92,11 +92,17 @@ namespace UniversalEditor.Editors.FileSystem { new CommandMenuItem("_Open"), new SeparatorMenuItem(), + new CommandMenuItem("Open in New _Tab"), + new CommandMenuItem("Open in New _Window"), + new SeparatorMenuItem(), new CommandMenuItem("Se_nd to"), new SeparatorMenuItem(), new CommandMenuItem("Cu_t"), new CommandMenuItem("_Copy"), new SeparatorMenuItem(), + new CommandMenuItem("Move to..."), + new CommandMenuItem("Copy to...", null, ContextMenuCopyTo_Click), + new SeparatorMenuItem(), new CommandMenuItem("Create _shortcut"), new CommandMenuItem("_Delete"), new CommandMenuItem("Rena_me"), @@ -114,26 +120,5 @@ namespace UniversalEditor.Editors.FileSystem this.Controls.Add(this.tv, new BoxLayout.Constraints(true, true)); } - void tv_BeforeContextMenu(object sender, EventArgs e) - { - TreeModelRow row = null; - if (e is MouseEventArgs) - { - MouseEventArgs ee = (e as MouseEventArgs); - ListViewHitTestInfo info = tv.HitTest(ee.X, ee.Y); - if (info != null) - row = info.Row; - } - - if (row != null) - { - tv.ContextMenu = contextMenuSelected; - } - else - { - tv.ContextMenu = contextMenuUnselected; - } - } - } } diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs index 70b6348a..4ae199c2 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs @@ -24,6 +24,7 @@ using UniversalEditor.ObjectModels.FileSystem; using UniversalEditor.UserInterface; using UniversalWidgetToolkit; +using UniversalWidgetToolkit.Dialogs; using UniversalWidgetToolkit.DragDrop; using UniversalWidgetToolkit.Input.Keyboard; using UniversalWidgetToolkit.Input.Mouse; @@ -163,5 +164,81 @@ namespace UniversalEditor.Editors.FileSystem RecursiveAddFile(f, null); } } + + void ContextMenuCopyTo_Click(object sender, EventArgs e) + { + // extract files + if (tv.SelectedRows.Count == 1) + { + UIExtractFileSystemObject(tv.SelectedRows[0].GetExtraData("item")); + } + else if (tv.SelectedRows.Count > 1) + { + FileDialog fd = new FileDialog(); + fd.Mode = FileDialogMode.SelectFolder; + fd.MultiSelect = false; + foreach (TreeModelRow row in tv.SelectedRows) + { + } + } + } + + private void UIExtractFileSystemObject(IFileSystemObject fso) + { + FileDialog fd = new FileDialog(); + if (fso is File) + { + File f = (fso as File); + /* + if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar.ToString() + f.Name)) + { + fd.SelectedFileNames.Add(System.IO.Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar.ToString() + f.Name); + } + else + { + */ + fd.SelectedFileNames.Add(f.Name); + //} + fd.Mode = FileDialogMode.Save; + fd.MultiSelect = false; + if (fd.ShowDialog() == DialogResult.OK) + { + System.IO.File.WriteAllBytes(fd.SelectedFileNames[0], f.GetData()); + } + } + else if (fso is Folder) + { + Folder f = (fso as Folder); + fd.SelectedFileNames.Add(f.Name); + fd.Mode = FileDialogMode.CreateFolder; + fd.MultiSelect = false; + if (fd.ShowDialog() == DialogResult.OK) + { + System.IO.Directory.CreateDirectory(fd.SelectedFileNames[0]); + // TODO: implement this + } + } + } + + void tv_BeforeContextMenu(object sender, EventArgs e) + { + TreeModelRow row = null; + if (e is MouseEventArgs) + { + MouseEventArgs ee = (e as MouseEventArgs); + ListViewHitTestInfo info = tv.HitTest(ee.X, ee.Y); + if (info != null) + row = info.Row; + } + + if (row != null) + { + tv.ContextMenu = contextMenuSelected; + } + else + { + tv.ContextMenu = contextMenuUnselected; + } + } } }