IDesigner 인터페이스

정의

사용자 지정 디자이너를 빌드하기 위한 기본 프레임워크를 제공합니다.

public interface class IDesigner : IDisposable
public interface IDesigner : IDisposable
[System.Runtime.InteropServices.ComVisible(true)]
public interface IDesigner : IDisposable
type IDesigner = interface
    interface IDisposable
[<System.Runtime.InteropServices.ComVisible(true)>]
type IDesigner = interface
    interface IDisposable
Public Interface IDesigner
Implements IDisposable
파생
특성
구현

예제

이 예제에서는 해당 구성 요소에 대한 로컬 참조를 저장하고, 구성 요소를 두 번 클릭할 때 기본 작업을 수행하고, 디자이너 동사 메뉴 명령을 제공하는 구현을 보여 IDesigner 줍니다.

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

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::Data;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;

public ref class ExampleIDesigner: public System::ComponentModel::Design::IDesigner
{
private:

   // Local reference to the designer's component.
   IComponent^ component;

public:

   property System::ComponentModel::IComponent^ Component 
   {
      // Public accessor to the designer's component.
      virtual System::ComponentModel::IComponent^ get()
      {
         return component;
      }
   }
   ExampleIDesigner(){}

   virtual void Initialize( System::ComponentModel::IComponent^ component )
   {
      // This method is called after a designer for a component is created,
      // and stores a reference to the designer's component.
      this->component = component;
   }

   // This method peforms the 'default' action for the designer. The default action 
   // for a basic IDesigner implementation is invoked when the designer's component 
   // is double-clicked. By default, a component associated with a basic IDesigner 
   // implementation is displayed in the design-mode component tray.
   virtual void DoDefaultAction()
   {
      // Shows a message box indicating that the default action for the designer was invoked.
      MessageBox::Show( "The DoDefaultAction method of an IDesigner implementation was invoked.", "Information" );
   }

   property System::ComponentModel::Design::DesignerVerbCollection^ Verbs 
   {
      // Returns a collection of designer verb menu items to show in the 
      // shortcut menu for the designer's component.
      [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
      virtual System::ComponentModel::Design::DesignerVerbCollection^ get()
      {
         DesignerVerbCollection^ verbs = gcnew DesignerVerbCollection;
         DesignerVerb^ dv1 = gcnew DesignerVerb( "Display Component Name",gcnew EventHandler( this, &ExampleIDesigner::ShowComponentName ) );
         verbs->Add( dv1 );
         return verbs;
      }
   }

private:

   // Event handler for displaying a message box showing the designer's component's name.
   void ShowComponentName( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( this->Component != nullptr )
            MessageBox::Show( this->Component->Site->Name, "Designer Component's Name" );
   }

public:

   // Provides an opportunity to release resources before object destruction.
   ~ExampleIDesigner(){}

};

// A DesignerAttribute associates the example IDesigner with an example control.

[DesignerAttribute(ExampleIDesigner::typeid)]
public ref class TestControl: public System::Windows::Forms::UserControl
{
public:
   TestControl(){}

};
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace IDesignerExample
{	
    // A DesignerAttribute associates the example IDesigner with an example control.
    [DesignerAttribute(typeof(ExampleIDesigner))]
    public class TestControl : System.Windows.Forms.UserControl
    {				
        public TestControl()
        {	
        }
    }

    public class ExampleIDesigner : System.ComponentModel.Design.IDesigner
    {
        // Local reference to the designer's component.
        private IComponent component; 
        // Public accessor to the designer's component.
        public System.ComponentModel.IComponent Component
        {
            get
            {
                return component;
            }            
        }

        public ExampleIDesigner()
        {            
        }

        public void Initialize(System.ComponentModel.IComponent component)
        {
            // This method is called after a designer for a component is created,
            // and stores a reference to the designer's component.
            this.component = component;
        }        
        
        // This method peforms the 'default' action for the designer. The default action 
        // for a basic IDesigner implementation is invoked when the designer's component 
        // is double-clicked. By default, a component associated with a basic IDesigner 
        // implementation is displayed in the design-mode component tray.
        public void DoDefaultAction()
        {
            // Shows a message box indicating that the default action for the designer was invoked.
            MessageBox.Show("The DoDefaultAction method of an IDesigner implementation was invoked.", "Information");
        }

        // Returns a collection of designer verb menu items to show in the 
        // shortcut menu for the designer's component.
        public System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
            get
            {
                DesignerVerbCollection verbs = new DesignerVerbCollection();
                DesignerVerb dv1 = new DesignerVerb("Display Component Name", new EventHandler(this.ShowComponentName));
                verbs.Add( dv1 );
                return verbs;
            }
        }

        // Event handler for displaying a message box showing the designer's component's name.
        private void ShowComponentName(object sender, EventArgs e)
        {
            if( this.Component != null )
                MessageBox.Show( this.Component.Site.Name, "Designer Component's Name" );
        }

        // Provides an opportunity to release resources before object destruction.
        public void Dispose()
        {        
        }
    }
}
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms

' A DesignerAttribute associates the example IDesigner with an example control.
<DesignerAttribute(GetType(ExampleIDesigner))> _
Public Class TestControl
    Inherits System.Windows.Forms.UserControl

    Public Sub New()
    End Sub
End Class

<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class ExampleIDesigner
    Implements System.ComponentModel.Design.IDesigner

    ' Local reference to the designer's component.
    Private _component As IComponent

    ' Public accessor to the designer's component.
    Public ReadOnly Property Component() As System.ComponentModel.IComponent Implements IDesigner.Component
        Get
            Return _component
        End Get
    End Property

    Public Sub New()
    End Sub

    Public Sub Initialize(ByVal component As System.ComponentModel.IComponent) Implements IDesigner.Initialize
        ' This method is called after a designer for a component is created,
        ' and stores a reference to the designer's component.
        Me._component = component
    End Sub

    ' This method peforms the 'default' action for the designer. The default action 
    ' for a basic IDesigner implementation is invoked when the designer's component 
    ' is double-clicked. By default, a component associated with a basic IDesigner 
    ' implementation is displayed in the design-mode component tray.
    Public Sub DoDefaultAction() Implements IDesigner.DoDefaultAction
        ' Shows a message box indicating that the default action for the designer was invoked.
        MessageBox.Show("The DoDefaultAction method of an IDesigner implementation was invoked.", "Information")
    End Sub

    ' Returns a collection of designer verb menu items to show in the 
    ' shortcut menu for the designer's component.
    Public ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Implements IDesigner.Verbs
        Get
            Dim verbs_ As New DesignerVerbCollection()
            Dim dv1 As New DesignerVerb("Display Component Name", New EventHandler(AddressOf Me.ShowComponentName))
            verbs_.Add(dv1)
            Return verbs_
        End Get
    End Property

    ' Event handler for displaying a message box showing the designer's component's name.
    Private Sub ShowComponentName(ByVal sender As Object, ByVal e As EventArgs)
        If (Me.Component IsNot Nothing) Then
            MessageBox.Show(Me.Component.Site.Name, "Designer Component's Name")
        End If
    End Sub

    ' Provides an opportunity to release resources before object destruction.
    Public Sub Dispose() Implements IDisposable.Dispose
    End Sub

End Class

설명

인터페이스는 IDesigner 디자이너에 대한 기본 서비스를 구현할 수 있는 인터페이스를 제공합니다. 디자이너는 디자인 타임에 구성 요소의 동작을 수정할 수 있으며 자체 서비스 및 동작을 제공할 수 있습니다. 디자이너는 디자인 타임에만 활성화되며 디자인 타임에 연결된 형식의 구성 요소를 만들 때 로드하려면 를 사용하는 DesignerAttribute 구성 요소 형식과 연결되어야 합니다.

인터페이스는 IDesigner 디자인 타임에 사용자 지정 동작을 제공하기 위해 구현할 수 있는 메서드와 속성을 제공합니다.

Initialize 구성 요소를 만들 때 작업을 수행하는 디자이너의 메서드를 구현합니다. 이는 구성 요소가 디자인 타임에 특별한 구성을 가져야 하거나 디자이너가 결정할 수 있는 조건에 따라 구성이 변경되어야 하는 경우에 유용할 수 있습니다.

디자이너는 사용자가 디자인 타임 환경에서 구성 요소 또는 컨트롤을 마우스 오른쪽 단추로 클릭할 때 표시되는 바로 가기 메뉴에 메뉴 명령을 제공할 수 있습니다. 구현할 수 있습니다는 Verbs 속성을 반환 하는 get 접근자를 정의 하는 DesignerVerbCollection 메뉴 명령을 생성 하는 DesignerVerb 개체입니다.

구성 요소 트레이에 표시되는 구성 요소의 디자이너는 구성 요소를 두 번 클릭할 때 기본 작업을 수행할 수 있습니다. DoDefaultAction 구성 요소를 두 번 클릭할 때 수행할 동작을 지정하는 메서드를 구현합니다.

디자이너는 사용 가능한 디자인 타임 서비스를 사용하여 구성 요소 및 해당 속성에 대한 현재 디자인 타임 환경 조사, 구성 요소 속성 값 읽기 및 설정, 도구 상자 관리, 선택한 구성 요소 관리 또는 값을 구성하거나 추가 처리를 적용하는 데 사용할 수 있는 사용자 인터페이스 표시 등 다양한 작업을 수행할 수 있습니다.

폼에 배치할 수 있는 컨트롤에 대한 디자이너를 구현하려면 클래스에서 상속할 ControlDesigner 수 있습니다. 연결된 디자이너가 파생 ControlDesigner 되지 않는 컨트롤이 구성 요소 트레이에 표시됩니다. 및 ControlDesigner 클래스는 ComponentDesigner 인터페이스를 IDesigner 구현하고 디자이너 작성자에게 사용할 수 있는 추가 디자인 타임 지원을 제공합니다. 자세한 내용은 이러한 클래스에 대한 참조 설명서를 참조하세요.

디자인 구성 요소 만들기에 대한 개요는 Design-Time 지원 확장을 참조하세요.

속성

Component

해당 디자이너가 디자인하고 있는 기본 구성 요소를 가져옵니다.

Verbs

디자이너가 지원하는 디자인 타임 동사의 컬렉션을 가져옵니다.

메서드

Dispose()

관리되지 않는 리소스의 확보, 해제 또는 다시 설정과 관련된 애플리케이션 정의 작업을 수행합니다.

(다음에서 상속됨 IDisposable)
DoDefaultAction()

이 디자이너에 대한 기본 작업을 수행합니다.

Initialize(IComponent)

디자이너를 지정된 구성 요소로 초기화합니다.

적용 대상

추가 정보