-
Notifications
You must be signed in to change notification settings - Fork 1
SystemTray Addin
The SystemTray ExtensionPoint is one of our key productivity extension points defined by the path, /ToolsHub/SystemTray
. The definition for this can be found in the ToolsHub.addin.xml
manifest file.
Name | Type |
---|---|
ExtensionPoint Path | /ToolsHub/SystemTray |
ExtensionNode | SysTrayAddin |
Below are some examples of how to create add-ins which extend the application NotificationIcon in the SystemTray.
ToolsHub.addin.xml
manifest file declares the extension point using the following code.
<ExtensionPoint path="/ToolsHub/SystemTray">
<ExtensionNode name="SysTrayAddin" objectType="Xeno.ToolsHub.ExtensionModel.SystemTray.SysTrayAddin" />
</ExtensionPoint>
Remember, you'll need to set your Example.addin
as an Embeded Resource in Visual Studio's Properties window.
File: Example.addin
<?xml version="1.0" encoding="utf-8" ?>
<ExtensionModel>
<Extension path="/ToolsHub/SystemTray">
<SysTrayAddin type="Xeno.ToolsHub.LocalAddins.ExampleSysTray.ExampleSysTrayAddin " />
</Extension>
</ExtensionModel>
Now you'll need the C# class to wire into
using System.Collections.Generic;
using System.Windows.Forms;
namespace Xeno.ToolsHub.LocalAddins.ExampleSysTray
{
public class ExampleSysTrayAddin : Xeno.ToolsHub.ExtensionModel.SystemTray.SysTrayAddin
{
public string Title => "Example SysTray Add-in";
public override List<MenuItem> MenuItems()
{
var items = new List<MenuItem>();
items.Add(new MenuItem("Sample Item Text"));
return items;
}
}
}
If we wanted to use pure C# code and not create an XML manifest file, we could easily do so using the following example.
Notice how clean the example is. It only takes 3 lines of code (really one), and no need to create an XML file, or having to worry about typos in your manifest file. Honestly, this is recommended for first-timers.
using System.Collections.Generic;
using System.Windows.Forms;
namespace Xeno.ToolsHub.LocalAddins.ExampleSysTray
{
[Mono.Addins.Extension(Id = "ExampleSysTrayAddin",
NodeName = "SysTrayAddin",
Path = "/ToolsHub/SystemTray")]
public class ExampleSysTrayAddin : Xeno.ToolsHub.ExtensionModel.SystemTray.SysTrayAddin
{
public string Title => "Example SysTray Add-in";
public override List<MenuItem> MenuItems()
{
var items = new List<MenuItem>();
items.Add(new MenuItem("Sample Item Text"));
return items;
}
}
}
- Home
- ToolsHub Architecture
- Addin ExtensionPoints
- Creating an Add-in
- Design Docs
- Feature Requests
- FAQ