Export (0) Print
Expand All

IRootDesigner Interface

Provides support for root-level designer view technologies.

Namespace:  System.ComponentModel.Design
Assembly:  System (in System.dll)

[ComVisibleAttribute(true)]
public interface class IRootDesigner : IDesigner, 
	IDisposable

The IRootDesigner type exposes the following members.

  NameDescription
Public propertyComponentGets the base component that this designer is designing. (Inherited from IDesigner.)
Public propertySupportedTechnologiesGets the set of technologies that this designer can support for its display.
Public propertyVerbsGets a collection of the design-time verbs supported by the designer. (Inherited from IDesigner.)
Top

  NameDescription
Public methodDisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Public methodDoDefaultActionPerforms the default action for this designer. (Inherited from IDesigner.)
Public methodGetViewGets a view object for the specified view technology.
Public methodInitializeInitializes the designer with the specified component. (Inherited from IDesigner.)
Top

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.

The following code 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. You need to add a reference to the System.Design assembly to compile the example.

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.

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

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Diagnostics;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

namespace SampleRootDesigner
{
   ref class SampleRootDesigner;

   // This sample demonstrates how to provide the root designer view, or 
   // design mode background view, by overriding IRootDesigner.GetView(). 
   // The following attribute associates the SampleRootDesigner designer 
   // with the SampleComponent component.

   [Designer(SampleRootDesigner::typeid,IRootDesigner::typeid)]
   public ref class RootDesignedComponent: public Component
   {
   public:
      RootDesignedComponent(){}

   };

   public ref class SampleRootDesigner: public ComponentDesigner, public IRootDesigner
   {
   private:
      ref class RootDesignerView;

      // 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().
      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. 
      virtual Object^ GetView( ViewTechnology technology ) sealed = IRootDesigner::GetView
      {
         if ( technology != ViewTechnology::WindowsForms )
         {
            throw gcnew ArgumentException( "Not a supported view technology","technology" );
         }

         if ( m_view == nullptr )
         {

            // 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 = gcnew RootDesignerView( this );
         }

         return m_view;
      }


      // IRootDesigner.SupportedTechnologies is a required override for an 
      // IRootDesigner. WindowsForms is the view technology used by this designer. 
public:
      property array<ViewTechnology>^ SupportedTechnologies 
      {
		virtual array<ViewTechnology>^ get() 
		{
			return gcnew array<ViewTechnology> {ViewTechnology::Default};
                	
		}
      }

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

      public:
         RootDesignerView( SampleRootDesigner^ designer )
         {
            m_designer = designer;
            BackColor = Color::Blue;
            Font = gcnew System::Drawing::Font( Font->FontFamily->Name,24.0f );
         }


      protected:
         virtual void OnPaint( PaintEventArgs^ pe ) override
         {
            Control::OnPaint( pe );

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

      };


   };


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

   };

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft