DesignerActionItem 类

定义

为表示智能标记面板上的面板项的类型提供基类。Provides the base class for types that represent a panel item on a smart tag panel.

public ref class DesignerActionItem abstract
public abstract class DesignerActionItem
type DesignerActionItem = class
Public MustInherit Class DesignerActionItem
继承
DesignerActionItem
派生

示例

下面的代码示例演示如何创建对象的DesignerActionItem集合。The following code example demonstrates how to create a collection of DesignerActionItem objects.

有关实现智能标记的完整示例, 请参阅如何:将智能标记附加到 Windows 窗体组件For a full example of implementing smart tags, see How to: Attach Smart Tags to a Windows Forms Component.

public override DesignerActionItemCollection GetSortedActionItems()
{
    DesignerActionItemCollection items = new DesignerActionItemCollection();

    //Define static section header entries.
    items.Add(new DesignerActionHeaderItem("Appearance"));
    items.Add(new DesignerActionHeaderItem("Information"));

    //Boolean property for locking color selections.
    items.Add(new DesignerActionPropertyItem("LockColors",
                     "Lock Colors", "Appearance",
                     "Locks the color properties."));
    if (!LockColors)
    {
        items.Add(new DesignerActionPropertyItem("BackColor",
                         "Back Color", "Appearance",
                         "Selects the background color."));
        items.Add(new DesignerActionPropertyItem("ForeColor",
                         "Fore Color", "Appearance",
                         "Selects the foreground color."));

        //This next method item is also added to the context menu 
        // (as a designer verb).
        items.Add(new DesignerActionMethodItem(this,
                         "InvertColors", "Invert Colors",
                         "Appearance",
                         "Inverts the fore and background colors.",
                          true));
    }
    items.Add(new DesignerActionPropertyItem("Text",
                     "Text String", "Appearance",
                     "Sets the display text."));

    //Create entries for static Information section.
    StringBuilder location = new StringBuilder("Location: ");
    location.Append(colLabel.Location);
    StringBuilder size = new StringBuilder("Size: ");
    size.Append(colLabel.Size);
    items.Add(new DesignerActionTextItem(location.ToString(),
                     "Information"));
    items.Add(new DesignerActionTextItem(size.ToString(),
                     "Information"));

    return items;
}
Public Overrides Function GetSortedActionItems() _
As DesignerActionItemCollection
    Dim items As New DesignerActionItemCollection()

    'Define static section header entries.
    items.Add(New DesignerActionHeaderItem("Appearance"))
    items.Add(New DesignerActionHeaderItem("Information"))

    'Boolean property for locking color selections.
    items.Add(New DesignerActionPropertyItem( _
    "LockColors", _
    "Lock Colors", _
    "Appearance", _
    "Locks the color properties."))

    If Not LockColors Then
        items.Add( _
        New DesignerActionPropertyItem( _
        "BackColor", _
        "Back Color", _
        "Appearance", _
        "Selects the background color."))

        items.Add( _
        New DesignerActionPropertyItem( _
        "ForeColor", _
        "Fore Color", _
        "Appearance", _
        "Selects the foreground color."))

        'This next method item is also added to the context menu 
        ' (as a designer verb).
        items.Add( _
        New DesignerActionMethodItem( _
        Me, _
        "InvertColors", _
        "Invert Colors", _
        "Appearance", _
        "Inverts the fore and background colors.", _
        True))
    End If
    items.Add( _
    New DesignerActionPropertyItem( _
    "Text", _
    "Text String", _
    "Appearance", _
    "Sets the display text."))

    'Create entries for static Information section.
    Dim location As New StringBuilder("Location: ")
    location.Append(colLabel.Location)
    Dim size As New StringBuilder("Size: ")
    size.Append(colLabel.Size)

    items.Add( _
    New DesignerActionTextItem( _
    location.ToString(), _
    "Information"))

    items.Add( _
    New DesignerActionTextItem( _
    size.ToString(), _
    "Information"))

    Return items
End Function

注解

DesignerActionItem类用作表示智能标记面板中各个面板项的类的抽象基类, 智能标记面板表示智能标记的类似菜单的用户界面 (UI)。The DesignerActionItem class serves as an abstract base for classes that represent individual panel items in a smart tag panel, which represents a menu-like user interface (UI) for smart tags. 提供派生类, 这些类表示智能标记面板中的不同常见项, 包括纯文本、标题文本、关联DesignerActionList类的属性和方法以及设计器谓词。 .NET Framework.NET FrameworkThe .NET Framework.NET Framework supplies derived classes that represent the different common entries in a smart tag panel, including plain text, header text, properties and methods of the associated DesignerActionList class, and designer verbs.

通常, 你DesignerAction的功能在从派生的DesignerActionList程序员提供的类中定义, 后者包含GetSortedActionItems一种方法, 该方法将各个面板项组合在一起以形成智能标记面板。Typically, your DesignerAction feature is defined in a programmer-supplied class derived from DesignerActionList, which contains a GetSortedActionItems method that groups individual panel items together to form the smart tag panel. 和类型与DesignerActionList派生自的DesignerActionMethodItem类的成员相关联, 当用户选择其关联的面板条目时, 将激活对象。 DesignerActionPropertyItem DesignerActionMethodItemThe DesignerActionPropertyItem and DesignerActionMethodItem types are associated with members of the class derived from DesignerActionList, and DesignerActionMethodItem objects are activated when their associated panel entry is selected by the user.

备注

窗体和对话框可由派生自DesignerActionList的类的成员显示。Forms and dialog boxes can be displayed by members of the class derived from DesignerActionList. 默认情况下, 这些窗口的父级将是智能标记面板的 "容器" 窗口。By default, the parent of these windows will be the container window for the smart tag panel. 将这些子窗口显式地父子到其他服务或窗口可能导致项显示不正确。Explicitly parenting these child windows to another service or window may cause items to display improperly.

构造函数

DesignerActionItem(String, String, String)

初始化 DesignerActionItem 类的新实例。Initializes a new instance of the DesignerActionItem class.

属性

AllowAssociate

获取或设置一个值,该值表示是否允许将此项放入具有相同 Category 属性值的一组项中。Gets or sets a value indicating whether to allow this item to be placed into a group of items that have the same Category property value.

Category

获取某个项的组名。Gets the group name for an item.

Description

获取项的补充文本。Gets the supplemental text for the item.

DisplayName

获取此项的文本。Gets the text for this item.

Properties

获取对一个集合的引用,该集合可用于存储程序员定义的键/值对。Gets a reference to a collection that can be used to store programmer-defined key/value pairs.

ShowInSourceView

获取或设置指示此项目是否在源代码视图中显示的值。Gets or sets a value that indicates whether this item appears in source code view.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅