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
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 类结合使用,以便为承载多个 DesignSurface 对象的应用程序提供公共实现。The 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. 其中的大多数服务可以通过在 "受保护 ServiceContainer" 属性中替换来替代。Most of these services can be overridden by replacing them in the protected ServiceContainer property. 若要替换服务,请重写构造函数、调用基,并通过 protected ServiceContainer 属性进行任何更改。To replace a service, override the constructor, call base, and make any changes through the protected ServiceContainer property. 当处理设计图面时,将释放添加到服务容器并实现 IDisposable 的所有服务。All services that are added to the service container and that implement IDisposable are disposed when the design surface is disposed. 下表显示了 DesignSurface 类提供的一组默认可替换服务。The 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. 每个设计器都有一个拥有组件的 IContainerEach 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

返回加载错误的集合或空集合。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.

适用于

另请参阅