İngilizce dilinde oku

Aracılığıyla paylaş


ViewTechnology Sabit listesi

Tanım

Tasarımcının desteklediği teknolojilerin tanımlayıcılarını tanımlar.

C#
public enum ViewTechnology
C#
[System.Runtime.InteropServices.ComVisible(true)]
public enum ViewTechnology
Devralma
ViewTechnology
Öznitelikler

Alanlar

Name Değer Description
Default 2

Varsayılan görünüm teknolojisi desteğini belirtir.

Kök tasarımcı herhangi bir tür nesne döndürebilir, ancak nesnenin konağın teknolojisi için bir bağdaştırıcı ile uyumlu olması gerekir. Visual Studio gibi barındırma ortamları, yeni görünüm teknolojisi bağdaştırıcılarını takmak için bir yol sağlar. Windows Forms tasarımcısı için varsayılan görünüm nesnesi bir Control örnektir.

Passthrough 0

Görünüm nesnesinin doğrudan geliştirme ortamına geçirildiği modu temsil eder.

Görünüm nesnesi, geliştirme ortamının gerektirdiği tüm arabirimleri uygulamalıdır. Visual Studio geliştirme ortamı, ActiveX denetimi, etkin belge veya Visual Studio VSI (Visual Studio Tümleştirmesi) programı aracılığıyla kullanılabilen arabirimi uygulayan IVsWindowPane bir nesne olan görüntüleme nesnelerini destekler. Visual Studio geliştirme ortamı bu görünüm teknolojisi için destek sağlar. Bu görünüm teknolojisi desteğinin tüm geliştirme ortamlarında mevcut olması şart değildir.

WindowsForms 1

bir Windows Forms denetim nesnesinin kök tasarımcı için görüntü sağladığı modu temsil eder. Tasarımcı konağı geliştirme ortamı belge penceresini Windows Forms denetimiyle doldurur.

Örnekler

Aşağıdaki örnekte tasarımcıda nasıl kullanılacağı ViewTechnology.Default gösterilmektedir. Bu örnek, arabirim için GetView sağlanan daha büyük bir örneğin parçasıdır.

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

Aşağıdaki örnekte bir tasarımcıda 'ViewTechnology> numaralandırmasının nasıl kullanılacağı gösterilmektedir. Bu örnek, sınıfı için LocalizationExtenderProvider sağlanan daha büyük bir örneğin parçasıdır.

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;

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

Açıklamalar

Görünüm bağdaştırıcısı modeli özelliğin yerini alır ve özelliğe işlevsellik ViewTechnology ekler; ancak isterseniz ViewTechnology özellik hem geriye dönük uyumluluk hem de gelecekteki kullanım için korunur.

ViewTechnology , tasarımcı tarafından barındırılan bir belgenin görüntülenmesini denetlemek için kullanılacak modu gösterebilen tanımlayıcıları tanımlar.

Değerini yalnızca tasarımcı barındırma ortamınızda kullanmanız Default gerekir. .NET Framework önceki sürümlerinde, ViewTechnology numaralandırma bir kök tasarımcı tarafından desteklenen kullanıcı arabirimi modelinin türünü belirtti. Bu model genişletilebilir olmadığından, bunun yerine bir görünüm bağdaştırıcısı modeli kullanmalısınız. Görünüm bağdaştırıcısı, bir türe ait bir nesneyi diğerine uyarlayan bir türdür.

Örneğin, bir HTML tasarımcısı görünümü olarak bir DemoDOM ağaç döndürebilir. HTML tasarımcısı bir görünüm teknolojisi Defaultdöndürür. Bir Windows Forms barındırma ortamında bir veya daha fazla görünüm bağdaştırıcısı sınıfı kullanılabilir. Böyle bir sınıf öğesini DemoDOM bir Windows Forms denetimine dönüştürebiliyorsa, barındırma uygulaması bu tür tasarımcıları destekleyebilir. Tasarımcının GetView yönteminden döndürülen veri türünü hiçbir bağdaştırıcı işleyemiyorsa, tasarımcının yükü başarısız olur ve kullanıcıya bir hata gösterilir.

Visual Studio'nun görünüm bağdaştırıcıları sağlamak için genişletilebilir bir şeması vardır, böylece herhangi bir kullanıcı arabirimi teknolojisine uyarlanabilir. Üçüncü taraf teknoloji sağlayıcıları uygun bir görünüm bağdaştırıcısı da sunabilir ve nesne modelleri hemen kullanılabilir.

Şunlara uygulanır

Ürün Sürümler
.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