implement context menu in UEXML instead of code

This commit is contained in:
Michael Becker 2019-11-08 21:33:37 -05:00
parent 472f2d8366
commit ee190dab6a
No known key found for this signature in database
GPG Key ID: 389DFF5D73781A12
3 changed files with 66 additions and 13 deletions

View File

@ -0,0 +1,57 @@
<UniversalEditor Version="5.0">
<Editors>
<Editor ID="{A97649A7-3A5E-49BE-BC62-117EE92CE4B5}" TypeName="UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable.ExecutableEditor">
<Commands>
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_Add_NewItem" Title="Ne_w section..." />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_Add_ExistingItem" Title="E_xisting section..." />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_Add" Title="A_dd">
<Items>
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_Add_NewItem" />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_Add_ExistingItem" />
</Items>
</Command>
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_MoveTo" Title-"Move to..." />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_CopyTo" Title="_Copy to..." />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_Open" Title="_Open" />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_OpenNewTab" Title="Open in New _Tab" />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_OpenNewWindow" Title="Open in New _Window" />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected_Rename" Title="Rena_me" />
<Command ID="ExecutableEditor_ContextMenu_Sections_Selected" Title="Section (selected)">
<Items>
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_Open" />
<Separator />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_OpenNewTab" />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_OpenNewWindow" />
<Separator />
<CommandReference CommandID="EditCut" />
<CommandReference CommandID="EditCopy" />
<Separator />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_MoveTo" />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_CopyTo" />
<Separator />
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_Rename" />
<Separator />
<CommandReference CommandID="FileProperties" />
</Items>
</Command>
<Command ID="ExecutableEditor_ContextMenu_Sections_Unselected" Title="Section (unselected)">
<Items>
<CommandReference CommandID="ExecutableEditor_ContextMenu_Sections_Selected_Add" />
<Separator />
<CommandReference CommandID="EditPaste" />
<Separator />3
<CommandReference CommandID="FileProperties" />
</Items>
</Command>
</Commands>
</Editor>
</Editors>
</UniversalEditor>

View File

@ -642,6 +642,7 @@
<Content Include="Editors\UniversalEditor.Editors.FileSystem.FileSystemEditor\Commands.uexml" />
<Content Include="Editors\Multimedia\Audio\Synthesized\PianoRoll\MenuBar.uexml" />
<Content Include="splash.bmp" />
<Content Include="Editors\Executable\Commands.uexml" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />
@ -661,6 +662,7 @@
<Folder Include="Editors\Multimedia\Audio\" />
<Folder Include="Editors\Multimedia\Audio\Synthesized\" />
<Folder Include="Editors\Multimedia\Audio\Synthesized\PianoRoll\" />
<Folder Include="Editors\Executable\" />
</ItemGroup>
<ItemGroup>
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />

View File

@ -60,6 +60,8 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
private Label lblAssemblyVersion = null;
private TextBox txtAssemblyVersion = null;
private DefaultTreeModel tmOtherInformation = null;
public ExecutableEditor()
{
this.Layout = new BoxLayout(Orientation.Vertical);
@ -77,11 +79,10 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
tbs = new TabContainer();
TabPage tabSections = new TabPage("Sections (0)");
tabSections.Layout = new BoxLayout(Orientation.Vertical);
tabSections.Controls.Add(tvSections, new BoxLayout.Constraints(true, true));
tbs.TabPages.Add(tabSections);
TabPage tabManagedAssembly = new TabPage("Managed Assembly");
tabManagedAssembly.Layout = new BoxLayout(Orientation.Vertical);
@ -107,13 +108,7 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
tbs.TabPages.Add(tabManagedAssembly);
this.contextMenuItemSelected = new Menu();
this.contextMenuItemSelected.Items.AddRange(new MBS.Framework.UserInterface.MenuItem[]
{
new MBS.Framework.UserInterface.CommandMenuItem("_Copy to", null, ContextMenu_CopyTo_Click)
});
Application.AttachCommandEventHandler("ExecutableEditor_ContextMenu_Sections_Selected_CopyTo", ContextMenu_CopyTo_Click);
this.Controls.Add(tbs, new BoxLayout.Constraints(true, true));
}
@ -149,7 +144,6 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
}
}
private Menu contextMenuItemSelected = null;
void tvSections_BeforeContextMenu(object sender, EventArgs e)
{
bool selected = tvSections.SelectedRows.Count > 0;
@ -163,11 +157,11 @@ namespace UniversalEditor.Plugins.Executable.UserInterface.Editors.Executable
if (selected)
{
tvSections.ContextMenu = contextMenuItemSelected;
tvSections.ContextMenuCommandID = "ExecutableEditor_ContextMenu_Sections_Selected";
}
else
{
tvSections.ContextMenu = null;
tvSections.ContextMenuCommandID = "ExecutableEditor_ContextMenu_Sections_Unselected";
}
}