DesignSurface 類別

定義

呈現可供設計元件的使用者介面。Presents a user interface for designing components.

public ref class DesignSurface : IDisposable, IServiceProvider
public class DesignSurface : IDisposable, IServiceProvider
[System.Security.SecurityCritical]
public class DesignSurface : IDisposable, IServiceProvider
type DesignSurface = class
    interface IDisposable
    interface IServiceProvider
[<System.Security.SecurityCritical>]
type DesignSurface = class
    interface IDisposable
    interface IServiceProvider
Public Class DesignSurface
Implements IDisposable, IServiceProvider
繼承
DesignSurface
屬性
實作

備註

類別會實 DesignSurface 作為設計工具的使用者。The DesignSurface class implements what the user perceives as a designer. DesignSurface 這是使用者操作來變更設計階段功能的使用者介面。DesignSurface is the user interface the user manipulates to change design-time features. DesignSurface 提供完全獨立的設計介面。DesignSurface provides a completely self-contained design surface.

DesignSurface類別可以做為獨立的設計工具使用,也可以與類別結合, DesignSurfaceManager 為裝載多個物件的應用程式提供通用的執行方式 DesignSurfaceThe DesignSurface class may be used as a stand-alone designer, or it may be coupled with the DesignSurfaceManager class to provide a common implementation for an application that hosts multiple DesignSurface objects.

DesignSurface類別可以單獨使用,或使用者可以從它衍生新的類別並增加行為。The DesignSurface class can be used by itself, or the user can derive a new class from it and augment the behavior.

DesignSurface類別會自動提供數個設計階段服務。The DesignSurface class provides several design-time services automatically. DesignSurface類別會將它的所有服務加入其函式中。The DesignSurface class adds all of its services in its constructor. 大部分的服務都可以藉由在 protected 屬性中取代來加以覆寫 ServiceContainerMost of these services can be overridden by replacing them in the protected ServiceContainer property. 若要取代服務,請覆寫此函式、呼叫基底,然後透過 protected 屬性進行任何變更 ServiceContainerTo replace a service, override the constructor, call base, and make any changes through the protected ServiceContainer property. 在處置設計介面時,會處置加入至服務容器和執行的所有服務 IDisposableAll services that are added to the service container and that implement IDisposable are disposed when the design surface is disposed. 下表顯示類別所提供的預設可取代服務集 DesignSurfaceThe default set of replaceable services that the DesignSurface class provides is shown in the following table.

服務Service 描述Description
IExtenderProviderService 可讓不屬於容器元件集合的物件提供自己的擴充項提供者。Enables objects that are not part of the container's components collection to provide their own extender providers.
IExtenderListService TypeDescriptor 來取得擴充項提供者的清單。Used by TypeDescriptor to get a list of extender providers. 透過這項服務,擴充項提供者可以存留在容器外部。With this service, extender providers can live outside of the container.
ITypeDescriptorFilterService 提供設計工具中繼資料勾點。Provides designer metadata hooks. 這是用來篩選中繼資料的主要介面。This is the primary interface for metadata filtering.
ISelectionService 提供在設計工具中選取元件的方法。Provides a way to select components in the designer.
IReferenceService 提供一種方法來取得物件的名稱,即使這些物件並未放置也一樣。Provides a way to get a name for objects, even when those objects are not sited.
DesignSurface 提供設計介面本身做為服務。Offers the design surface itself as a service.
DesignerOptionService 提供基底類別,用於取得和設定設計工具的選項值。Provides a base class for getting and setting option values for a designer.

下表顯示預設提供的非可取代服務。The following table shows the non-replaceable services provided by default.

服務Service 描述Description
IComponentChangeService 當元件變更時引發事件。Raises events as changes are made to components.
IDesignerHost 控制類型、服務和交易的存取權。Controls access to types, services, and transactions. 設計工具的主要介面。Master interface for designers.
IContainer 擁有一組所設計的元件。Owns the set of components that are being designed. 每個設計工具都有 IContainer 擁有元件的。Each designer has an IContainer that owns the components.
IServiceContainer 衍生自 IServiceProvider ,並提供從設計工具加入和移除服務的方法。Derives from IServiceProvider and provides a way to add and remove services from the designer.

除了這些服務以外, DesignSurface 類別也提供可透過元件的網站取得的單一服務。In addition to these services, the DesignSurface class also provides a single service that is available through a component's site. 此服務對於每個元件都是唯一的。This service is unique for each component. 下表顯示無法取代的服務。The following table shows the services that cannot be replaced.

服務Service 描述Description
IDictionaryService 索引鍵/值組的泛型字典,可用於儲存元件的任意資料。A generic dictionary of key/value pairs that can be used to store arbitrary data about a component.
INestedContainer 容器,可讓元件將其他子元件新增至設計工具。A container that enables a component to add additional child components to the designer. 這些元件將會是設計介面的一部分,但不會參與序列化。These components will be part of the design surface, but will not participate in serialization. 當您想要設計的控制項能夠在設計工具中公開本身的區域,但您不想要讓該區域參與序列化時,這會很有用。This is useful when you want to design a control that is capable of exposing a region of itself in a designer, but you do not want the region to participate in serialization.

除了之外 ISite ,此網站也會執行下列介面。In addition to ISite, the site also implements the following interfaces.

警告

檢查這些介面是否存在,而不是使用任意轉型,因為其他網站實現可能不會執行它們。Check for the existence of these interfaces, rather than use indiscriminate casting, because other site implementations may not implement them.

服務Service 描述Description
IServiceContainer 提供一種方法來取得網站特定服務的容器。Provides a way to get to the container of site-specific services. 例如, IDictionaryService 是網站特定的服務。For example, IDictionaryService is a site-specific service. 透過此服務,您可以新增其他網站特定的服務。With this service, you can add additional site-specific services.

建構函式

DesignSurface()

初始化 DesignSurface 類別的新執行個體。Initializes a new instance of the DesignSurface class.

DesignSurface(IServiceProvider)

初始化 DesignSurface 類別的新執行個體。Initializes a new instance of the DesignSurface class.

DesignSurface(IServiceProvider, Type)

初始化 DesignSurface 類別的新執行個體。Initializes a new instance of the DesignSurface class.

DesignSurface(Type)

初始化 DesignSurface 類別的新執行個體。Initializes a new instance of the DesignSurface class.

屬性

ComponentContainer

取得設計介面內的 IContainer 實作。Gets the IContainer implementation within the design surface.

DtelLoading

取得值,指出是否正在載入 [設計階段錯誤清單]****。Gets a value indicating whether the Design-time Error List is loading.

IsLoaded

取得值,指出目前是否已載入設計介面。Gets a value indicating whether the design surface is currently loaded.

LoadErrors

傳回載入錯誤的集合或 Void 集合。Returns a collection of loading errors or a void collection.

ServiceContainer

取得服務容器。Gets the service container.

View

取得根設計工具的檢視。Gets the view for the root designer.

方法

BeginLoad(DesignerLoader)

使用指定的設計工具載入器開始載入處理序。Begins the loading process with the given designer loader.

BeginLoad(Type)

開始載入處理序。Begins the loading process.

CreateComponent(Type)
已過時。

建立元件的執行個體。Creates an instance of a component.

CreateDesigner(IComponent, Boolean)

在將元件加入容器時建立設計工具。Creates a designer when a component is added to the container.

CreateInstance(Type)

建立指定型別的執行個體。Creates an instance of the given type.

CreateNestedContainer(IComponent)

建立適合的容器,以巢狀控制項或元件。Creates a container suitable for nesting controls or components.

CreateNestedContainer(IComponent, String)

建立適合的容器,以巢狀控制項或元件。Creates a container suitable for nesting controls or components.

Dispose()

釋放 DesignSurface 使用的資源。Releases the resources used by the DesignSurface.

Dispose(Boolean)

釋放 DesignSurface 使用的資源。Releases the resources used by the DesignSurface.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Flush()

序列化對設計介面的變更。Serializes changes to the design surface.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetService(Type)

取得服務容器中的服務。Gets a service from the service container.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnLoaded(LoadedEventArgs)

引發 Loaded 事件。Raises the Loaded event.

OnLoading(EventArgs)

引發 Loading 事件。Raises the Loading event.

OnUnloaded(EventArgs)

引發 Unloaded 事件。Raises the Unloaded event.

OnUnloading(EventArgs)

引發 Unloading 事件。Raises the Unloading event.

OnViewActivate(EventArgs)

引發 ViewActivated 事件。Raises the ViewActivated event.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

Disposed

發生於處置設計介面時。Occurs when the design surface is disposed.

Flushed

發生於呼叫 Flush()DesignSurface 方法時。Occurs when a call is made to the Flush() method of DesignSurface.

Loaded

發生於完成設計工具載入時。Occurs when the designer load has completed.

Loading

發生於即將載入設計工具時。Occurs when the designer is about to be loaded.

Unloaded

發生於設計工具完成卸載時。Occurs when a designer has finished unloading.

Unloading

發生於即將卸載設計工具時。Occurs when a designer is about to unload.

ViewActivated

發生於已在 Activate() 上呼叫 IDesignerHost 方法時。Occurs when the Activate() method has been called on IDesignerHost.

適用於

另請參閱