ComponentDesigner ComponentDesigner ComponentDesigner ComponentDesigner Class

Definición

Extiende el comportamiento de un componente en modo de diseño.Extends the design mode behavior of a component.

public ref class ComponentDesigner : IDisposable, System::ComponentModel::Design::IComponentInitializer, System::ComponentModel::Design::IDesignerFilter, System::ComponentModel::Design::ITreeDesigner
public class ComponentDesigner : IDisposable, System.ComponentModel.Design.IComponentInitializer, System.ComponentModel.Design.IDesignerFilter, System.ComponentModel.Design.ITreeDesigner
type ComponentDesigner = class
    interface ITreeDesigner
    interface IDesigner
    interface IDisposable
    interface IDesignerFilter
    interface IComponentInitializer
Public Class ComponentDesigner
Implements IComponentInitializer, IDesignerFilter, IDisposable, ITreeDesigner
Herencia
ComponentDesignerComponentDesignerComponentDesignerComponentDesigner
Derivado
Implementaciones

Ejemplos

En el ejemplo de código siguiente se ComponentDesigner proporciona una implementación de ejemplo y un componente de ejemplo asociado al diseñador.The following code example provides an example ComponentDesigner implementation and an example component associated with the designer. El diseñador implementa Initialize una invalidación del método que llama al método base Initialize DoDefaultAction , una invalidación del método que muestra MessageBox cuando Verbs se hace doble clic en el componente, y una invalidación del descriptor de acceso de DesignerVerb propiedad que proporciona un comando de menú personalizado al menú contextual del componente.The designer implements an override of the Initialize method that calls the base Initialize method, an override of the DoDefaultAction method that displays a MessageBox when the component is double-clicked, and an override of the Verbs property accessor that supplies a custom DesignerVerb menu command to the shortcut menu for the component.

#using <System.dll>
#using <System.Design.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Windows::Forms;

// Provides an example component designer.
ref class ExampleComponentDesigner: public ComponentDesigner
{
public:
   ExampleComponentDesigner()
   {
   }

   // This method provides an opportunity to perform processing when a designer is initialized.
   // The component parameter is the component that the designer is associated with.
   virtual void Initialize( IComponent^ component ) override
   {
      // Always call the base Initialize method in an of this method.
      ComponentDesigner::Initialize( component );
   }

   // This method is invoked when the associated component is double-clicked.
   virtual void DoDefaultAction() override
   {
      MessageBox::Show( "The event handler for the default action was invoked." );
   }

   // This method provides designer verbs.
   property DesignerVerbCollection^ Verbs 
   {
      virtual DesignerVerbCollection^ get() override
      {
         array<DesignerVerb^>^ newDesignerVerbs = {gcnew DesignerVerb( "Example Designer Verb Command", gcnew EventHandler( this, &ExampleComponentDesigner::onVerb ) )};
         return gcnew DesignerVerbCollection( newDesignerVerbs );
      }
   }

private:
   // Event handling method for the example designer verb
   void onVerb( Object^ sender, EventArgs^ e )
   {
      MessageBox::Show( "The event handler for the Example Designer Verb Command was invoked." );
   }
};

// Provides an example component associated with the example component designer.

[DesignerAttribute(ExampleComponentDesigner::typeid, IDesigner::typeid)]
ref class ExampleComponent: public Component
{
public:
   ExampleComponent(){}
};
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;

namespace ExampleComponent
{	
    // Provides an example component designer.
    public class ExampleComponentDesigner : System.ComponentModel.Design.ComponentDesigner
    {
        public ExampleComponentDesigner()
        {
        }

        // This method provides an opportunity to perform processing when a designer is initialized.
        // The component parameter is the component that the designer is associated with.
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            // Always call the base Initialize method in an override of this method.
            base.Initialize(component);
        }

        // This method is invoked when the associated component is double-clicked.
        public override void DoDefaultAction()
        {
            MessageBox.Show("The event handler for the default action was invoked.");
        }

        // This method provides designer verbs.
        public override System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
            get
            {
                return new DesignerVerbCollection( new DesignerVerb[] { new DesignerVerb("Example Designer Verb Command", new EventHandler(this.onVerb)) } );
            }
        }

        // Event handling method for the example designer verb
        private void onVerb(object sender, EventArgs e)
        {
            MessageBox.Show("The event handler for the Example Designer Verb Command was invoked.");
        }
    }

    // Provides an example component associated with the example component designer.
    [DesignerAttribute(typeof(ExampleComponentDesigner), typeof(IDesigner))]
    public class ExampleComponent : System.ComponentModel.Component
    {		
        public ExampleComponent()
        {
        }
    }
}
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms

Namespace ExampleComponent

    ' Provides an example component designer.
    Public Class ExampleComponentDesigner
        Inherits System.ComponentModel.Design.ComponentDesigner

        Public Sub New()
        End Sub

        ' This method provides an opportunity to perform processing when a designer is initialized.
        ' The component parameter is the component that the designer is associated with.
        Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
            ' Always call the base Initialize method in an override of this method.
            MyBase.Initialize(component)
        End Sub

        ' This method is invoked when the associated component is double-clicked.
        Public Overrides Sub DoDefaultAction()
            MessageBox.Show("The event handler for the default action was invoked.")
        End Sub

        ' This method provides designer verbs.
        Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
            Get
                Return New DesignerVerbCollection(New DesignerVerb() {New DesignerVerb("Example Designer Verb Command", New EventHandler(AddressOf Me.onVerb))})
            End Get
        End Property

        ' Event handling method for the example designer verb
        Private Sub onVerb(ByVal sender As Object, ByVal e As EventArgs)
            MessageBox.Show("The event handler for the Example Designer Verb Command was invoked.")
        End Sub
    End Class 'ExampleComponentDesigner

    ' Provides an example component associated with the example component designer.
    <DesignerAttribute(GetType(ExampleComponentDesigner), GetType(IDesigner))> _
     Public Class ExampleComponent
        Inherits System.ComponentModel.Component

        Public Sub New()
        End Sub
    End Class 'ExampleComponent

End Namespace 'ExampleComponent

Comentarios

La ComponentDesigner clase base del diseñador proporciona un diseñador simple que puede extender el comportamiento de un componente asociado en el modo de diseño.The ComponentDesigner base designer class provides a simple designer that can extend the behavior of an associated component in design mode.

ComponentDesignerproporciona una implementación IDesignerFilter de interfaz vacía, cuyos métodos se pueden invalidar para ajustar los atributos, propiedades y eventos del componente asociado en tiempo de diseño.ComponentDesigner provides an empty IDesignerFilter interface implementation, whose methods can be overridden to adjust the attributes, properties and events of the associated component at design time.

Puede asociar un diseñador a un tipo mediante DesignerAttribute.You can associate a designer with a type using a DesignerAttribute. Para obtener información general sobre cómo personalizar el comportamiento en tiempo de diseño, vea extender la compatibilidad en tiempo de diseño.For an overview of customizing design-time behavior, see Extending Design-Time Support.

La ComponentDesigner clase implementa un comportamiento especial para los descriptores de propiedad de los componentes heredados.The ComponentDesigner class implements a special behavior for the property descriptors of inherited components. La implementación predeterminada ComponentDesigner usa InheritedPropertyDescriptor un tipo interno denominado para las propiedades que se heredan de una clase base.An internal type named InheritedPropertyDescriptor is used by the default ComponentDesigner implementation to stand in for properties that are inherited from a base class. Hay dos casos en los que se agregan estos descriptores de propiedad.There are two cases in which these property descriptors are added.

  1. Al propio objeto raíz, devuelto por la IDesignerHost.RootComponent propiedad, porque se hereda de su clase base.To the root object itself, which is returned by the IDesignerHost.RootComponent property, because you are inheriting from its base class.

  2. En los campos que se encuentran en la clase base del objeto raíz.To fields found in the base class of the root object. Los campos públicos y protegidos de la clase base se agregan al diseñador para que los pueda manipular el usuario.Public and protected fields from the base class are added to the designer so that they can be manipulated by the user.

La InheritedPropertyDescriptor clase modifica el valor predeterminado de una propiedad, por lo que el valor predeterminado es el valor actual en la creación de instancias de objeto.The InheritedPropertyDescriptor class modifies the default value of a property, so that the default value is the current value at object instantiation. Esto se debe a que la propiedad se hereda de otra instancia.This is because the property is inherited from another instance. El diseñador define el restablecimiento del valor de propiedad como si se establece en el valor establecido por la clase heredada.The designer defines resetting the property value as setting it to the value that was set by the inherited class. Este valor puede diferir del valor predeterminado almacenado en los metadatos.This value may differ from the default value stored in metadata.

Constructores

ComponentDesigner() ComponentDesigner() ComponentDesigner() ComponentDesigner()

Inicializa una nueva instancia de la clase ComponentDesigner.Initializes a new instance of the ComponentDesigner class.

Propiedades

ActionLists ActionLists ActionLists ActionLists

Obtiene las listas de acciones en tiempo de diseño que admite el componente asociado al diseñador.Gets the design-time action lists supported by the component associated with the designer.

AssociatedComponents AssociatedComponents AssociatedComponents AssociatedComponents

Obtiene la colección de componentes asociados al componente administrado por el diseñador.Gets the collection of components associated with the component managed by the designer.

Component Component Component Component

Obtiene el componente que el diseñador está creando.Gets the component this designer is designing.

InheritanceAttribute InheritanceAttribute InheritanceAttribute InheritanceAttribute

Obtiene un atributo que indica el tipo de herencia del componente asociado.Gets an attribute that indicates the type of inheritance of the associated component.

Inherited Inherited Inherited Inherited

Obtiene un valor que indica si este componente es heredado.Gets a value indicating whether this component is inherited.

ParentComponent ParentComponent ParentComponent ParentComponent

Obtiene el componente primario de este diseñador.Gets the parent component for this designer.

ShadowProperties ShadowProperties ShadowProperties ShadowProperties

Obtiene una colección de valores de propiedad que reemplazan la configuración del usuario.Gets a collection of property values that override user settings.

Verbs Verbs Verbs Verbs

Obtiene los verbos en tiempo de diseño que admite el componente asociado al diseñador.Gets the design-time verbs supported by the component that is associated with the designer.

Métodos

Dispose() Dispose() Dispose() Dispose()

Libera todos los recursos que usa ComponentDesigner.Releases all resources used by the ComponentDesigner.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Libera los recursos no administrados que usa ComponentDesigner y, de forma opcional, libera los recursos administrados.Releases the unmanaged resources used by the ComponentDesigner and optionally releases the managed resources.

DoDefaultAction() DoDefaultAction() DoDefaultAction() DoDefaultAction()

Crea una firma de método en el archivo de código fuente para el evento predeterminado del componente y hace navegar el cursor del usuario en esa ubicación.Creates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Intenta liberar los recursos mediante una llamada a Dispose(false) antes de que el objeto sea reclamado por la recolección de elementos no utilizados.Attempts to free resources by calling Dispose(false) before the object is reclaimed by garbage collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Intenta recuperar el tipo de servicio especificado del sitio en modo de diseño del componente del diseñador.Attempts to retrieve the specified type of service from the design mode site of the designer's component.

GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
Initialize(IComponent) Initialize(IComponent) Initialize(IComponent) Initialize(IComponent)

Prepara el diseñador para ver, modificar y diseñar el componente especificado.Prepares the designer to view, edit, and design the specified component.

InitializeExistingComponent(IDictionary) InitializeExistingComponent(IDictionary) InitializeExistingComponent(IDictionary) InitializeExistingComponent(IDictionary)

Reinicializa un componente existente.Reinitializes an existing component.

InitializeNewComponent(IDictionary) InitializeNewComponent(IDictionary) InitializeNewComponent(IDictionary) InitializeNewComponent(IDictionary)

Inicializa un componente recién creado.Initializes a newly created component.

InitializeNonDefault() InitializeNonDefault() InitializeNonDefault() InitializeNonDefault()

Inicializa la configuración de un componente importado que ya se ha inicializado con una configuración que no es la predeterminada.Initializes the settings for an imported component that is already initialized to settings other than the defaults.

InvokeGetInheritanceAttribute(ComponentDesigner) InvokeGetInheritanceAttribute(ComponentDesigner) InvokeGetInheritanceAttribute(ComponentDesigner) InvokeGetInheritanceAttribute(ComponentDesigner)

Obtiene el objeto InheritanceAttribute de la enumeración ComponentDesigner especificada.Gets the InheritanceAttribute of the specified ComponentDesigner.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
OnSetComponentDefaults() OnSetComponentDefaults() OnSetComponentDefaults() OnSetComponentDefaults()

Establece las propiedades predeterminadas del componente.Sets the default properties for the component.

PostFilterAttributes(IDictionary) PostFilterAttributes(IDictionary) PostFilterAttributes(IDictionary) PostFilterAttributes(IDictionary)

Permite a un diseñador cambiar o quitar elementos en el conjunto de atributos que expone mediante un TypeDescriptor.Allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor.

PostFilterEvents(IDictionary) PostFilterEvents(IDictionary) PostFilterEvents(IDictionary) PostFilterEvents(IDictionary)

Permite a un diseñador cambiar o quitar elementos del conjunto de eventos que expone mediante un objeto TypeDescriptor.Allows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor.

PostFilterProperties(IDictionary) PostFilterProperties(IDictionary) PostFilterProperties(IDictionary) PostFilterProperties(IDictionary)

Permite a un diseñador cambiar o quitar elementos del conjunto de propiedades que expone mediante un objeto TypeDescriptor.Allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor.

PreFilterAttributes(IDictionary) PreFilterAttributes(IDictionary) PreFilterAttributes(IDictionary) PreFilterAttributes(IDictionary)

Permite a un diseñador agregar elementos al conjunto de atributos que expone mediante un objeto TypeDescriptor.Allows a designer to add to the set of attributes that it exposes through a TypeDescriptor.

PreFilterEvents(IDictionary) PreFilterEvents(IDictionary) PreFilterEvents(IDictionary) PreFilterEvents(IDictionary)

Permite a un diseñador agregar elementos al conjunto de eventos que expone mediante un objeto TypeDescriptor.Allows a designer to add to the set of events that it exposes through a TypeDescriptor.

PreFilterProperties(IDictionary) PreFilterProperties(IDictionary) PreFilterProperties(IDictionary) PreFilterProperties(IDictionary)

Permite a un diseñador agregar elementos al conjunto de propiedades que expone mediante un objeto TypeDescriptor.Allows a designer to add to the set of properties that it exposes through a TypeDescriptor.

RaiseComponentChanged(MemberDescriptor, Object, Object) RaiseComponentChanged(MemberDescriptor, Object, Object) RaiseComponentChanged(MemberDescriptor, Object, Object) RaiseComponentChanged(MemberDescriptor, Object, Object)

Notifica a IComponentChangeService que este componente se ha cambiado.Notifies the IComponentChangeService that this component has been changed.

RaiseComponentChanging(MemberDescriptor) RaiseComponentChanging(MemberDescriptor) RaiseComponentChanging(MemberDescriptor) RaiseComponentChanging(MemberDescriptor)

Notifica a IComponentChangeService que este componente se va a cambiar.Notifies the IComponentChangeService that this component is about to be changed.

ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

IDesignerFilter.PostFilterAttributes(IDictionary) IDesignerFilter.PostFilterAttributes(IDictionary) IDesignerFilter.PostFilterAttributes(IDictionary) IDesignerFilter.PostFilterAttributes(IDictionary)

Para obtener una descripción de este miembro, vea el método PostFilterAttributes(IDictionary).For a description of this member, see the PostFilterAttributes(IDictionary) method.

IDesignerFilter.PostFilterEvents(IDictionary) IDesignerFilter.PostFilterEvents(IDictionary) IDesignerFilter.PostFilterEvents(IDictionary) IDesignerFilter.PostFilterEvents(IDictionary)

Para obtener una descripción de este miembro, vea el método PostFilterEvents(IDictionary).For a description of this member, see the PostFilterEvents(IDictionary) method.

IDesignerFilter.PostFilterProperties(IDictionary) IDesignerFilter.PostFilterProperties(IDictionary) IDesignerFilter.PostFilterProperties(IDictionary) IDesignerFilter.PostFilterProperties(IDictionary)

Para obtener una descripción de este miembro, vea el método PostFilterProperties(IDictionary).For a description of this member, see the PostFilterProperties(IDictionary) method.

IDesignerFilter.PreFilterAttributes(IDictionary) IDesignerFilter.PreFilterAttributes(IDictionary) IDesignerFilter.PreFilterAttributes(IDictionary) IDesignerFilter.PreFilterAttributes(IDictionary)

Para obtener una descripción de este miembro, vea el método PreFilterAttributes(IDictionary).For a description of this member, see the PreFilterAttributes(IDictionary) method.

IDesignerFilter.PreFilterEvents(IDictionary) IDesignerFilter.PreFilterEvents(IDictionary) IDesignerFilter.PreFilterEvents(IDictionary) IDesignerFilter.PreFilterEvents(IDictionary)

Para obtener una descripción de este miembro, vea el método PreFilterEvents(IDictionary).For a description of this member, see the PreFilterEvents(IDictionary) method.

IDesignerFilter.PreFilterProperties(IDictionary) IDesignerFilter.PreFilterProperties(IDictionary) IDesignerFilter.PreFilterProperties(IDictionary) IDesignerFilter.PreFilterProperties(IDictionary)

Para obtener una descripción de este miembro, vea el método PreFilterProperties(IDictionary).For a description of this member, see the PreFilterProperties(IDictionary) method.

ITreeDesigner.Children ITreeDesigner.Children ITreeDesigner.Children ITreeDesigner.Children

Para una descripción de este miembro, consulte la propiedad Children.For a description of this member, see the Children property.

ITreeDesigner.Parent ITreeDesigner.Parent ITreeDesigner.Parent ITreeDesigner.Parent

Para una descripción de este miembro, consulte la propiedad Parent.For a description of this member, see the Parent property.

Se aplica a

Consulte también: