///<summary> ///Constructor. ///</summary> /// <param name="parentLocation">Parent location</param> /// <param name="parentName">Parent name</param> /// <param name="name">Name</param> /// <param name="shortcut">Shortcut</param> /// <param name="text">Text</param> /// <param name="enabled">Enabled</param> /// <param name="visible">Visible</param> /// <param name="isChecked">Check state</param> /// <param name="executed">Execute event handler</param> protected CustomMenuNode( MenuItemLocation parentLocation, string parentName, string name, int shortcut, string text, bool enabled, bool visible, bool isChecked, EventHandler executed ): base(name) { this.text = text; this.enabled = enabled; this.visible = visible; this.executed += executed; this.shortcut = shortcut; this.parentName = parentName; this.isChecked = isChecked; // This.help = new HelpString(this); switch(parentLocation) { case MenuItemLocation.After: this.parentLocation = OTAMenuItemLocation.otamlAfter; break; case MenuItemLocation.Before: this.parentLocation = OTAMenuItemLocation.otamlBefore; break; case MenuItemLocation.Child: this.parentLocation = OTAMenuItemLocation.otamlChild; break; default: this.parentLocation = OTAMenuItemLocation.otamlChild; break; } }
///<summary>Inserts a menu item with bitmap/icon</summary> /// <param name="parentName">Name of its parent menu item</param> /// <param name="location">Location related to the parent</param> /// <param name="name">Name of the menu item</param> /// <param name="text">Text shown</param> /// <param name="executed">Envent handler</param> /// <param name="visible">Flag of visible</param> ///<param name="enabled">Flag of enabled</param> /// <param name="isChecked">Check state</param> /// <param name="imageName">Image name</param> public static IOTAMenuItem AddMenuItem( string parentName, OTAMenuItemLocation location, string name, string text, EventHandler executed, bool visible, bool enabled, bool isChecked, string imageName) { Trace.Assert(parentName != null); Trace.Assert(name != null); Trace.Assert(text != null); Trace.Assert(imageName != null); IOTAMenuItem item = AddMenuItem(parentName, location, name, text, imageName); if (item != null) { item.Enabled = enabled; item.Visible = visible; item.Executed += executed; item.Checked = isChecked; } else { LoggingService.Warn("null menu item"); } return item; }