Leggere in inglese

Condividi tramite


IRootDesigner Interfaccia

Definizione

Fornisce supporto per le tecnologie di visualizzazione della finestra di progettazione a livello radice.

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
Derivato
Attributi
Implementazioni

Esempio

Nell'esempio di codice seguente viene illustrata un'implementazione IRootDesigner associata a un controllo utente di esempio. Questa IRootDesigner implementazione visualizza un controllo per la visualizzazione in background nella visualizzazione progettazione eseguendo l'override del GetView metodo . È necessario aggiungere un riferimento all'assembly System.Design per compilare l'esempio.

Per usare questo esempio, aggiungere il codice sorgente a un progetto e visualizzare la RootViewSampleComponent visualizzazione nella finestra di progettazione per visualizzare la visualizzazione progettazione radice personalizzata.

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);
            }
        }		
    }
}

Commenti

Una finestra di progettazione radice è la finestra di progettazione che si trova nella posizione superiore o nella radice della gerarchia dell'oggetto documento in fase di progettazione corrente. Una finestra di progettazione radice deve implementare l'interfaccia IRootDesigner . Una finestra di progettazione radice gestisce in genere la visualizzazione in background in modalità visualizzazione progettazione e in genere visualizza i controlli all'interno del contenitore di base del progetto in fase di progettazione corrente.

Proprietà

Component

Ottiene il componente di base in fase di progettazione nella finestra di progettazione.

(Ereditato da IDesigner)
SupportedTechnologies

Ottiene il gruppo di tecnologie che questa finestra di progettazione è in grado di supportare per la visualizzazione.

Verbs

Ottiene un insieme di verbi della fase di progettazione supportati dalla finestra di progettazione.

(Ereditato da IDesigner)

Metodi

Dispose()

Esegue attività definite dall'applicazione, come rilasciare o reimpostare risorse non gestite.

(Ereditato da IDisposable)
DoDefaultAction()

Esegue l'azione predefinita per questa finestra di progettazione.

(Ereditato da IDesigner)
GetView(ViewTechnology)

Ottiene un oggetto visualizzazione per la tecnologia di visualizzazione specificata.

Initialize(IComponent)

Inizializza la finestra di progettazione con il componente specificato.

(Ereditato da IDesigner)

Si applica a

Prodotto Versioni
.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