ComponentDesigner 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擴充元件的設計模式行為。
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 ref class ComponentDesigner : IDisposable, System::ComponentModel::Design::IComponentInitializer, System::ComponentModel::Design::IDesigner, 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
public class ComponentDesigner : IDisposable, System.ComponentModel.Design.IComponentInitializer, System.ComponentModel.Design.IDesigner, 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
Public Class ComponentDesigner
Implements IComponentInitializer, IDesigner, IDesignerFilter, IDisposable, ITreeDesigner
- 繼承
-
ComponentDesigner
- 衍生
- 實作
範例
下列程式代碼範例提供範例 ComponentDesigner 實作和與設計工具相關聯的範例元件。 設計工具會實作呼叫基底方法的方法覆寫Initialize、按兩下元件時顯示 MessageBox 的方法覆寫DoDefaultAction,以及提供自定義DesignerVerb功能表命令給元件的快捷方式功能表的屬性存取子覆寫Verbs。Initialize
#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
備註
基 ComponentDesigner 底設計工具類別提供簡單的設計工具,可擴充設計模式中相關聯元件的行為。
ComponentDesigner 提供空 IDesignerFilter 的介面實作,其方法可以在設計時間調整相關聯元件的屬性、屬性和事件。
您可以使用 建立設計工具與型別 DesignerAttribute的關聯。 如需自定義設計時間行為的概觀,請參閱 擴充 Design-Time 支援。
類別 ComponentDesigner 會實作繼承元件之屬性描述項的特殊行為。 默認實作會使用ComponentDesigner名為 InheritedPropertyDescriptor
的內部類型,來代表繼承自基類的屬性。 有兩種情況會新增這些屬性描述元。
針對屬性所傳回的 IDesignerHost.RootComponent 根物件本身,因為您繼承自其基類。
在根物件的基類中找到的欄位。 基類的公用和受保護字段會新增至設計工具,讓使用者可以操作這些字段。
類別 InheritedPropertyDescriptor
會修改屬性的預設值,讓預設值是物件具現化時的目前值。 這是因為 屬性繼承自另一個實例。 設計工具會將重設屬性值定義為繼承類別所設定的值。 此值可能與儲存在元數據中的預設值不同。
建構函式
ComponentDesigner() |
初始化 ComponentDesigner 類別的新執行個體。 |
屬性
ActionLists |
取得與設計工具相關之元件所支援的設計階段動作清單。 |
AssociatedComponents |
取得元件集合,該集合與設計工具管理的元件相關聯。 |
Component |
取得這個設計工具正在設計的元件。 |
InheritanceAttribute |
取得屬性 (Attribute),表示相關元件的繼承 (Inheritance) 型別。 |
Inherited |
取得值,表示是否要繼承這個元件。 |
ParentComponent |
取得這個設計工具的父元件。 |
SetTextualDefaultProperty |
擴充元件的設計模式行為。 |
ShadowProperties |
取得覆寫使用者設定的屬性值集合。 |
Verbs |
取得與設計工具相關元件所支援的設計階段動詞命令 (Verb)。 |
方法
明確介面實作
IDesignerFilter.PostFilterAttributes(IDictionary) |
如需這個成員的描述,請參閱 PostFilterAttributes(IDictionary) 方法。 |
IDesignerFilter.PostFilterEvents(IDictionary) |
如需這個成員的描述,請參閱 PostFilterEvents(IDictionary) 方法。 |
IDesignerFilter.PostFilterProperties(IDictionary) |
如需這個成員的描述,請參閱 PostFilterProperties(IDictionary) 方法。 |
IDesignerFilter.PreFilterAttributes(IDictionary) |
如需這個成員的描述,請參閱 PreFilterAttributes(IDictionary) 方法。 |
IDesignerFilter.PreFilterEvents(IDictionary) |
如需這個成員的描述,請參閱 PreFilterEvents(IDictionary) 方法。 |
IDesignerFilter.PreFilterProperties(IDictionary) |
如需這個成員的描述,請參閱 PreFilterProperties(IDictionary) 方法。 |
ITreeDesigner.Children |
如需這個成員的描述,請參閱 Children 屬性。 |
ITreeDesigner.Parent |
如需這個成員的描述,請參閱 Parent 屬性。 |