You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extensibility/creating-custom-editors-and-designers.md
+25-20Lines changed: 25 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ ms.workload:
13
13
- "vssdk"
14
14
---
15
15
# Create custom editors and designers
16
+
16
17
The Visual Studio integrated development environment (IDE) can host different types of editor:
17
18
18
19
- The Visual Studio core editor
@@ -23,10 +24,11 @@ The Visual Studio integrated development environment (IDE) can host different ty
23
24
24
25
- Designers
25
26
26
-
The following information helps you choose the type of editor you need.
27
+
The following information helps you choose the type of editor you need.
27
28
28
29
## Types of editor
29
-
For information about the Visual Studio core editor, see [Extend the editor and language services](../extensibility/extending-the-editor-and-language-services.md).
30
+
31
+
For information about the Visual Studio core editor, see [Extend the editor and language services](../extensibility/extending-the-editor-and-language-services.md).
30
32
31
33
### Custom editors
32
34
A custom editor is one that is designed to work in specialized circumstances. For example, you might create an editor whose function is to read and write data to a specific repository, such as a Microsoft Exchange server. Choose a custom editor if you want an editor that works with your project type only or if you want an editor that has only a few specific commands. Note, however, that users will not be able to use a custom editor to edit standard [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] projects.
@@ -64,33 +66,36 @@ The Visual Studio integrated development environment (IDE) can host different ty
64
66
If it can be embedded, you should create a host window for the external editor and then call the <xref:Microsoft.VisualStudio.Shell.Interop.IVsProject3.IsDocumentInProject%2A> method and set the <xref:Microsoft.VisualStudio.Shell.Interop.VSDOCUMENTPRIORITY> enumeration value to `DP_External`. If the editor cannot be embedded, the IDE will automatically create a separate window for it.
65
67
66
68
## In This Section
67
-
-[Walkthrough: Create a custom editor](../extensibility/walkthrough-creating-a-custom-editor.md)
68
-
Explains how to create a custom editor.
69
69
70
-
-[Walkthrough: Add features to a custom editor](../extensibility/walkthrough-adding-features-to-a-custom-editor.md)
71
-
Explains how to add features to a custom editor.
70
+
[Walkthrough: Create a custom editor](../extensibility/walkthrough-creating-a-custom-editor.md)\
71
+
Explains how to create a custom editor.
72
+
73
+
[Walkthrough: Add features to a custom editor](../extensibility/walkthrough-adding-features-to-a-custom-editor.md)\
74
+
Explains how to add features to a custom editor.
72
75
73
-
-[Designer initialization and metadata configuration](../extensibility/designer-initialization-and-metadata-configuration.md)
74
-
Explains how to initialize a designer.
76
+
[Designer initialization and metadata configuration](../extensibility/designer-initialization-and-metadata-configuration.md)\
77
+
Explains how to initialize a designer.
75
78
76
-
-[Supply undo support to designers](../extensibility/supplying-undo-support-to-designers.md)
77
-
Explains how to provide undo support for designers.
79
+
[Supply undo support to designers](../extensibility/supplying-undo-support-to-designers.md)\
80
+
Explains how to provide undo support for designers.
78
81
79
-
-[Syntax coloring in custom editors](../extensibility/syntax-coloring-in-custom-editors.md)
80
-
Explains the difference between syntax coloring in the core editor and in custom editors.
82
+
[Syntax coloring in custom editors](../extensibility/syntax-coloring-in-custom-editors.md)\
83
+
Explains the difference between syntax coloring in the core editor and in custom editors.
81
84
82
-
-[Document data and document view in custom editors](../extensibility/document-data-and-document-view-in-custom-editors.md)
83
-
Explains how to implement document data and document views in custom editors.
85
+
[Document data and document view in custom editors](../extensibility/document-data-and-document-view-in-custom-editors.md)\
86
+
Explains how to implement document data and document views in custom editors.
84
87
85
88
## Related sections
86
-
-[Legacy interfaces in the editor](../extensibility/legacy-interfaces-in-the-editor.md)
87
-
Explains how to access the core editor by means of the legacy API.
88
89
89
-
-[Develop a legacy language service](../extensibility/internals/developing-a-legacy-language-service.md)
90
-
Explains how to implement a language service.
90
+
[Legacy interfaces in the editor](../extensibility/legacy-interfaces-in-the-editor.md)\
91
+
Explains how to access the core editor by means of the legacy API.
91
92
92
-
-[Extend other parts of Visual Studio](../extensibility/extending-other-parts-of-visual-studio.md)
93
-
Explains how to create UI elements that match the rest of [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)].
93
+
[Develop a legacy language service](../extensibility/internals/developing-a-legacy-language-service.md)\
94
+
Explains how to implement a language service.
95
+
96
+
[Extend other parts of Visual Studio](../extensibility/extending-other-parts-of-visual-studio.md)\
97
+
Explains how to create UI elements that match the rest of [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)].
Copy file name to clipboardExpand all lines: docs/extensibility/designer-initialization-and-metadata-configuration.md
+31-26Lines changed: 31 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -13,81 +13,86 @@ ms.workload:
13
13
- "vssdk"
14
14
---
15
15
# Designer initialization and metadata configuration
16
+
16
17
Manipulation of the metadata and filter attributes associated with a designer or designer component provides a mechanism for applications to define which tools are used by a particular designer to handle different <xref:System.Type> objects (such as data structures, classes, or graphical entities), when the designer is available, and how the Visual Studio IDE is configured to support the designer (for instance which **Toolbox** category or tab is available).
17
18
18
-
The [!INCLUDE[vsipsdk](../extensibility/includes/vsipsdk_md.md)] provides several mechanisms to facilitate the control of a designer's or designer component's initialization and the manipulation of its metadata by a VSPackage.
19
+
The [!INCLUDE[vsipsdk](../extensibility/includes/vsipsdk_md.md)] provides several mechanisms to facilitate the control of a designer's or designer component's initialization and the manipulation of its metadata by a VSPackage.
19
20
20
21
## Initialize metadata and configuration information
21
-
Because they are loaded on demand, VSPackages may not have been loaded by the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] environment prior to the instantiation of a designer. Therefore, VSPackages cannot use the standard mechanism for configuring a designer or designer component on creation, which is to handle a <xref:System.ComponentModel.Design.IDesignerEventService.DesignerCreated> event. Instead, a VSPackage implements an instance of the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> interface and registers itself to provide customizations, referred to as design surface extensions.
22
+
Because they are loaded on demand, VSPackages may not have been loaded by the Visual Studio environment prior to the instantiation of a designer. Therefore, VSPackages cannot use the standard mechanism for configuring a designer or designer component on creation, which is to handle a <xref:System.ComponentModel.Design.IDesignerEventService.DesignerCreated> event. Instead, a VSPackage implements an instance of the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> interface and registers itself to provide customizations, referred to as design surface extensions.
22
23
23
24
### Customize initialization
24
-
Customizing a designer, a component, or a designer surface, involves:
25
+
26
+
Customizing a designer, a component, or a designer surface, involves:
25
27
26
28
1. Modifying the designer metadata and effectively changing how a certain <xref:System.Type> is accessed or converted.
27
29
28
30
This is typically done through the <xref:System.Drawing.Design.UITypeEditor> or <xref:System.ComponentModel.TypeConverter> mechanisms.
29
31
30
-
For example, when <xref:System.Windows.Forms>-based designers are initialized, the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] environment modifies the <xref:System.Drawing.Design.UITypeEditor> for <xref:System.Web.UI.WebControls.Image> objects used with the designer to use the resource manager to obtain bitmaps rather than the file system.
32
+
For example, when <xref:System.Windows.Forms>-based designers are initialized, the Visual Studio environment modifies the <xref:System.Drawing.Design.UITypeEditor> for <xref:System.Web.UI.WebControls.Image> objects used with the designer to use the resource manager to obtain bitmaps rather than the file system.
31
33
32
34
2. Integrating with the environment, for example, by subscribing to events or obtaining project configuration information. You can obtain project configuration information and subscribe to events by obtaining the <xref:System.ComponentModel.Design.ITypeResolutionService> interface.
33
35
34
36
3. Modification of the user environment by activating appropriate **Toolbox** categories or by restricting the designer's applicability by applying an instance of the <xref:System.ComponentModel.ToolboxItemFilterAttribute> class to the designer.
35
37
36
38
### Designer initialization by a VSPackage
37
-
A VSPackage should handle designer initialization by:
39
+
40
+
A VSPackage should handle designer initialization by:
38
41
39
42
1. Creating an object implementing the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> class.
40
43
41
44
> [!NOTE]
42
-
> The <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> class should never be implemented on the same object as the <xref:Microsoft.VisualStudio.Shell.Package> class.
45
+
> The <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> class should never be implemented on the same object as the <xref:Microsoft.VisualStudio.Shell.Package> class.
43
46
44
-
2.Register the class implementing <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> as providing support for the VSPackage's designer extensionsby applying instances of <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtensionAttribute>, <xref:Microsoft.VisualStudio.Shell.ProvideObjectAttribute> and <xref:Microsoft.VisualStudio.Shell.ProvideServiceAttribute> to the class providing the VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package>.
47
+
2.Registering the class that implements <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> as providing support for the VSPackage's designer extensions. Register the class by applying instances of <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtensionAttribute>, <xref:Microsoft.VisualStudio.Shell.ProvideObjectAttribute>, and <xref:Microsoft.VisualStudio.Shell.ProvideServiceAttribute> to the class that provides the VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package>.
45
48
46
-
Whenever any designer or designer component is created, the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] environment:
49
+
Whenever a designer or designer component is created, the Visual Studio environment:
47
50
48
-
3. Accesses each registered design surface extension provider.
51
+
- Accesses each registered design surface extension provider.
49
52
50
-
4. Instantiates and initializes an instance of each design surface extension provider's <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object
53
+
- Instantiates and initializes an instance of each design surface extension provider's <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object.
51
54
52
-
5. Calls each design surface extension provider's <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension.OnDesignerCreated%2A> method or <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension.OnComponentCreated%2A> method (as appropriate).
55
+
- Calls each design surface extension provider's <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension.OnDesignerCreated%2A> method or <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension.OnComponentCreated%2A> method (as appropriate).
53
56
54
-
When implementing the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object as a member of a VSPackage, it is important to understand that:
57
+
When implementing the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object as a member of a VSPackage, it is important to understand that:
55
58
56
-
6. The [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] environment does not provide any control over what metadata or other configuration settings a particular `DesignSurfaceExtension` provider's modifies. It is possible for two or more `DesignSurfaceExtension` providers modifying the same designer feature in conflicting ways, with the final modification being definitive. It is indeterminate which modification is last applied.
59
+
- The Visual Studio environment does not provide any control over what metadata or other configuration settings a particular `DesignSurfaceExtension` provider's modifies. It is possible for two or more `DesignSurfaceExtension` providers modifying the same designer feature in conflicting ways, with the final modification being definitive. It is indeterminate which modification is last applied.
57
60
58
-
7. It is possible to explicitly restrict an implementation of the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object to specific designers, by applying instances of <xref:System.ComponentModel.ToolboxItemFilterAttribute> to that implementation. For more information on **Toolbox** item filtering, see the <xref:System.ComponentModel.ToolboxItemFilterAttribute> and <xref:System.ComponentModel.ToolboxItemFilterType>.
61
+
- It's possible to explicitly restrict an implementation of the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> object to specific designers by applying instances of <xref:System.ComponentModel.ToolboxItemFilterAttribute> to that implementation. For more information on **Toolbox** item filtering, see the <xref:System.ComponentModel.ToolboxItemFilterAttribute> and <xref:System.ComponentModel.ToolboxItemFilterType>.
59
62
60
63
## Additional metadata provisioning
61
-
A VSPackage can change the configuration of a designer or designer component other than at design time.
62
64
63
-
The <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> class can be used programmatically, or be applied to a VSPackage providing a designer.
65
+
A VSPackage can change the configuration of a designer or designer component other than at design time.
64
66
65
-
An instance of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> class is used to modify the metadata of components created on a design surface. For example, one could replace a default property browser used by <xref:System.Windows.Forms.CommonDialog> objects, with a custom property browser.
67
+
The <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> class can be used programmatically or applied to a VSPackage that provides a designer.
66
68
67
-
Modifications provided by an instance of <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> applied to a VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package> can have one of two scopes:
69
+
An instance of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> class is used to modify the metadata of components created on a design surface. For example, one could replace a default property browser used by <xref:System.Windows.Forms.CommonDialog> objects with a custom property browser.
70
+
71
+
Modifications provided by an instance of <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> applied to a VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package> can have one of two scopes:
68
72
69
73
- Global -- for all new instances of a given component
70
74
71
75
- Local -- pertaining only to instance of the component created on a design surface provided by the current VSPackage.
72
76
73
-
The `IsGlobal` property of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> instance applied to a VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package> determines this scope.
77
+
The `IsGlobal` property of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> instance applied to a VSPackage's implementation of <xref:Microsoft.VisualStudio.Shell.Package> determines this scope.
74
78
75
-
Applying the attribute to an implementation of <xref:Microsoft.VisualStudio.Shell.Package> with the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute.IsGlobal%2A> property of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> object set to `true`, as below, changes the browser for the entire [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] environment:
79
+
Applying the attribute to an implementation of <xref:Microsoft.VisualStudio.Shell.Package> with the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute.IsGlobal%2A> property of the <xref:Microsoft.VisualStudio.Shell.Design.ProvideDesignerMetadataAttribute> object set to `true`, as below, changes the browser for the entire Visual Studio environment:
> At the present time, the design surface only supports creating components, and therefore only components can have local metadata. In the example above, we were attempting to modify a property, such as the `Color` property of an object. If `false` was passed in for the global flag, `CustomBrowser` would never appear because the designer never actually creates an instance of `Color`. Setting the global flag to `false` is useful for components, such as controls, timers, and dialog boxes.
92
+
> The design surface only supports creating components, and therefore only components can have local metadata. In the example above, we were attempting to modify a property, such as the `Color` property of an object. If `false` was passed in for the global flag, `CustomBrowser` would never appear because the designer never actually creates an instance of `Color`. Setting the global flag to `false` is useful for components, such as controls, timers, and dialog boxes.
0 commit comments