implement context menu in UEXML instead of code
This commit is contained in:
parent
854d237750
commit
472f2d8366
@ -2,23 +2,73 @@
|
||||
<Editors>
|
||||
<Editor ID="{1B5B1E8D-442A-4AC0-8EFD-03AADFF3CAD2}" TypeName="UniversalEditor.Editors.FileSystem.FileSystemEditor">
|
||||
<Commands>
|
||||
<Command ID="FileSystemContextMenu_View" />
|
||||
<Command ID="FileSystemContextMenu_Add" />
|
||||
<Command ID="FileSystemContextMenu_New" />
|
||||
<Command ID="FileSystemContextMenu_View_Thumbnails" Title="T_humbnails" />
|
||||
<Command ID="FileSystemContextMenu_View_Tiles" Title="Tile_s" />
|
||||
<Command ID="FileSystemContextMenu_View_Icons" Title="Ico_ns" />
|
||||
<Command ID="FileSystemContextMenu_View_List" Title="_List" />
|
||||
<Command ID="FileSystemContextMenu_View_Details" Title="_Details" />
|
||||
|
||||
<Command ID="FileSystemContextMenu_Open" />
|
||||
<Command ID="FileSystemContextMenu_OpenNewTab" />
|
||||
<Command ID="FileSystemContextMenu_OpenNewWindow" />
|
||||
<Command ID="FileSystemContextMenu_SendTo" />
|
||||
<Command ID="FileSystemContextMenu_View" Title="_View">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSystemContextMenu_View_Thumbnails" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_View_Tiles" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_View_Icons" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_View_List" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_View_Details" />
|
||||
</Items>
|
||||
</Command>
|
||||
|
||||
<Command ID="FileSystemContextMenu_MoveTo" />
|
||||
<Command ID="FileSystemContextMenu_CopyTo" />
|
||||
<Command ID="FileSystemContextMenu_Add_NewItem" Title="Ne_w item..." />
|
||||
<Command ID="FileSystemContextMenu_Add_ExistingItem" Title="E_xisting item..." />
|
||||
<Command ID="FileSystemContextMenu_Add_NewFolder" Title="New fol_der" />
|
||||
<Command ID="FileSystemContextMenu_Add_ExistingFolder" Title="Existin_g folder..." />
|
||||
<Command ID="FileSystemContextMenu_Add_FilesFromFolder" Title="_Files from folder..." />
|
||||
<Command ID="FileSystemContextMenu_Add" Title="A_dd">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSystemContextMenu_Add_NewItem" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_Add_ExistingItem" />
|
||||
<Separator />
|
||||
<CommandReference CommandID="FileSystemContextMenu_Add_NewFolder" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_Add_ExistingFolder" />
|
||||
<Separator />
|
||||
<CommandReference CommandID="FileSystemContextMenu_Add_FilesFromFolder" />
|
||||
</Items>
|
||||
</Command>
|
||||
|
||||
<Command ID="FileSystemContextMenu_New_Folder" Title="_Folder" />
|
||||
<Command ID="FileSystemContextMenu_New_Shortcut" Title="_Shortcut" />
|
||||
<Command ID="FileSystemContextMenu_New_Briefcase" Title="Briefcase" />
|
||||
<Command ID="FileSystemContextMenu_New_BitmapImage" Title="Bitmap image" />
|
||||
<Command ID="FileSystemContextMenu_New_FormattedTextDocument" Title="Formatted text document" />
|
||||
<Command ID="FileSystemContextMenu_New_PlainTextDocument" Title="Plain text document" />
|
||||
<Command ID="FileSystemContextMenu_New_WaveSound" Title="Wave sound" />
|
||||
<Command ID="FileSystemContextMenu_New_CompressedFolder" Title="Compressed (zipped) folder" />
|
||||
<Command ID="FileSystemContextMenu_New" Title="Ne_w">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_Folder" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_Shortcut" />
|
||||
<Separator />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_Briefcase" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_BitmapImage" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_FormattedTextDocument" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_PlainTextDocument" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_WaveSound" />
|
||||
<CommandReference CommandID="FileSystemContextMenu_New_CompressedFolder" />
|
||||
</Items>
|
||||
</Command>
|
||||
|
||||
<Command ID="FileSystemContextMenu_Open" Title="_Open" />
|
||||
<Command ID="FileSystemContextMenu_OpenNewTab" Title="Open in New _Tab" />
|
||||
<Command ID="FileSystemContextMenu_OpenNewWindow" Title="Open in New _Window" />
|
||||
<Command ID="FileSystemContextMenu_SendTo" Title="Se_nd to" />
|
||||
|
||||
<Command ID="FileSystemContextMenu_MoveTo" Title-"Move to..." />
|
||||
<Command ID="FileSystemContextMenu_CopyTo" Title="Copy to..." />
|
||||
|
||||
<Command ID="FileSystemContextMenu_CreateShortcut" />
|
||||
<Command ID="FileSystemContextMenu_Rename" />
|
||||
</Commands>
|
||||
<Menus>
|
||||
<Menu ID="UniversalEditor.Editors.FileSystem.FileSystemEditor.ContextMenuUnselected">
|
||||
|
||||
<Command ID="FileSystemContextMenu_Unselected">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSystemContextMenu_View" />
|
||||
<Separator />
|
||||
@ -33,8 +83,8 @@
|
||||
<Separator />
|
||||
<CommandReference CommandID="FileProperties" />
|
||||
</Items>
|
||||
</Menu>
|
||||
<Menu ID="UniversalEditor.Editors.FileSystem.FileSystemEditor.ContextMenuSelected">
|
||||
</Command>
|
||||
<Command ID="FileSystemContextMenu_Selected">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSystemContextMenu_Open" />
|
||||
<Separator />
|
||||
@ -55,8 +105,8 @@
|
||||
<Separator />
|
||||
<CommandReference CommandID="FileProperties" />
|
||||
</Items>
|
||||
</Menu>
|
||||
</Menus>
|
||||
</Command>
|
||||
</Commands>
|
||||
</Editor>
|
||||
</Editors>
|
||||
</UniversalEditor>
|
||||
@ -32,16 +32,8 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
private ListView tv = null;
|
||||
private DefaultTreeModel tmTreeView = null;
|
||||
|
||||
private Menu contextMenuUnselected = new Menu();
|
||||
private Menu contextMenuSelected = new Menu();
|
||||
|
||||
private CommandMenuItem contextMenuUnselectedPaste = null;
|
||||
private CommandMenuItem contextMenuUnselectedPasteShortcut = new CommandMenuItem("Paste _shortcut");
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
contextMenuUnselectedPaste = new CommandMenuItem("_Paste", null, contextMenuUnselectedPaste_Click);
|
||||
|
||||
this.Layout = new BoxLayout(Orientation.Vertical);
|
||||
|
||||
this.tmTreeView = new DefaultTreeModel(new Type[] { typeof(string), typeof(string), typeof(string), typeof(string) });
|
||||
@ -51,81 +43,13 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
this.tv.SelectionMode = SelectionMode.Multiple;
|
||||
this.tv.Model = this.tmTreeView;
|
||||
|
||||
// these need to somehow be loaded from xml
|
||||
contextMenuUnselected.Items.AddRange(new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_View", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("T_humbnails"),
|
||||
new CommandMenuItem("Tile_s"),
|
||||
new CommandMenuItem("Ico_ns"),
|
||||
new CommandMenuItem("_List"),
|
||||
new CommandMenuItem("_Details")
|
||||
}),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Arrange _Icons by", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_Name"),
|
||||
new CommandMenuItem("_Size"),
|
||||
new CommandMenuItem("_Type"),
|
||||
new CommandMenuItem("_Date modified"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Show in _groups"),
|
||||
new CommandMenuItem("_Auto arrange"),
|
||||
new CommandMenuItem("A_lign to grid")
|
||||
}),
|
||||
new CommandMenuItem("R_efresh"),
|
||||
new SeparatorMenuItem(),
|
||||
contextMenuUnselectedPaste,
|
||||
contextMenuUnselectedPasteShortcut,
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("A_dd", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("Ne_w Item", null, delegate(object sender, EventArgs e) { MessageDialog.ShowDialog("TODO: Implement a way to open a new document editor for an embedded file", "Not Implemented", MessageDialogButtons.OK, MessageDialogIcon.Warning); }),
|
||||
new CommandMenuItem("E_xisting Item...", null, FileAddExistingItem_Click),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("New Fol_der", null, FileNewFolder_Click),
|
||||
new CommandMenuItem("Existin_g Folder...", null, FileAddItemsFromFolder_Click),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("_Files from Folder...", null, FileAddExistingFolder_Click)
|
||||
}),
|
||||
new CommandMenuItem("Ne_w", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_Folder", null, FileNewFolder_Click),
|
||||
new CommandMenuItem("_Shortcut"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Briefcase"),
|
||||
new CommandMenuItem("Bitmap image"),
|
||||
new CommandMenuItem("Formatted text document"),
|
||||
new CommandMenuItem("Plain text document"),
|
||||
new CommandMenuItem("Wave sound"),
|
||||
new CommandMenuItem("Compressed (zipped) folder")
|
||||
}),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("P_roperties", null, ContextMenuProperties_Click)
|
||||
});
|
||||
|
||||
contextMenuSelected.Items.AddRange(new MenuItem[]
|
||||
{
|
||||
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", null, ContextMenuDelete_Click),
|
||||
new CommandMenuItem("Rena_me", null, ContextMenuRename_Click),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("P_roperties", null, ContextMenuProperties_Click)
|
||||
});
|
||||
Application.AttachCommandEventHandler("FileSystemContextMenu_Add_ExistingFolder", FileAddExistingFolder_Click);
|
||||
Application.AttachCommandEventHandler("FileSystemContextMenu_Add_FilesFromFolder", FileAddItemsFromFolder_Click);
|
||||
Application.AttachCommandEventHandler("FileSystemContextMenu_New_Folder", FileNewFolder_Click);
|
||||
// Application.AttachCommandEventHandler("EditDelete", ContextMenuDelete_Click);
|
||||
Application.AttachCommandEventHandler("FileSystemContextMenu_Rename", ContextMenuRename_Click);
|
||||
Application.AttachCommandEventHandler("FileSystemContextMenu_CopyTo", ContextMenuCopyTo_Click);
|
||||
// Application.AttachCommandEventHandler("FileProperties", ContextMenuProperties_Click);
|
||||
|
||||
this.tv.BeforeContextMenu += tv_BeforeContextMenu;
|
||||
|
||||
|
||||
@ -179,7 +179,18 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
if (fd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Folder f = FolderFromPath(fd.SelectedFileNames[fd.SelectedFileNames.Count - 1]);
|
||||
RecursiveAddFolder(f);
|
||||
IFileSystemObject[] files = f.GetContents();
|
||||
foreach (IFileSystemObject fso in files)
|
||||
{
|
||||
if (fso is File)
|
||||
{
|
||||
RecursiveAddFile(fso as File);
|
||||
}
|
||||
else if (fso is Folder)
|
||||
{
|
||||
RecursiveAddFolder(fso as Folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void FileAddExistingFolder_Click(object sender, EventArgs e)
|
||||
@ -193,18 +204,7 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
if (fd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Folder f = FolderFromPath(fd.SelectedFileNames[fd.SelectedFileNames.Count - 1]);
|
||||
IFileSystemObject[] files = f.GetContents();
|
||||
foreach (IFileSystemObject fso in files)
|
||||
{
|
||||
if (fso is File)
|
||||
{
|
||||
RecursiveAddFile(fso as File);
|
||||
}
|
||||
else if (fso is Folder)
|
||||
{
|
||||
RecursiveAddFolder(fso as Folder);
|
||||
}
|
||||
}
|
||||
RecursiveAddFolder(f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,17 +552,17 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
row = info.Row;
|
||||
}
|
||||
|
||||
contextMenuUnselectedPaste.Enabled = Clipboard.Default.ContainsFileList;
|
||||
contextMenuUnselectedPasteShortcut.Enabled = Clipboard.Default.ContainsFileList;
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
tv.ContextMenu = contextMenuSelected;
|
||||
tv.ContextMenuCommandID = "FileSystemContextMenu_Selected";
|
||||
}
|
||||
else
|
||||
{
|
||||
tv.ContextMenu = contextMenuUnselected;
|
||||
tv.ContextMenuCommandID = "FileSystemContextMenu_Unselected";
|
||||
}
|
||||
|
||||
Application.Commands["EditPaste"].Enabled = Clipboard.Default.ContainsFileList;
|
||||
// (tv.ContextMenu.Items["FileSystemContextMenu_PasteShortcut"] as CommandMenuItem).Enabled = Clipboard.Default.ContainsFileList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user