MenuItem Class

Assembly: CodeEffects.Rule.Editor.dll
Namespace: CodeEffects.Rule.Editor.Models

Summary

This class is used to hold rule items in the ToolBarRules, ContextMenuRules, and InlineRules collections of the Control class, and in the collection returned by ISourceProvider.GetInlineRules().

The editor names a rule that a loaded rule calls or executes from these items. An item whose NotOffered property is true is used only for that: its name is shown, but it is never offered in a menu.

Syntax

public class MenuItem

Constructors

  • Initializes a new instance of the class. The ID property is set to Guid.Empty in string form, so set it before you use the item.

    Parameters

    • None.
  • Initializes a new instance of the class with an ID and a display name.

    Parameters

    • id (System.String) - The ID of the menu item. Sets the ID property.
    • displayName (System.String) - The display name of the menu item. Sets the DisplayName property.
  • Initializes a new instance of the class with an ID, a display name, and a description.

    Parameters

    • id (System.String) - The ID of the menu item. Sets the ID property.
    • displayName (System.String) - The display name of the menu item. Sets the DisplayName property.
    • description (System.String) - The description of the menu item. Sets the Description property.
  • Initializes a new instance of the class with an ID, a display name, a description, and the name of the source object. The source name is for internal use and the editor ignores it in the collections described above.

    Parameters

    • id (System.String) - The ID of the menu item. Sets the ID property.
    • displayName (System.String) - The display name of the menu item. Sets the DisplayName property.
    • description (System.String) - The description of the menu item. Sets the Description property.
    • sourceName (System.String) - The name of the source object the item belongs to. There is no public property for it.

Properties

  • Description

    Type: System.String

    Gets or sets the description of the menu item. If set, the Help String displays this description when the menu item is selected. This property is optional.

  • DisplayName

    Type: System.String

    Gets or sets the display name of the menu item. This property is required.

  • ID

    Type: System.String

    Gets or sets the ID of the menu item. This property is required. For a rule, this is the rule's ID.

  • NotOffered

    Type: System.Boolean

    Gets or sets whether the editor only names the rule and never offers it. Set it for a rule that a stored rule still calls or executes but that can no longer be picked, for example a rule taken out of use, so that the stored rule shows the rule's name instead of its ID. Applies to ContextMenuRules, InlineRules, and the items returned by ISourceProvider.GetInlineRules(); such items are left out of ToolBarRules. Offering is not validity: the editor validates a call to such a rule as it validates any other call. The default is false. This property is optional.

Methods

  • ToString

    Returns: System.String

    Not intended for public use. The editor calls this method to write the item as JSON for its client-side menus.

    Parameters

    • _ (System.Boolean) - Not used. Reserved for future use.

Example

var editor = new Control("divEditor");

editor.ToolBarRules = new List<MenuItem>
{
	new MenuItem("0d7a1b3e-5c1f-4e0a-9d52-6a0f3b7c2e11", "Premium customers", "Customers with the Premium plan")
};

// Offered in the menus, and a retired rule that stored rules still call: named, never offered
editor.ContextMenuRules = new List<MenuItem>
{
	new MenuItem("0d7a1b3e-5c1f-4e0a-9d52-6a0f3b7c2e11", "Premium customers"),
	new MenuItem("5b2e8c41-7d3a-4f6e-a1c9-2e4d6f8a0b13", "Legacy discount") { NotOffered = true }
};

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×