Implement Extract Files (Copy To) in FileSystemEditor

This commit is contained in:
Michael Becker 2019-09-05 23:56:34 -04:00
parent 00529ca593
commit 439fb9eac8
4 changed files with 105 additions and 21 deletions

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Heroes of Might and Magic II AGG">
<FileNameFilters>
<FileNameFilter>*.agg</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.FileSystem.NewWorldComputing.AGG.AGGDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -637,6 +637,7 @@
<Content Include="Dialogs\DocumentPropertiesDialog.glade" />
<Content Include="Panels\StartPage.glade" />
<Content Include="Extensions\FamilyTreeMaker\Associations\FTW.uexml" />
<Content Include="Extensions\FileSystem\Associations\NewWorldComputing\AGG.uexml" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />
@ -649,6 +650,7 @@
<Folder Include="Extensions\Microsoft\Associations\" />
<Folder Include="Extensions\FamilyTreeMaker\" />
<Folder Include="Extensions\FamilyTreeMaker\Associations\" />
<Folder Include="Extensions\FileSystem\Associations\NewWorldComputing\" />
</ItemGroup>
<ItemGroup>
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />

View File

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

View File

@ -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<IFileSystemObject>("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;
}
}
}
}