IRootDesigner Schnittstelle
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Unterstützt Ansichtstechnologien für Designer auf Stammebene.
public interface class IRootDesigner : IDisposable, System::ComponentModel::Design::IDesigner
public interface class IRootDesigner : System::ComponentModel::Design::IDesigner
public interface IRootDesigner : IDisposable, System.ComponentModel.Design.IDesigner
[System.Runtime.InteropServices.ComVisible(true)]
public interface IRootDesigner : IDisposable, System.ComponentModel.Design.IDesigner
public interface IRootDesigner : System.ComponentModel.Design.IDesigner
type IRootDesigner = interface
interface IDesigner
interface IDisposable
[<System.Runtime.InteropServices.ComVisible(true)>]
type IRootDesigner = interface
interface IDesigner
interface IDisposable
Public Interface IRootDesigner
Implements IDesigner, IDisposable
Public Interface IRootDesigner
Implements IDesigner
- Abgeleitet
- Attribute
- Implementiert
Beispiele
Im folgenden Codebeispiel wird eine IRootDesigner Implementierung veranschaulicht, die einem Beispielbenutzersteuerelement zugeordnet ist. Diese IRootDesigner Implementierung zeigt ein Steuerelement für die Hintergrundansicht in der Designeransicht an, indem die GetView -Methode überschrieben wird. Sie müssen einen Verweis auf die System.Design-Assembly hinzufügen, um das Beispiel zu kompilieren.
Um dieses Beispiel zu verwenden, fügen Sie den Quellcode zu einem Projekt hinzu, und zeigen Sie in der Designeransicht an RootViewSampleComponent
, um die benutzerdefinierte Stamm-Designer-Ansicht anzuzeigen.
#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(){}
};
}
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);
}
}
}
}
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.Default 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. Default is the view technology used by this designer.
ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies
Get
Return New ViewTechnology() {ViewTechnology.Default}
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
Hinweise
Ein Stamm-Designer ist der Designer, der sich an der obersten Position oder dem Stamm der aktuellen Dokumentobjekthierarchie zur Entwurfszeit befindet. Ein Stamm-Designer muss die IRootDesigner -Schnittstelle implementieren. Ein Stamm-Designer verwaltet in der Regel die Hintergrundansicht im Designeransichtsmodus und zeigt in der Regel die Steuerelemente im Basiscontainer des aktuellen Entwurfszeitprojekts an.
Eigenschaften
Component |
Ruft die von diesem Designer entworfene Basiskomponente ab. (Geerbt von IDesigner) |
SupportedTechnologies |
Ruft den Satz von Technologien ab, die dieser Designer für die Anzeige unterstützen kann. |
Verbs |
Ruft eine Auflistung der Entwurfszeitverben ab, die vom Designer unterstützt werden. (Geerbt von IDesigner) |
Methoden
Dispose() |
Führt anwendungsspezifische Aufgaben durch, die mit der Freigabe, der Zurückgabe oder dem Zurücksetzen von nicht verwalteten Ressourcen zusammenhängen. (Geerbt von IDisposable) |
DoDefaultAction() |
Führt die Standardaktion für diesen Designer durch. (Geerbt von IDesigner) |
GetView(ViewTechnology) |
Ruft ein Ansichtsobjekt für die angegebene Ansichtstechnologie ab. |
Initialize(IComponent) |
Initialisiert den Designer mit der angegebenen Komponente. (Geerbt von IDesigner) |