If you are using the example below you will also need to add using System.Runtime.InteropServices statement and using System.Windows.Forms statement to the project. If you would like to work from the example code you can copy it into the project at this stage. If chose to copy the code then you will need to create your own GUID and replace the example GUID where ever it appears in the example, generate property stubs for Cmd1 and Cmd2, and replace the sample icon location with the real location of your chosen icon.
HotDocs.Application app = new HotDocs.Application(); app.Plugins.Register("{12345678-1111-2222-AAAA-DDDDDDDDDDDD}", "Sample Menu Plugin", 100, 1);
C:\>Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe "C:\Program Files (x86)\HotDocs\WindowMenuExtension.dll" /codebase
The following Visual C# example implements the ILibraryWindowMenuExtension interface:
[ComVisible(true)] [Guid("12345678-1111-2222-AAAA-DDDDDDDDDDDD")] public class WindowMenuExt : HotDocs.ILibraryWindowMenuExtension { public void Command(string libraryPath, LibraryEntity caretEntry, int commandId) {
if (commandId == cmd1)
System.Diagnostics.Process.Start("http://www.hotdocs.com");
if (commandId == cmd2)
MessageBox.Show("Menu sample w/icon selected");
}
public void DisplayMenuInitialize(string libraryPath, LibraryEntity caretEntry)
{
MessageBox.Show(caretEntry.Title);
}
public void GetMenuEntry(int menuPosition, ref string menuText, ref Icon Icon, ref bool enabled, ref bool callAgain, int commandId)
{
HotDocs.Icon icon = new Icon();
icon.LoadIcon(@"C:\images\MenuEntry.ico");
switch (menuPosition)
{
case 0:
menuText = "HotDocs Website";
enabled = true;
callAgain = true;
cmd1 = commandId;
break;
case 1:
//Add a separator
menuText = "-";
enabled = false;
break;
case 2:
menuText = "Menu Sample w/icon";
Icon = icon;
enabled = true;
callAgain = false;
cmd2 = commandId;
break;
default:
break;
}
}
public void GetMenuTitle(ref string menuTitle)
{
menuTitle = "Menu Ext Plugin";
}
public void Initialize()
{
//Do any one time initialization
}
public void LibraryInitialized()
{
MessageBox.Show("The library has been initialized");
}
[ComRegisterFunction]
public static void RegisterPlugin(Type t)
{
HotDocs.Application app = new HotDocs.Application();
app.Plugins.Register("{12345678-1111-2222-AAAA-DDDDDDDDDDDD}", "Sample Menu Plugin", 100, 1);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app); }
[ComUnregisterFunction]
public static void UnRegisterPlugin(Type t)
{
HotDocs.Application app = new HotDocs.Application();
app.Plugins.Unregister("{12345678-1111-2222-AAAA-DDDDDDDDDDDD}");
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
}
}