Provides support for root-level designer view technologies.
For a list of all members of this type, see IRootDesigner Members.
[Visual Basic] <ComVisible(True)> Public Interface IRootDesigner Inherits IDesigner, IDisposable [C#] [ComVisible(true)] public interface IRootDesigner : IDesigner, IDisposable [C++] [ComVisible(true)] public __gc __interface IRootDesigner : public IDesigner, IDisposable [JScript] public ComVisible(true) interface IRootDesigner implements IDesigner, IDisposable
| Class | Description |
|---|---|
| ComponentDocumentDesigner | Base designer class for extending the design mode behavior of a root design document that supports nested components. |
| DocumentDesigner | Base designer class for extending the design mode behavior of, and providing a root-level design mode view for, a Control that supports nested controls and should receive scroll messages. |
A root designer is the designer that is in the top position, or root, of the current design-time document object hierarchy. A root designer must implement the IRootDesigner interface. A root designer typically manages the background view in designer view mode, and usually displays the controls within the base container of the current design time project.
[Visual Basic, C#] The following example demonstrates a IRootDesigner implementation associated with a sample user control. This IRootDesigner implementation displays a control for the background view in designer view by overriding the GetView method. To use this example, add the source code to a project and show the RootViewSampleComponent in designer view to display the custom root designer view.
[Visual Basic] Imports System Imports System.Collections Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Diagnostics Imports System.Drawing Imports System.Windows.Forms Imports 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 Inherits RootDesignedComponent Public Sub New() End Sub End Class ' The following attribute associates the SampleRootDesigner designer ' with the SampleComponent component. <Designer(GetType(SampleRootDesigner), GetType(IRootDesigner))> _ Public Class RootDesignedComponent Inherits Component Public Sub New() End Sub End Class Public Class SampleRootDesigner Inherits ComponentDesigner Implements 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 m_view As RootDesignerView ' 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. Function GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView If Not technology = ViewTechnology.WindowsForms Then Throw New ArgumentException("Not a supported view technology", "technology") End If If m_view Is Nothing Then ' 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(Me) End If Return m_view End Function ' IRootDesigner.SupportedTechnologies is a required override for an ' IRootDesigner. WindowsForms is the view technology used by this designer. ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies Get Return New ViewTechnology() {ViewTechnology.WindowsForms} End Get End Property ' RootDesignerView is a simple control that will be displayed ' in the designer window. Private Class RootDesignerView Inherits Control Private m_designer As SampleRootDesigner Public Sub New(ByVal designer As SampleRootDesigner) m_designer = designer BackColor = Color.Blue Font = New Font(Font.FontFamily.Name, 24.0F) End Sub Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs) MyBase.OnPaint(pe) ' Draws the name of the component in large letters. Dim rf As New RectangleF(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height) pe.Graphics.DrawString(m_designer.Component.Site.Name, Font, Brushes.Yellow, rf) End Sub End Class End Class End Namespace [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.WindowsForms) { 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. WindowsForms is the view technology used by this designer. ViewTechnology[] IRootDesigner.SupportedTechnologies { get { return new ViewTechnology[] {ViewTechnology.WindowsForms}; } } // 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); } } } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
IRootDesigner Members | System.ComponentModel.Design Namespace