ViewTechnology 列舉

定義

定義設計工具主應用程式 (Designer Host) 所支援的技術集合的識別項。

public enum class ViewTechnology
public enum ViewTechnology
[System.Runtime.InteropServices.ComVisible(true)]
public enum ViewTechnology
type ViewTechnology = 
[<System.Runtime.InteropServices.ComVisible(true)>]
type ViewTechnology = 
Public Enum ViewTechnology
繼承
ViewTechnology
屬性

欄位

Default 2

指定預設檢視技術的支援。

根目錄設計工具可以傳回任何型別的物件,但該物件必須與主機技術的配接器相容。 Visual Studio 這類裝載環境可用來插入新的檢視技術配接器。 Windows Form 設計工具的預設檢視物件是 Control 執行個體。

Passthrough 0

表示直接將檢視物件傳遞至開發環境的模式。

檢視物件必須實作任何開發環境所需的介面。 Visual Studio 開發環境支援的檢視物件可以是 ActiveX 控制項、使用中文件,或是實作透過 Visual Studio VSI (Visual Studio 整合) 程式提供之 IVsWindowPane 介面的物件。 Visual Studio 開發環境提供此檢視技術的支援。 並非所有開發環境都支援此檢視技術。

WindowsForms 1

表示 Windows Form 控制項物件為主要設計工具提供顯示方式的模式。 設計工具主應用程式使用 Windows Form 控制項來填入開發環境文件視窗。

範例

下列範例示範如何在設計工具中使用 ViewTechnology.Default 。 這個範例是針對介面提供的較大範例的 GetView 一部分。

#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

下列範例示範如何在設計工具中使用 『ViewTechnology> 列舉。 這個範例是提供給 類別之較大範例的 LocalizationExtenderProvider 一部分。

#using <system.dll>
#using <system.design.dll>
#using <system.windows.forms.dll>
#using <system.drawing.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;

// This example demonstrates adding localization support to a component hierarchy from a
// custom IRootDesigner using the LocalizationExtenderProvider class.
namespace LocalizationExtenderProviderExample
{

   // Example IRootDesigner implementation demonstrates LocalizationExtenderProvider support.
   private ref class SampleRootDesigner: public IRootDesigner
   {
   private:

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

      public:
         RootDesignerView( SampleRootDesigner^ designer, IComponent^ component )
         {
            m_designer = designer;
            this->comp = component;
            BackColor = Color::Blue;
            Font = gcnew System::Drawing::Font( FontFamily::GenericMonospace,12 );
         }


      protected:

         // Displays the name of the component and the name of the assembly of the component
         // that this root designer is providing support for.
         virtual void OnPaint( PaintEventArgs^ pe ) override
         {
            Control::OnPaint( pe );
            if ( m_designer != 0 && comp != 0 )
            {
               
               // Draws the name of the component in large letters.
               pe->Graphics->DrawString( "Root Designer View", Font, Brushes::Yellow, 8, 4 );
               pe->Graphics->DrawString( String::Concat( "Design Name  : ", comp->Site->Name ), gcnew System::Drawing::Font( "Arial",10 ), Brushes::Yellow, 8, 28 );
               pe->Graphics->DrawString( String::Concat( "Assembly    : ", comp->GetType()->AssemblyQualifiedName ), gcnew System::Drawing::Font( "Arial",10 ), Brushes::Yellow, System::Drawing::RectangleF( System::Drawing::Point( 8, 44 ), System::Drawing::Size( ClientRectangle.Width - 8, ClientRectangle.Height - 44 ) ) );
               
               // Uses the site of the component to acquire an ISelectionService and sets the property grid focus to the component.
               ISelectionService^ selectionService = dynamic_cast<ISelectionService^>(comp->Site->GetService( typeid<ISelectionService^> ));
               if ( selectionService != nullptr )
               {
                  array<IComponent^>^myArray = {m_designer->component};
                  selectionService->SetSelectedComponents( static_cast<Array^>(myArray) );
               }
            }
         }

      };


   protected:

      // RootDesignerView Control provides a full region designer view for this root designer's associated component.
      RootDesignerView^ m_view;

      // Stores reference to the LocalizationExtenderProvider this designer adds, in order to remove it on Dispose.
      LocalizationExtenderProvider^ extender;

      // Internally stores the IDesigner's component reference
      IComponent^ component;

      // Provides a RootDesignerView object that supports ViewTechnology.WindowsForms.
      Object^ GetView( ViewTechnology technology )
      {
         if ( technology != ViewTechnology::WindowsForms )
         {
            throw gcnew ArgumentException( "Not a supported view technology", "technology" );
         }

         if ( m_view == nullptr )
         {
            
            // Create the view control. In this example, a Control of type RootDesignerView is used.
            // A WindowsForms ViewTechnology view provider requires a class that inherits from Control.
            m_view = gcnew RootDesignerView( this,this->Component );
         }

         return m_view;
      }


      property array<ViewTechnology>^ SupportedTechnologies 
      {

         // This designer supports the WindowsForms view technology.
         array<ViewTechnology>^ IRootDesigner::get()
         {
            ViewTechnology myArray[] = {ViewTechnology::WindowsForms};
            return myArray;
         }

      }

   public:

      // Adds a LocalizationExtenderProvider for the component this designer is initialized to support.
      void Initialize( IComponent^ component )
      {
         this->component = component;
         
         // If no extender from this designer is active...
         if ( extender == nullptr )
         {
            
            // Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
            extender = gcnew LocalizationExtenderProvider( this->component->Site,this->component );
            
         }
      }


      property DesignerVerbCollection^ Verbs 
      {

         // Empty IDesigner interface property and method implementations
         DesignerVerbCollection^ get()
         {
            return nullptr;
         }

      }

      property IComponent^ Component 
      {
         IComponent^ get()
         {
            return this->component;
         }

      }
      void DoDefaultAction(){}

      void Dispose(){}


   protected:

      // If a LocalizationExtenderProvider has been added, removes the extender provider.
      void Dispose( bool disposing )
      {
         
         // If an extender has been added, remove it
         if ( extender != nullptr )
         {
            
            // Disposes of the extender provider.  The extender
            // provider removes itself from the extender provider
            // service when it is disposed.
            extender->Dispose();
            extender = nullptr;
         }
      }

   };


   // The following attribute associates the RootDesignedComponent with the RootDesignedComponent component.

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

   };


   // RootViewDesignerComponent is a component associated with the SampleRootDesigner
   // IRootDesigner that provides LocalizationExtenderProvider localization support.
   // This derived class is included at the top of this example to enable
   // easy launching of designer view without having to put the class in its own file.
   public ref class RootViewDesignerComponent: public RootDesignedComponent
   {
   public:
      RootViewDesignerComponent(){}

   };

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

// This example demonstrates adding localization support to a component hierarchy from a 
// custom IRootDesigner using the LocalizationExtenderProvider class.
namespace LocalizationExtenderProviderExample
{	
    // RootViewDesignerComponent is a component associated with the SampleRootDesigner
    // IRootDesigner that provides LocalizationExtenderProvider localization support.
    // This derived class is included at the top of this example to enable 
    // easy launching of designer view without having to put the class in its own file.
    public class RootViewDesignerComponent : RootDesignedComponent
    {  
        public RootViewDesignerComponent()
        {            
        }
    }

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

    // Example IRootDesigner implementation demonstrates LocalizationExtenderProvider support.
    internal class SampleRootDesigner : IRootDesigner
    {
        // RootDesignerView Control provides a full region designer view for this root designer's associated component.
        private RootDesignerView m_view;			
        // Stores reference to the LocalizationExtenderProvider this designer adds, in order to remove it on Dispose.
        private LocalizationExtenderProvider extender;        
        // Internally stores the IDesigner's component reference
        private IComponent component;                
        
        // Adds a LocalizationExtenderProvider for the component this designer is initialized to support.
        public void Initialize(System.ComponentModel.IComponent component)
        {
           this.component = component;
            
            // If no extender from this designer is active...
            if( extender == null )
            {
                // Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
                extender = new LocalizationExtenderProvider(this.component.Site, this.component);
            }
        }

        // Provides a RootDesignerView object that supports ViewTechnology.WindowsForms.
        object IRootDesigner.GetView(ViewTechnology technology) 
        {
            if (technology != ViewTechnology.WindowsForms)
            {
                throw new ArgumentException("Not a supported view technology", "technology");
            }
            if (m_view == null )
            {
                // Create the view control. In this example, a Control of type RootDesignerView is used.
                // A WindowsForms ViewTechnology view provider requires a class that inherits from Control.
                m_view = new RootDesignerView(this, this.Component);
            }
            return m_view;
        }

        // This designer supports the WindowsForms view technology.
        ViewTechnology[] IRootDesigner.SupportedTechnologies 
        {
            get
            {
                return new ViewTechnology[] {ViewTechnology.WindowsForms};
            }
        }
        
        // If a LocalizationExtenderProvider has been added, removes the extender provider.
        protected void Dispose(bool disposing)
        {            
            // If an extender has been added, remove it
            if( extender != null  )  
            {
                // Disposes of the extender provider.  The extender 
                // provider removes itself from the extender provider
                // service when it is disposed.
                extender.Dispose();
                extender = null;                
            }            
        }

        // Empty IDesigner interface property and method implementations
        public System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
            get
            {
                return null;
            }
        }

        public System.ComponentModel.IComponent Component
        {
            get
            {
                return this.component;
            }
        }

        public void DoDefaultAction()
        {            
        }

        public void Dispose()
        {        
        }
        
        // RootDesignerView is a simple control that will be displayed in the designer window.
        private class RootDesignerView : Control
        {
            private SampleRootDesigner m_designer;   
            private IComponent comp;
            
            public RootDesignerView(SampleRootDesigner designer, IComponent component)
            {
                m_designer = designer;                        
                this.comp = component;      
                BackColor = Color.Blue;
                Font = new Font(FontFamily.GenericMonospace, 12);
            }

            // Displays the name of the component and the name of the assembly of the component 
            // that this root designer is providing support for.
            protected override void OnPaint(PaintEventArgs pe)
            {
                base.OnPaint(pe);

                if( m_designer != null && comp != null )
                {
                    // Draws the name of the component in large letters.
                    pe.Graphics.DrawString("Root Designer View", Font, Brushes.Yellow, 8, 4);                    
                    pe.Graphics.DrawString("Design Name  : "+comp.Site.Name, new Font("Arial", 10), Brushes.Yellow, 8, 28);                    
                    pe.Graphics.DrawString("Assembly    : "+comp.GetType().AssemblyQualifiedName, new Font("Arial", 10), Brushes.Yellow, new Rectangle(new Point(8, 44), new Size(ClientRectangle.Width-8, ClientRectangle.Height-44)));                   

                    // Uses the site of the component to acquire an ISelectionService and sets the property grid focus to the component.
                    ISelectionService selectionService = (ISelectionService)comp.Site.GetService(typeof(ISelectionService));
                    if( selectionService != null )                
                        selectionService.SetSelectedComponents( new IComponent[] { m_designer.component } );             
                }
            }
        }
    }
}
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

' This example demonstrates adding localization support to a component hierarchy from a 
' custom IRootDesigner using the LocalizationExtenderProvider class.

' RootViewDesignerComponent is a component associated with the SampleRootDesigner
' IRootDesigner that provides LocalizationExtenderProvider localization support.
' This derived class is included at the top of this example to enable 
' easy launching of designer view without having to put the class in its own file.
Public Class RootViewDesignerComponent
    Inherits RootDesignedComponent

    Public Sub New()
    End Sub
End Class

' The following attribute associates the RootDesignedComponent with the RootDesignedComponent component.
<Designer(GetType(SampleRootDesigner), GetType(IRootDesigner))> _
Public Class RootDesignedComponent
    Inherits Component

    Public Sub New()
    End Sub
End Class

' Example IRootDesigner implementation demonstrates LocalizationExtenderProvider support.
Friend Class SampleRootDesigner
    Implements IRootDesigner

    ' RootDesignerView Control provides a full region designer view for this root designer's associated component.
    Private m_view As RootDesignerView
    ' Stores reference to the LocalizationExtenderProvider this designer adds, in order to remove it on Dispose.
    Private extender As LocalizationExtenderProvider
    ' Internally stores the IDesigner's component reference
    Private component_ As IComponent

    ' Adds a LocalizationExtenderProvider for the component this designer is initialized to support.
    Public Sub Initialize(ByVal component As System.ComponentModel.IComponent) Implements IRootDesigner.Initialize
        Me.component_ = component

        ' If no extender from this designer is active...
        If extender Is Nothing Then
            ' Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
            extender = New LocalizationExtenderProvider(Me.component_.Site, Me.component_)
        End If
    End Sub

    ' Provides a RootDesignerView object that supports ViewTechnology.WindowsForms.
    Function GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView

        If technology <> ViewTechnology.WindowsForms Then
            Throw New ArgumentException("Not a supported view technology", "technology")
        End If
        If m_view Is Nothing Then
            ' Create the view control. In this example, a Control of type RootDesignerView is used.
            ' A WindowsForms ViewTechnology view provider requires a class that inherits from Control.
            m_view = New RootDesignerView(Me, Me.Component)
        End If
        Return m_view

    End Function

    ' This designer supports the WindowsForms view technology.
    ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies
        Get
            Return New ViewTechnology() {ViewTechnology.WindowsForms}
        End Get
    End Property

    ' If a LocalizationExtenderProvider has been added, removes the extender provider.
    Protected Overloads Sub Dispose(ByVal disposing As Boolean)
        ' If an extender has been added, remove it
        If (extender IsNot Nothing) Then
            ' Disposes of the extender provider.  The extender 
            ' provider removes itself from the extender provider
            ' service when it is disposed.
            extender.Dispose()
            extender = Nothing
        End If
    End Sub

    ' Empty IDesigner interface property and method implementations
    Public ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Implements IDesigner.Verbs
        Get
            Return Nothing
        End Get
    End Property

    Public ReadOnly Property Component() As System.ComponentModel.IComponent Implements IRootDesigner.Component
        Get
            Return Me.component_
        End Get
    End Property

    Public Sub DoDefaultAction() Implements IDesigner.DoDefaultAction
    End Sub

    Public Overloads Sub Dispose() Implements IDisposable.Dispose
    End Sub

    ' RootDesignerView is a simple control that will be displayed in the designer window.
    Private Class RootDesignerView
        Inherits Control
        Private m_designer As SampleRootDesigner
        Private comp As IComponent

        Public Sub New(ByVal designer As SampleRootDesigner, ByVal component As IComponent)
            m_designer = designer
            Me.comp = component
            BackColor = Color.Blue
            Font = New Font(FontFamily.GenericMonospace, 12)
        End Sub

        ' Displays the name of the component and the name of the assembly of the component 
        ' that this root designer is providing support for.
        Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
            MyBase.OnPaint(pe)

            If (m_designer IsNot Nothing) AndAlso (comp IsNot Nothing) Then
                ' Draws the name of the component in large letters.
                pe.Graphics.DrawString("Root Designer View", Font, Brushes.Yellow, 8, 4)
                pe.Graphics.DrawString("Design Name  : " + comp.Site.Name, New Font("Arial", 10), Brushes.Yellow, 8, 28)
                
                ' Uses the site of the component to acquire an ISelectionService and sets the property grid focus to the component.
                Dim selectionService As ISelectionService = CType(comp.Site.GetService(GetType(ISelectionService)), ISelectionService)
                If (selectionService IsNot Nothing) Then
                    selectionService.SetSelectedComponents(New IComponent() {m_designer.Component})
                End If
            End If
        End Sub
    End Class

End Class

備註

檢視配接器模型會取代並新增功能至 ViewTechnology 功能;不過,如果您選擇的話, ViewTechnology 此功能會保留供回溯相容性和未來使用。

ViewTechnology 會定義標識碼,指出用來控制設計工具裝載文件的顯示模式。

您應該只在設計工具主控環境中使用 Default 值。 在舊版 .NET Framework 中ViewTechnology,列舉指定根設計工具支援的UI模型類型。 由於此模型無法擴充,因此您應該改用 檢視配接器 模型。 檢視配接器是一種類型,會將某個類型的物件調整為另一種類型。

例如,HTML 設計工具可能會傳回 DemoDOM 樹狀結構做為其檢視。 HTML 設計工具會傳回的 Default檢視技術。 Windows Forms裝載環境會有一或多個可用的檢視配接器類別。 如果這類類別可以將轉換成 DemoDOM Windows Forms 控件,裝載應用程式可以支援這種類型的設計工具。 如果沒有任何配接器可以處理從設計工具的 方法傳回的 GetView 數據類型,設計工具的載入將會失敗,而且使用者會看到錯誤。

Visual Studio 具有提供檢視配接器的可延伸配置,因此它可以適應任何 UI 技術。 第三方技術提供者也可以提供適當的檢視配接器,而且其物件模型會立即取用。

適用於