英語で読む

次の方法で共有


IRootDesigner インターフェイス

定義

ルート レベルのデザイナー ビュー テクノロジのサポートを提供します。

C#
public interface IRootDesigner : IDisposable, System.ComponentModel.Design.IDesigner
C#
[System.Runtime.InteropServices.ComVisible(true)]
public interface IRootDesigner : IDisposable, System.ComponentModel.Design.IDesigner
C#
public interface IRootDesigner : System.ComponentModel.Design.IDesigner
派生
属性
実装

次のコード例は、サンプル ユーザー コントロールに IRootDesigner 関連付けられている実装を示しています。 この実装では IRootDesigner 、 メソッドをオーバーライドすることで、デザイナー ビューに背景ビューのコントロールを GetView 表示します。 この例をコンパイルするには、System.Design アセンブリへの参照を追加する必要があります。

この例を使用するには、ソース コードをプロジェクトに追加し、デザイナー ビューに を RootViewSampleComponent 表示して、カスタム ルート デザイナー ビューを表示します。

C#
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace SampleRootDesigner
{	
    // This sample demonstrates how to provide the root designer view, or
    // design mode background view, by overriding IRootDesigner.GetView().

    // This sample component inherits from RootDesignedComponent which 
    // uses the SampleRootDesigner.
    public class RootViewSampleComponent : RootDesignedComponent
    {
        public RootViewSampleComponent()
        {
        }
    }

    // The following attribute associates the SampleRootDesigner designer 
    // with the SampleComponent component.
    [Designer(typeof(SampleRootDesigner), typeof(IRootDesigner))]
    public class RootDesignedComponent : Component
    {
        public RootDesignedComponent()
        {
        }
    }

    public class SampleRootDesigner : ComponentDesigner, IRootDesigner
    {
        // Member field of custom type RootDesignerView, a control that 
        // will be shown in the Forms designer view. This member is 
        // cached to reduce processing needed to recreate the 
        // view control on each call to GetView().
        private RootDesignerView m_view;			

        // This method returns an instance of the view for this root
        // designer. The "view" is the user interface that is presented
        // in a document window for the user to manipulate. 
        object IRootDesigner.GetView(ViewTechnology technology) 
        {
            if (technology != ViewTechnology.Default)
            {
                throw new ArgumentException("Not a supported view technology", "technology");
            }
            if (m_view == null)
            {
                   // Some type of displayable Form or control is required 
                   // for a root designer that overrides GetView(). In this 
                   // example, a Control of type RootDesignerView is used.
                   // Any class that inherits from Control will work.
                m_view = new RootDesignerView(this);
            }
            return m_view;
        }

        // IRootDesigner.SupportedTechnologies is a required override for an
        // IRootDesigner. Default is the view technology used by this designer.  
        ViewTechnology[] IRootDesigner.SupportedTechnologies 
        {
            get
            {
                return new ViewTechnology[] {ViewTechnology.Default};
            }
        }

        // RootDesignerView is a simple control that will be displayed 
        // in the designer window.
        private class RootDesignerView : Control 
        {
            private SampleRootDesigner m_designer;

            public RootDesignerView(SampleRootDesigner designer)
            {
                m_designer = designer;
                BackColor = Color.Blue;
                Font = new Font(Font.FontFamily.Name, 24.0f);
            }

            protected override void OnPaint(PaintEventArgs pe)
            {
                base.OnPaint(pe);

                // Draws the name of the component in large letters.
                pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, ClientRectangle);
            }
        }		
    }
}

注釈

ルート デザイナーは、現在のデザイン時のドキュメント オブジェクト階層の最上位 (ルート) にあるデザイナーです。 ルート デザイナーは インターフェイスを実装する IRootDesigner 必要があります。 通常、ルート デザイナーはデザイナー ビュー モードでバックグラウンド ビューを管理し、通常は現在のデザイン時プロジェクトの基本コンテナー内にコントロールを表示します。

プロパティ

Component

デザイナーがデザインする基本コンポーネントを取得します。

(継承元 IDesigner)
SupportedTechnologies

デザイナーがサポートできる表示用の一連の技術を取得します。

Verbs

デザイナーでサポートされているデザイン時動詞のコレクションを取得します。

(継承元 IDesigner)

メソッド

Dispose()

アンマネージ リソースの解放またはリセットに関連付けられているアプリケーション定義のタスクを実行します。

(継承元 IDisposable)
DoDefaultAction()

デザイナーの既定のアクションを実行します。

(継承元 IDesigner)
GetView(ViewTechnology)

指定したビュー技術のビュー オブジェクトを取得します。

Initialize(IComponent)

コンポーネントを指定して、デザイナーを初期化します。

(継承元 IDesigner)

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1