IDesignerとは? わかりやすく解説

IDesigner インターフェイス

カスタム デザイナ構築するための基本フレームワーク提供します

名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Interface IDesigner
    Inherits IDisposable
[ComVisibleAttribute(true)] 
public interface IDesigner : IDisposable
[ComVisibleAttribute(true)] 
public interface class IDesigner : IDisposable
/** @attribute ComVisibleAttribute(true) */ 
public interface IDesigner extends IDisposable
ComVisibleAttribute(true) 
public interface IDesigner extends IDisposable
解説解説

IDesigner インターフェイスは、デザイナ基本的なサービス実装できるインターフェイス提供しますデザイナは、デザイン時にコンポーネント動作変更でき、それ独自のサービス動作も提供できますデザイナデザイン時だけにアクティブなりますデザイナは、DesignerAttribute を使用してコンポーネントの型に関連付ける必要がありますこうすることで、関連付けられた型のコンポーネントデザイン時に作成されると、そのデザイナ読み込まれます。

IDesigner インターフェイスには、デザイン時のカスタム動作提供するために実装できるメソッドプロパティ用意されています。

コンポーネント作成されたときにアクション実行するには、デザイナInitialize メソッド実装ます。これは、デザイン時にコンポーネント特別な構成を持つ場合や、デザイナ決定できる条件基づいてコンポーネント構成変更する必要がある場合に便利です。

デザイナは、ユーザーデザイン環境コンポーネントコントロール右クリックしたときに表示されるショートカット メニューメニュー コマンドを提供できます。Verbs プロパティ実装して、生成するメニュー コマンド対応する DesignerVerb オブジェクト格納している DesignerVerbCollection を返す get アクセサを定義できます

コンポーネント トレイ表示されるコンポーネントデザイナは、コンポーネントダブルクリックされたときに既定アクション実行できますコンポーネントダブルクリックされたときに実行する動作指定するには、DoDefaultAction メソッド実装ます。

またデザイナは、さまざまなタスク実行する利用可能デザインサービス使用できます実行できるタスクには、各コンポーネントとそのプロパティ対応する現在のデザイン環境調査コンポーネントプロパティ値の読み込み設定ツールボックス管理選択したコンポーネント管理、値の設定追加処理の適用使用できるユーザー インターフェイス表示などがあります

フォーム上に配置できるコントロールデザイナ実装するには、ControlDesigner クラスから継承します関連付けられているデザイナControlDesigner継承していないコントロールは、コンポーネント トレイ表示されます。ComponentDesigner クラスControlDesigner クラスは、IDesigner インターフェイス実装し、デザイナ作成者使用できる追加デザインサポート提供します詳細については、これらのクラスリファレンス ドキュメント参照してください

デザイン コンポーネント作成概要については、「イベントデリゲート」を参照してください

使用例使用例

コンポーネントへのローカル参照格納しコンポーネントダブルクリックされたときに既定アクション実行しデザイナ動詞メニュー コマンド提供する IDesigner 実装の例次に示します

Imports System
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 Not (Me.Component
 Is 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
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()
        {    
        }
    }

    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name = "FullTrust")] 
    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()
        {        
        }
    }
}
#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(){}

};
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IDesigner メンバ
System.ComponentModel.Design 名前空間
IRootDesigner
IDesignerHost
DesignerVerb クラス
その他の技術情報
デザインサポート拡張

IDesigner プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

IDesigner インターフェイス
System.ComponentModel.Design 名前空間
IRootDesigner
IDesignerHost
DesignerVerb クラス

その他の技術情報

デザインサポート拡張

IDesigner メソッド


パブリック メソッドパブリック メソッド

参照参照

関連項目

IDesigner インターフェイス
System.ComponentModel.Design 名前空間
IRootDesigner
IDesignerHost
DesignerVerb クラス

その他の技術情報

デザインサポート拡張

IDesigner メンバ




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「IDesigner」の関連用語

IDesignerのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IDesignerのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS