ComponentDesigner Osztály

Definíció

Kiterjeszti az összetevők tervezési módjának viselkedését.

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
Öröklődés
ComponentDesigner
Származtatott
Megvalósítás

Példák

Az alábbi példakód egy példa ComponentDesigner implementációt és a tervezőhöz társított példaösszetevőt tartalmaz. A tervező implementálja az Initialize alapmetódus Initialize meghívására szolgáló metódus felülbírálását, az DoDefaultAction összetevő dupla kattintáskor megjelenő MessageBox metódus felülbírálását, valamint az Verbs összetevő helyi menüjéhez egyéni DesignerVerb menüparancsot biztosító tulajdonságfelelős felülbírálását.

#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

Megjegyzések

Az ComponentDesigner alaptervezői osztály egy egyszerű tervezőt biztosít, amely kiterjesztheti a társított összetevők viselkedését tervezési módban.

ComponentDesigner üres IDesignerFilter felületi implementációt biztosít, amelynek metódusait felül lehet bírálni a társított összetevő attribútumainak, tulajdonságainak és eseményeinek tervezéskor történő módosításához.

A tervezőt társíthatja egy típushoz egy DesignerAttribute. A tervezési idő viselkedésének testreszabásáról a Design-Time támogatásának kiterjesztése című témakörben olvashat.

Az ComponentDesigner osztály speciális viselkedést alkalmaz az örökölt összetevők tulajdonságleíróihoz. Az alapértelmezett ComponentDesigner implementáció egy belső típust InheritedPropertyDescriptor használ az alaposztálytól örökölt tulajdonságokhoz való beálláshoz. A tulajdonságleírók két esetben vannak hozzáadva.

  1. Magának a gyökérobjektumnak, amelyet a tulajdonság ad IDesignerHost.RootComponent vissza, mert az alaposztályától örököl.

  2. A gyökérobjektum alaposztályában található mezőkre. Az alaposztály nyilvános és védett mezői hozzáadódnak a tervezőhöz, hogy a felhasználó manipulálhassa őket.

Az InheritedPropertyDescriptor osztály módosítja egy tulajdonság alapértelmezett értékét, így az alapértelmezett érték az aktuális érték az objektum példányosításakor. Ennek az az oka, hogy a tulajdonság egy másik példánytól öröklődik. A tervező úgy határozza meg a tulajdonságérték alaphelyzetbe állítását, hogy az az örökölt osztály által beállított értékre legyen állítva. Ez az érték eltérhet a metaadatokban tárolt alapértelmezett értéktől.

Konstruktorok

Name Description
ComponentDesigner()

Inicializálja a ComponentDesigner osztály új példányát.

Tulajdonságok

Name Description
ActionLists

Lekéri a tervezőhöz társított összetevő által támogatott tervezési idő műveletlistáit.

AssociatedComponents

Lekéri a tervező által felügyelt összetevőhöz társított összetevők gyűjteményét.

Component

Lekéri a tervező által megtervezett összetevőt.

InheritanceAttribute

Lekéri a társított összetevő öröklési típusát jelző attribútumot.

Inherited

Beolvas egy értéket, amely jelzi, hogy ez az összetevő öröklődik-e.

ParentComponent

Lekéri a tervező szülőösszetevőjét.

ShadowProperties

Lekéri a felhasználói beállításokat felülbíráló tulajdonságértékek gyűjteményét.

Verbs

Lekéri a tervezőhöz társított összetevő által támogatott tervezési időt.

Metódusok

Name Description
Dispose()

Felszabadítja a .-hez használt összes erőforrást ComponentDesigner.

Dispose(Boolean)

Felszabadítja a felügyelt erőforrások által ComponentDesigner használt nem felügyelt erőforrásokat, és opcionálisan felszabadítja a felügyelt erőforrásokat.

DoDefaultAction()

Létrehoz egy metódus-aláírást a forráskódfájlban az összetevő alapértelmezett eseményéhez, és a felhasználó kurzorát erre a helyre navigálja.

Equals(Object)

Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal.

(Öröklődés forrása Object)
Finalize()

Az erőforrások felszabadítására tett kísérletek hívással Dispose(false) , mielőtt a szemétgyűjtés visszaköveteli az objektumot.

GetHashCode()

Ez az alapértelmezett kivonatoló függvény.

(Öröklődés forrása Object)
GetService(Type)

Megkísérli lekérni a megadott szolgáltatástípust a tervező összetevőjének tervezési módú helyéről.

GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
Initialize(IComponent)

Előkészíti a tervezőt a megadott összetevő megtekintésére, szerkesztésére és tervezésére.

InitializeExistingComponent(IDictionary)

Egy meglévő összetevő újraincializálása.

InitializeNewComponent(IDictionary)

Inicializál egy újonnan létrehozott összetevőt.

InitializeNonDefault()
Elavult.

Inicializálja egy olyan importált összetevő beállításait, amely már inicializálva van az alapértelmezett beállításoktól eltérő beállításokra.

InvokeGetInheritanceAttribute(ComponentDesigner)

Lekéri a InheritanceAttribute megadott ComponentDesignerértéket.

MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
OnSetComponentDefaults()
Elavult.

Beállítja az összetevő alapértelmezett tulajdonságait.

PostFilterAttributes(IDictionary)

Lehetővé teszi a tervező számára, hogy módosítsa vagy eltávolítsa az elemeket az általa egy adott attribútumon keresztül TypeDescriptorelérhetővé tott attribútumkészletből.

PostFilterEvents(IDictionary)

Lehetővé teszi a tervező számára, hogy módosítsa vagy eltávolítsa az elemeket az általa egy adott eseményen keresztül TypeDescriptorelérhetővé tott eseménykészletből.

PostFilterProperties(IDictionary)

Lehetővé teszi a tervezők számára, hogy módosítsák vagy eltávolítsák az elemeket az általa egy adott tulajdonságon keresztül TypeDescriptorelérhetővé tott tulajdonságok készletéből.

PreFilterAttributes(IDictionary)

Lehetővé teszi a tervező számára, hogy hozzáadja azokat az attribútumokat, amelyeket egy TypeDescriptor.

PreFilterEvents(IDictionary)

Lehetővé teszi a tervező számára, hogy hozzáadja azokat az eseményeket, amelyeket egy TypeDescriptor.

PreFilterProperties(IDictionary)

Lehetővé teszi a tervező számára, hogy hozzáadja azokat a tulajdonságokat, amelyeket egy TypeDescriptor.

RaiseComponentChanged(MemberDescriptor, Object, Object)

Értesíti az IComponentChangeService összetevő módosításáról.

RaiseComponentChanging(MemberDescriptor)

Értesíti az IComponentChangeService összetevő módosításáról.

ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

Explicit interfész-implementációk

Name Description
IDesignerFilter.PostFilterAttributes(IDictionary)

Ennek a tagnak a leírását a PostFilterAttributes(IDictionary) metódus ismerteti.

IDesignerFilter.PostFilterEvents(IDictionary)

Ennek a tagnak a leírását a PostFilterEvents(IDictionary) metódus ismerteti.

IDesignerFilter.PostFilterProperties(IDictionary)

Ennek a tagnak a leírását a PostFilterProperties(IDictionary) metódus ismerteti.

IDesignerFilter.PreFilterAttributes(IDictionary)

Ennek a tagnak a leírását a PreFilterAttributes(IDictionary) metódus ismerteti.

IDesignerFilter.PreFilterEvents(IDictionary)

Ennek a tagnak a leírását a PreFilterEvents(IDictionary) metódus ismerteti.

IDesignerFilter.PreFilterProperties(IDictionary)

Ennek a tagnak a leírását a PreFilterProperties(IDictionary) metódus ismerteti.

ITreeDesigner.Children

A tag leírását a tulajdonságban Children talál.

ITreeDesigner.Parent

A tag leírását a tulajdonságban Parent talál.

A következőre érvényes:

Lásd még