ComponentDesigner Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Estende il comportamento della modalità progettazione di un componente.
public ref class ComponentDesigner : IDisposable, System::ComponentModel::Design::IDesigner, System::ComponentModel::Design::IDesignerFilter
public ref class ComponentDesigner : IDisposable, System::ComponentModel::Design::IComponentInitializer, System::ComponentModel::Design::IDesignerFilter, System::ComponentModel::Design::ITreeDesigner
public class ComponentDesigner : IDisposable, System.ComponentModel.Design.IDesigner, System.ComponentModel.Design.IDesignerFilter
public class ComponentDesigner : IDisposable, System.ComponentModel.Design.IComponentInitializer, System.ComponentModel.Design.IDesignerFilter, System.ComponentModel.Design.ITreeDesigner
type ComponentDesigner = class
interface IDesigner
interface IDisposable
interface IDesignerFilter
type ComponentDesigner = class
interface ITreeDesigner
interface IDesigner
interface IDisposable
interface IDesignerFilter
interface IComponentInitializer
Public Class ComponentDesigner
Implements IDesigner, IDesignerFilter, IDisposable
Public Class ComponentDesigner
Implements IComponentInitializer, IDesignerFilter, IDisposable, ITreeDesigner
- Ereditarietà
-
ComponentDesigner
- Derivato
- Implementazioni
Esempio
Nell'esempio di codice seguente viene fornita un'implementazione di esempio e un componente di esempio ComponentDesigner associato alla finestra di progettazione. La finestra di progettazione implementa un override del metodo che chiama il Initialize metodo di base Initialize , un override del DoDefaultAction metodo che visualizza un MessageBox oggetto quando si fa doppio clic sul componente e un override della funzione di accesso alla Verbs proprietà che fornisce un comando di menu personalizzato DesignerVerb al menu di scelta rapida per il componente.
#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
' 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
End Namespace 'ExampleComponent
Commenti
La ComponentDesigner classe di progettazione di base fornisce una finestra di progettazione semplice che può estendere il comportamento di un componente associato in modalità progettazione.
ComponentDesigner fornisce un'implementazione di interfaccia vuota IDesignerFilter , i cui metodi possono essere sottoposti a override per regolare gli attributi, le proprietà e gli eventi del componente associato in fase di progettazione.
È possibile associare una finestra di progettazione a un tipo usando un oggetto DesignerAttribute. Per una panoramica della personalizzazione del comportamento in fase di progettazione, vedere Estensione del supporto Design-Time.
La ComponentDesigner classe implementa un comportamento speciale per i descrittori di proprietà dei componenti ereditati. Un tipo interno denominato InheritedPropertyDescriptor viene usato dall'implementazione predefinita ComponentDesigner per mantenere le proprietà ereditate da una classe di base. Esistono due casi in cui vengono aggiunti questi descrittori di proprietà.
Per l'oggetto radice stesso, restituito dalla IDesignerHost.RootComponent proprietà , perché si eredita dalla relativa classe di base.
Per i campi trovati nella classe di base dell'oggetto radice. I campi pubblici e protetti dalla classe di base vengono aggiunti alla finestra di progettazione in modo che possano essere modificati dall'utente.
La InheritedPropertyDescriptor classe modifica il valore predefinito di una proprietà, in modo che il valore predefinito sia il valore corrente alla creazione di istanze dell'oggetto. Ciò è dovuto al fatto che la proprietà viene ereditata da un'altra istanza. La finestra di progettazione definisce la reimpostazione del valore della proprietà impostandolo sul valore impostato dalla classe ereditata. Questo valore può differire dal valore predefinito archiviato nei metadati.
Costruttori
| Nome | Descrizione |
|---|---|
| ComponentDesigner() |
Inizializza una nuova istanza della classe ComponentDesigner. |
Proprietà
| Nome | Descrizione |
|---|---|
| ActionLists |
Ottiene gli elenchi di azioni in fase di progettazione supportati dal componente associato alla finestra di progettazione. |
| AssociatedComponents |
Ottiene la raccolta di componenti associati al componente gestito dalla finestra di progettazione. |
| Component |
Ottiene il componente che la finestra di progettazione sta progettando. |
| InheritanceAttribute |
Ottiene un attributo che indica il tipo di ereditarietà del componente associato. |
| Inherited |
Ottiene un valore che indica se il componente è ereditato. |
| ParentComponent |
Ottiene il componente padre per questa finestra di progettazione. |
| SetTextualDefaultProperty |
Estende il comportamento della modalità progettazione di un componente. |
| ShadowProperties |
Ottiene una raccolta di valori di proprietà che eseguono l'override delle impostazioni utente. |
| Verbs |
Ottiene i verbi della fase di progettazione supportati dal componente associato alla finestra di progettazione. |
Metodi
| Nome | Descrizione |
|---|---|
| Dispose() |
Rilascia tutte le risorse usate da ComponentDesigner. |
| Dispose(Boolean) |
Rilascia le risorse non gestite usate da ComponentDesigner e, facoltativamente, rilascia le risorse gestite. |
| DoDefaultAction() |
Crea una firma del metodo nel file del codice sorgente per l'evento predefinito nel componente e sposta il cursore dell'utente in tale posizione. |
| Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
| Finalize() |
Tenta di liberare risorse chiamando |
| GetHashCode() |
Funge da funzione hash predefinita. (Ereditato da Object) |
| GetService(Type) |
Tenta di recuperare il tipo di servizio specificato dal sito in modalità progettazione del componente della finestra di progettazione. |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| Initialize(IComponent) |
Prepara la finestra di progettazione per visualizzare, modificare e progettare il componente specificato. |
| InitializeExistingComponent(IDictionary) |
Reinizializza un componente esistente. |
| InitializeNewComponent(IDictionary) |
Inizializza un componente appena creato. |
| InitializeNonDefault() |
Obsoleti.
Obsoleti.
Inizializza le impostazioni per un componente importato già inizializzato in impostazioni diverse dalle impostazioni predefinite. |
| InvokeGetInheritanceAttribute(ComponentDesigner) |
Ottiene l'oggetto dell'oggetto InheritanceAttribute specificato ComponentDesigner. |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| OnSetComponentDefaults() |
Obsoleti.
Obsoleti.
Imposta le proprietà predefinite per il componente. |
| PostFilterAttributes(IDictionary) |
Consente a una finestra di progettazione di modificare o rimuovere elementi dal set di attributi esposti tramite un oggetto TypeDescriptor. |
| PostFilterEvents(IDictionary) |
Consente a una finestra di progettazione di modificare o rimuovere elementi dal set di eventi esposti tramite un oggetto TypeDescriptor. |
| PostFilterProperties(IDictionary) |
Consente a una finestra di progettazione di modificare o rimuovere elementi dal set di proprietà esposte tramite un oggetto TypeDescriptor. |
| PreFilterAttributes(IDictionary) |
Consente a una finestra di progettazione di aggiungere al set di attributi esposti tramite un oggetto TypeDescriptor. |
| PreFilterEvents(IDictionary) |
Consente a una finestra di progettazione di aggiungere al set di eventi esposti tramite un oggetto TypeDescriptor. |
| PreFilterProperties(IDictionary) |
Consente a una finestra di progettazione di aggiungere al set di proprietà esposte tramite un oggetto TypeDescriptor. |
| RaiseComponentChanged(MemberDescriptor, Object, Object) |
Notifica all'oggetto IComponentChangeService che questo componente è stato modificato. |
| RaiseComponentChanging(MemberDescriptor) |
Notifica all'oggetto IComponentChangeService che il componente sta per essere modificato. |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |