Export (0) Print
Expand All
Expand Minimize

ViewTechnology Enumeration

Defines identifiers for a set of technologies that designer hosts support.

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

[ComVisibleAttribute(true)] 
public enum ViewTechnology
/** @attribute ComVisibleAttribute(true) */ 
public enum ViewTechnology
ComVisibleAttribute(true) 
public enum ViewTechnology

 Member nameDescription
DefaultSpecifies the default view technology support.  

The root designer may return any type of object, but the object must be compatible with an adapter for the technology of the host. Hosting environments such as Visual Studio provide a way to plug in new view technology adapters. The default view object for the Windows Forms designer is a System.Windows.Forms.Control instance.

PassthroughRepresents a mode in which the view object is passed directly to the development environment.  

The view object must implement any interfaces the development environment requires. The Visual Studio development environment supports view objects that are either an ActiveX control, active document, or an object that implements the IVsWindowPane interface that is available through Visual Studio VSI (Visual Studio Integration) program. The Visual Studio development environment provides support for this view technology. Support for this view technology is not necessarily available in all development environments.

WindowsFormsRepresents a mode in which a Windows Forms control object provides the display for the root designer.  

The designer host fills the development environment document window with the Windows Forms control.

The view adapter model replaces and adds functionality to the ViewTechnology feature; however, the ViewTechnology feature is retained for both backward compatibility and future use, if you choose. For more information, see ".NET Shape Library: A Sample Designer" in the Windows Forms Knowledge Base at http://windowsforms.net/articles/shapedesigner.aspx.

ViewTechnology defines identifiers that can indicate the mode to use for controlling the display of a designer-hosted document.

You should only use the Default value in your designer hosting environment. In previous versions of the .NET Framework, the ViewTechnology enumeration specified the type of UI model supported by a root designer. Because this model is not extensible, you should instead use a view adapter model. A view adapter is a type that adapts an object of one type to another.

For example, an HTML designer might return a DemoDOM tree as its view. The HTML designer returns a view technology of Default. A Windows Forms hosting environment would have one or more view adapter classes available. If one such class could convert the DemoDOM into a Windows Forms control, the hosting application can support this type of designer. If no adapter can handle the data type returned from the designer’s GetView method, the load of the designer will fail, and the user will be presented with an error.

Visual Studio has an extensible scheme for providing view adapters, so it can adapt to any UI technology. Third-party technology providers can also offer an appropriate view adapter, and their object models are immediately consumable.

For an example that uses view adapters, see ".NET Shape Library: A Sample Designer" in the Windows Forms Knowledge Base at http://windowsforms.net/articles/shapedesigner.aspx.

The following code example demonstrates how to use the ViewTechnology class in a designer. This code example is part of a larger example provided for the IRootDesigner interface.

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

package SampleRootDesigner;

import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Diagnostics.*;
import System.Drawing.*;
import System.Windows.Forms.*;
import System.Windows.Forms.Design.*;
// 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 extends RootDesignedComponent
{
    public RootViewSampleComponent()
    {
    } //RootViewSampleComponent
} //RootViewSampleComponent

// The following attribute associates the SampleRootDesigner designer 
// with the SampleComponent component.
/** @ attribute Designer(SampleRootDesigner .class.ToType(),
    IRootDesigner .class.ToType())
 */
public class RootDesignedComponent extends Component
{
    public RootDesignedComponent()
    {
    } //RootDesignedComponent
} //RootDesignedComponent

public class SampleRootDesigner extends  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 RootDesignerView mView;

    // 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. 
    public Object GetView(ViewTechnology technology)
    {
        if (!(technology.Equals(ViewTechnology.WindowsForms))) {
            throw new ArgumentException(
                "Not a supported view technology", "technology");
        }
        if (mView == 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.
            mView = new RootDesignerView(this);
        }
        return mView;
    } //GetView

    // IRootDesigner.SupportedTechnologies is a required override for an
    // IRootDesigner. WindowsForms is the view technology used by this designer.  
    /** @property 
     */
    public ViewTechnology[] get_SupportedTechnologies()
    {
        return new ViewTechnology[] { ViewTechnology.WindowsForms };
    } //get_SupportedTechnologies

    // RootDesignerView is a simple control that will be displayed 
    // in the designer window.
    private class RootDesignerView extends Control
    {
        private SampleRootDesigner mDesigner;

        public RootDesignerView(SampleRootDesigner designer)
        {
            mDesigner = designer;
            set_BackColor(Color.get_Blue());
            set_Font(new Font(get_Font().get_FontFamily().get_Name(), 24));
        } //RootDesignerView

        protected void OnPaint(PaintEventArgs pe)
        {
            super.OnPaint(pe);

            // Draws the name of the component in large letters.
            pe.get_Graphics().DrawString(
                mDesigner.get_Component().get_Site().get_Name(), 
                get_Font(), Brushes.get_Yellow(), 
                RectangleF.op_Implicit(get_ClientRectangle()));
        } //OnPaint
    } //RootDesignerView
} //SampleRootDesigner

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft