Use Case
| • | You want to add items to the ImageViewerComponent's context menu at compile time. |
Relevant Architecture
Relevant Types/Files
| • | MenuActionAttribute |
| • | ClearCanvas.Desktop.Executable.exe.config |
Sample Code
using ClearCanvas.Common;
using ClearCanvas.Desktop;
using ClearCanvas.Desktop.Actions;
using ClearCanvas.ImageViewer;
using ClearCanvas.ImageViewer.BaseTools;
// ... (other using namespace statements here)
namespace MyPlugin.Imaging
{
[ButtonAction("apply", "global-toolbars/ToolbarStandard/ApplyMyTool", "Apply")]
[MenuAction("apply", "imageviewer-contextmenu/ApplyMyTool", "Apply")]
[IconSet("apply", IconScheme.Colour, "Icons.MyToolSmall.png", "Icons.MyToolMedium.png", "Icons.MyToolLarge.png")]
// ... (other action attributes here)
[ExtensionOf(typeof (ImageViewerToolExtensionPoint))]
public class ContextMenuTool : ImageViewerTool
{
public void Apply() {}
}
}
<action-models>
<action-model id="ClearCanvas.ImageViewer.DiagnosticImageViewerComponent:imageviewer-contextmenu">
<action id="ClearCanvas.ImageViewer.Tools.Standard.StackTool:activate"
path="imageviewer-contextmenu/MenuStack" group-hint="Tools.Image.Manipulation.Stacking.Standard" />
<action id="ClearCanvas.ImageViewer.Tools.Standard.WindowLevelTool:activate"
path="imageviewer-contextmenu/MenuWindowLevel" group-hint="Tools.Image.Manipulation.Lut.WindowLevel" />
</action-model>
</action-models>
Remarks
Adding an image viewer context menu item can be accomplished by decorating the class of the tool you want added with a MenuAction attribute. The site portion of the path must be "imageviewer-contextmenu". To affect the ordering of the menu item in the context menu, do you as you would with any other menu by adding the appropriate entries to the ClearCanvas.Desktop.Executable.exe.config (see this for the significance of these files.)
Examples in Code Base
| • | ClearCanvas.ImageViewer.Tools.Standard.WindowLevelTool |