LocalizationExtenderProvider 類別

定義

警告

This class has been deprecated. Use CodeDomLocalizationProvider instead. http://go.microsoft.com/fwlink/?linkid=14202

對根設計工具提供當地語系化 (Localization) 功能的設計階段支援。

C#
public class LocalizationExtenderProvider : IDisposable, System.ComponentModel.IExtenderProvider
C#
[System.Obsolete("This class has been deprecated. Use CodeDomLocalizationProvider instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public class LocalizationExtenderProvider : IDisposable, System.ComponentModel.IExtenderProvider
繼承
LocalizationExtenderProvider
屬性
實作

範例

下列程式代碼範例會將 加入 LocalizationExtenderProvider 至元件。

C#
// Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
extender = new LocalizationExtenderProvider(this.component.Site, this.component);

下列程式代碼範例包含範例元件和設計工具。 設計工具會使用 LocalizationExtenderProvider 來新增元件的當地語系化支援屬性。

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

備註

LocalizationExtenderProvider可以使用一組屬性和方法擴充 IRootDesigner ,以提供 .NET Framework 本地化架構的支援。 如需使用資源的詳細資訊,請參閱 當地語系化

當地語系化支援架構可讓設計工具使用可在運行時間交換的資源檔來初始化元件屬性,以支援各種語言、特定文化特性樣式和動態設定的功能。 您可以使用這個類別的方法,讓產生串行化程式的設計工具和程式代碼能夠從資源載入,以及建置使用當地語系化功能的初始化程序代碼。

隨附於Visual Studio的預設串行化程式已經能夠當地語系化元件和控件,但只有在找到 .NET Framework當地語系化架構的支援時,才能這麼做。 若要偵測當地語系化支援是否存在,串行化系統必須在根設計工具元件上找到名為 “Localizable” 的公用 Boolean 屬性。 如果串行化程式找到這個屬性,它會搜尋名為 「Language」 類型的 CultureInfo 屬性,以判斷目前的資源組態。 默認串行化程式會使用這些屬性來判斷它是否應該本地化元件的任何可當地語系化資源,如果是的話, CultureInfo 應該儲存資源資訊的格式為何。

建構函式

LocalizationExtenderProvider(ISite, IComponent)
已淘汰.

使用指定服務提供者 (Provider) 和基底元件,初始化 LocalizationExtenderProvider 類別的新執行個體。

方法

CanExtend(Object)
已淘汰.

指示這個物件是否可以將它的擴充項 (Extender) 屬性提供給指定的物件。

Dispose()
已淘汰.

處置 (Dispose) LocalizationExtenderProvider 所使用的資源 (除了記憶體之外)。

Dispose(Boolean)
已淘汰.

釋放 LocalizationExtenderProvider 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()
已淘汰.

做為預設雜湊函式。

(繼承來源 Object)
GetLanguage(Object)
已淘汰.

取得指定物件的目前資源文化特性。

GetLoadLanguage(Object)
已淘汰.

取得預設資源文化特性,在設計階段初始化當地語系化物件的值時使用。

GetLocalizable(Object)
已淘汰.

取得值,表示指定的物件是否支援資源當地語系化。

GetType()
已淘汰.

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()
已淘汰.

建立目前 Object 的淺層複製。

(繼承來源 Object)
ResetLanguage(Object)
已淘汰.

重設指定物件的資源文化特性。

SetLanguage(Object, CultureInfo)
已淘汰.

將指定物件的目前資源文化特性設定為指定的資源文化特性。

SetLocalizable(Object, Boolean)
已淘汰.

設定數值,表示指定的物件是否支援當地語系化資源。

ShouldSerializeLanguage(Object)
已淘汰.

取得值,表示指定物件是否必須在資源中保存 (Persist) 其當地語系化的值。

ToString()
已淘汰.

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

產品 版本 (已淘汰)
.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)