Freigeben über


Design-Time Architecture

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

c5z9s1h4.dtarchitecture(en-us,VS.71).gif

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 Implementing 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 Implementing 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.

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 .NET environment.

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 component sited 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.

See Also

Enhancing Design-Time Support | Attributes and Design-Time Support | Implementing a Type Converter | Implementing a UI Type Editor | Custom Designers