Skip to content

Commit 87ed719

Browse files
committed
Improve template plug-in by adding submenu to top menu
1 parent 4a9ab5d commit 87ed719

7 files changed

Lines changed: 45 additions & 3 deletions

File tree

src/Plugins/MW5.TemplatePlugin/MW5.TemplatePlugin.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119
<ItemGroup>
120120
<None Include="Resources\ico_template.ico" />
121121
</ItemGroup>
122+
<ItemGroup>
123+
<None Include="Resources\template-icon.png" />
124+
</ItemGroup>
125+
<ItemGroup>
126+
<None Include="Resources\hello-icon.png" />
127+
</ItemGroup>
122128
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
123129
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
124130
Other similar extension points exist, see Microsoft.Common.targets.

src/Plugins/MW5.TemplatePlugin/Menu/MenuGenerator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// --------------------------------------------------------------------------------------------------------------------
99

1010
using MW5.Plugins.Enums;
11+
using MW5.Plugins.TemplatePlugin.Properties;
1112

1213
namespace MW5.Plugins.TemplatePlugin.Menu
1314
{
@@ -58,10 +59,16 @@ public MenuGenerator(IAppContext context, InitPlugin plugin)
5859
/// </summary>
5960
/// <param name="context">The application context.</param>
6061
/// <param name="identity">The plug-in identity.</param>
61-
private void InitMenu(IAppContext context, PluginIdentity identity)
62+
private static void InitMenu(IAppContext context, PluginIdentity identity)
6263
{
6364
var menu = context.Menu.Items.AddDropDown("Template", "_", identity);
65+
menu.Icon = new MenuIcon(Resources.template_icon); // template by LAFS from the Noun Project
6466
menu.SubItems.AddButton("Info", MenuKeys.ShowDockableWindow, identity);
67+
68+
var submenu = menu.SubItems.AddDropDown("SubMenu", MenuKeys.SubMenu, identity);
69+
var btn = submenu.SubItems.AddButton("Foo", MenuKeys.Foo, identity);
70+
btn.Icon = new MenuIcon(Resources.hello_icon); // hello by Deemak Daksina from the Noun Project
71+
submenu.SubItems.AddButton("Bar", MenuKeys.Bar, identity);
6572
}
6673

6774
/// <summary>

src/Plugins/MW5.TemplatePlugin/Menu/MenuKeys.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ public class MenuKeys
1919
/// <summary>
2020
/// The menu item key. Used to identify which toolbar button or menu item was clicked.
2121
/// </summary>
22-
public const string ShowDockableWindow = "change this and make sure it is unique for all plug-ins";
22+
public const string ShowDockableWindow = "ShowDockableWindow - change this and make sure it is unique for all plug-ins";
23+
public const string SubMenu = "SubMenu - change this and make sure it is unique for all plug-ins";
24+
public const string Foo = "Foo - change this and make sure it is unique for all plug-ins";
25+
public const string Bar = "Bar - change this and make sure it is unique for all plug-ins";
2326

2427
#endregion
2528
}

src/Plugins/MW5.TemplatePlugin/Properties/Resources.Designer.cs

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Plugins/MW5.TemplatePlugin/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="hello_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\hello-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123+
</data>
121124
<data name="ico_template" type="System.Resources.ResXFileRef, System.Windows.Forms">
122125
<value>..\Resources\ico_template.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123126
</data>
124127
<data name="monitor" type="System.Resources.ResXFileRef, System.Windows.Forms">
125128
<value>..\Resources\monitor.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126129
</data>
130+
<data name="template_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
131+
<value>..\Resources\template-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
132+
</data>
127133
</root>
11.9 KB
Loading
6.8 KB
Loading

0 commit comments

Comments
 (0)