Table of Contents

Class MenuResource

Namespace
CADability.UserInterface
Assembly
CADability.dll

The MenuResource class provides methods to load and manipulate a menu resource that is used by CADability and its applications to compose the main menu, popup and context menues.

public class MenuResource
Inheritance
MenuResource
Inherited Members

Constructors

MenuResource()

public MenuResource()

Methods

AddMenuResource(Stream)

Adds all subnodes of "CustomMenus" to the standard menu resource (e.g. additional context menus).

public static void AddMenuResource(Stream XmlStream)

Parameters

XmlStream Stream

Stream containing the XML document

CreateContextMenuWithHandler(string[], ICommandHandler)

Creates a flat context menu from the provided menu ids. The text of each entry is looked up in the StringTable with the menu id as resource id, all entries use the provided command handler.

public static MenuWithHandler[] CreateContextMenuWithHandler(string[] menuIDs, ICommandHandler Handler)

Parameters

menuIDs string[]

Ids of the menu entries

Handler ICommandHandler

Command handler which handles the menu commands

Returns

MenuWithHandler[]

The menu entries

FindImageIndex(string)

Returns the image index (the "IconNr" attribute) of the menu item or popup menu with the given id, as used for the toolbar buttons.

public static int FindImageIndex(string MenuID)

Parameters

MenuID string

Id of the menu item or popup menu

Returns

int

The image index, or -1 if there is no such item or it has no icon

GetPopupItems(string)

Returns the ids of the menu items directly contained in the popup menu MenuName of the menu resource, in the order of their definition. Nested popups are not included.

public static string[] GetPopupItems(string MenuName)

Parameters

MenuName string

Id of the popup menu

Returns

string[]

The menu ids; an empty array if there is no such popup

IsPopup(string)

Returns true if the provided name is a popup menu (context menu)

public static bool IsPopup(string MenuName)

Parameters

MenuName string

Returns

bool

LoadMenuDefinition(string, bool, ICommandHandler)

Loads a menu from the menu resource with the provided name. For the unmodified standard resource the name of the main menu will be "SDI Menu"

public static MenuWithHandler[] LoadMenuDefinition(string MenuName, bool main, ICommandHandler handler)

Parameters

MenuName string

Name of the menu to load: the "Name" attribute of a "MainMenu" node or the "MenuId" attribute of a "Popup" node

main bool

true to load a main menu, false to load a popup (context) menu

handler ICommandHandler

Command handler which handles the menu commands

Returns

MenuWithHandler[]

The menu entries, an empty array if there is no menu with this name (e.g. for a null name)

ReplaceMenus(Stream)

replaces all popup menus contained in subnodes of "CustomMenus" of the provided document.

public static void ReplaceMenus(Stream XmlStream)

Parameters

XmlStream Stream

Stream containing the XML document

SetMenuResource(Stream)

Replaces the standard menu resource by the provided XML document

public static void SetMenuResource(Stream XmlStream)

Parameters

XmlStream Stream

The document opend as a stream

SetMenuResource(XmlDocument)

Replaces the standard menu resource by the provided XML document

public static void SetMenuResource(XmlDocument XmlMenuDocument)

Parameters

XmlMenuDocument XmlDocument

The document