次の方法で共有


Design-Time Architecture

Caution

This content was written for .NET Framework. If you're using .NET 6 or a later version, use this content with caution. The designer system has changed for Windows Forms and it's important that you review the Designer changes since .NET Framework article.

The following illustration provides an overview of design-time architecture in the .NET Framework.

Design-time Architecture

The .NET Framework provides interfaces and classes for customizing component behavior and user interfaces in a design-time environment. A design-time environment typically includes a forms designer for arranging components and a property browser for configuring the values of a component's properties. A design-time environment typically also provides design-time services that can be accessed and used by design-time mechanisms.

The .NET Framework defines interfaces that developers can use to implement customized design-time support. The primary mechanisms of extending design-time support fall within the following categories: designers, type converters, and UI type editors. Attributes are applied to types and type members to associate them with these design-time support providers.

Attributes

Attributes associate a type or type member with a class that extends design-time behavior. A DesignerAttribute associates a type with a designer. A TypeConverterAttribute associates a type or type member with a type converter. An EditorAttribute associates a type or type member with a UI type editor. For more information about attributes in the .NET Framework, see Design-Time Attributes for Components and Attributes and Design-Time Support.

Designers

A designer can customize the behavior of a component at design time, including its appearance, initialization, and interaction with the user. A designer can add, remove, or replace properties listed in a property browser for a selected component. A designer can provide user-defined methods that can be linked to certain component events or executed from a custom menu command, or DesignerVerb. A designer can also use services provided by a design-time environment. For more information about designers, see Custom Designers.

Type Converters

A type converter can be implemented to convert values between the type it is built to support and other data types that it can translate values to or from. A type converter can also provide logic to enable configuration of a property within a property browser at design time. A type converter can provide a list of standard values for a property of the type it supports at design time in a property browser. A type converter can also produce initialization code to initialize a property at design time. For information about implementing a type converter, see How to: Implement a Type Converter.

UI Type Editors

A UI type editor can provide a custom user interface (UI) for editing the value of a property and displaying a representation of the value of the property at design time. A UI type editor is type-specific and provides a user interface for configuring properties of the type it is built to support, or derived types which do not have an overriding attribute, at design time. A UI type editor can display a Windows Form or drop-down configuration interface for configuring a property. For more information about implementing a UI type editor, see How to: Implement a UI Type Editor.

Note

Type converters and UI type editors are used both at design time and at run time, while designers are used only at design time.

The following tables show some of the important classes in the design-related namespaces.

System.Drawing.Design

Type

Description

UITypeEditor

Provides a base class that can be used to implement value editors.

IToolboxService

Provides methods and properties to manage and query the Toolbox in the development environment.

ToolboxItem

Provides a base implementation of a toolbox item.

System.ComponentModel.Design

Type

Description

DesignerActionList

Provides the base class for types that define a list of items used to create a smart tag panel.

DesignSurface

Presents a user interface for designing components.

IDesigner

Provides the basic framework for building a custom designer.

IRootDesigner

Provides support for root-level designer view technologies.

IExtenderProviderService

Provides an interface for adding and removing extender providers at design time.

UndoEngine

Specifies generic undo/redo functionality.

System.Windows.Forms.Design

Type

Description

IWindowsFormsEditorService

Provides an interface for UI type editors to display Windows Forms or to display a control in a drop down area from a PropertyGrid control in design mode.

ControlDesigner

Base designer class for extending the design mode behavior of a Control.

DocumentDesigner

Base designer class for extending the design mode behavior of, and providing a root-level design mode view for, a Control that supports nested controls and receives scroll messages.

System.Windows.Forms.Design.Behavior

Type

Description

BehaviorService

Manages user interface in the designer.

Behavior

Represents the Behavior objects that are managed by a BehaviorService.

Adorner

Manages a collection of user-interface related Glyph objects. This class cannot be inherited.

Glyph

Represents a single user interface (UI) entity managed by an Adorner.

Design-Time Services

The .NET Framework provides a set of design-time services that can extend the capabilities of a designer. These services can be obtained using the GetService method of a component sited in design mode. You can add your own service types that can be accessed from within a design mode project using the AddService method of the IDesignerHost service interface.

The IComponentChangeService interface allows a designer to receive notifications of when components are changed, added, or removed from the design-time environment.

The IDesignerEventService interface allows a designer to receive notifications when designers are added or removed from the design-time environment and notifications when the current component selection changes.

The IDesignerFilter interface allows a designer to add to and filter the set of properties displayed in a property browser for its component.

The IDesignerHost interface provides an interface for adding and retrieving services, handling events related to designer state, detecting whether a designer is currently loading, and managing components or designer transactions. Designer transactions enable sequences of actions to occur in a mode that prevents the design-time view from refreshing its display until completion of a sequence of actions in order to improve performance, while providing a mechanism to enable the component actions of a transaction to be undone and the previous state restored.

The IDesignerOptionService interface allows a designer to get and set the values of properties listed in the Windows Forms Designer property grid accessible from the Options menu item located on the Tools menu in the Visual Studio environment. The DesignerOptionService class extends the flexibility of querying for options.

The IDictionaryService interface allows a designer to use a key-based collection for user-defined data and key pairs that can be accessed by key or value.

The IEventBindingService interface allows a designer to expose events for a component in a property browser at design time while the component is selected.

The IExtenderListService interface allows a designer to obtain the currently active extender providers in the design-time environment. The IExtenderProviderService interface allows a designer to add or remove extender providers at design time.

The IHelpService interface allows a designer to create and remove help service contexts, create and remove help context attributes, and display help topics by keyword or URL.

The IInheritanceService interface allows a designer to search for components of derived classes and identify any inheritance attributes of each.

The IMenuCommandService interface allows a designer to search for, add, remove, or invoke menu commands in the design-time environment.

The IReferenceService interface allows a designer to obtain the name of an object by reference, a reference to an object by name, a reference to the parent of a specified component, or references to objects of a specified type in the current design mode project.

The IResourceService interface allows a designer to obtain a resource reader or resource writer for a specified CultureInfo.

The IRootDesigner interface allows a designer to replace the root designer view with a custom designer view display. The IRootDesigner interface must be implemented by the designer for a component.

The ISelectionService interface allows a designer to get a set of references to the currently selected components, set the selection to a component or set of components, and to determine whether any component is selected.

The IServiceContainer interface allows a designer to add or remove services that can be used by other components or designers.

The ITypeDescriptorFilterService interface allows a component or designer to filter the attributes, events and properties exposed by any component at design time. The ITypeDescriptorFilterService interface must be implemented by a class that can be added as a service using the AddService method of the Site of a sited component in design mode.

The ITypeResolutionService interface allows a designer to add a reference to an assembly to the project, obtain a type or assembly by name, and obtain the path of a specified assembly.

The DesignerActionService and DesignerActionUIService classes implement the smart tag feature for custom designers. For more information, see Designer Commands and the DesignerAction Object Model for Windows Forms.

The BehaviorService manages user interface in a designer. It provides a uniform way to manipulate user interface elements such as mouse-related events, menu commands, and OLE drag-and-drop operations at design time. For more information, see Behavior Service Overview.

The CodeDomComponentSerializationService class serializes a set of components or serializable objects into a serialization store. For more information, see Designer Serialization Overview.

See Also

Tasks

How to: Implement a Type Converter

How to: Implement a UI Type Editor

How to: Access Design-Time Services

How to: Access Design-Time Support in Windows Forms

Concepts

Attributes and Design-Time Support

Designer Commands and the DesignerAction Object Model for Windows Forms

Behavior Service Overview

Designer Serialization Overview

Other Resources

Extending Design-Time Support

Custom Designers