Skip to content

Commit d87ba94

Browse files
authored
Merge pull request #4469 from gewarren/extensibility-0417
Random extensibility fixes
2 parents 97e853e + ab4a5db commit d87ba94

4 files changed

+116
-99
lines changed

docs/extensibility/creating-custom-editors-and-designers.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ms.workload:
1313
- "vssdk"
1414
---
1515
# Create custom editors and designers
16+
1617
The Visual Studio integrated development environment (IDE) can host different types of editor:
1718

1819
- The Visual Studio core editor
@@ -23,10 +24,11 @@ The Visual Studio integrated development environment (IDE) can host different ty
2324

2425
- Designers
2526

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

2829
## 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).
3032

3133
### Custom editors
3234
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
6466
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.
6567

6668
## In This Section
67-
- [Walkthrough: Create a custom editor](../extensibility/walkthrough-creating-a-custom-editor.md)
68-
Explains how to create a custom editor.
6969

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

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

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

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

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

8588
## 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.
8889

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

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)].
9498

9599
## See also
100+
96101
- <xref:Microsoft.VisualStudio.Shell.Interop.IVsEditorFactory>

docs/extensibility/designer-initialization-and-metadata-configuration.md

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,86 @@ ms.workload:
1313
- "vssdk"
1414
---
1515
# Designer initialization and metadata configuration
16+
1617
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).
1718

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

2021
## 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.
2223

2324
### 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:
2527

2628
1. Modifying the designer metadata and effectively changing how a certain <xref:System.Type> is accessed or converted.
2729

2830
This is typically done through the <xref:System.Drawing.Design.UITypeEditor> or <xref:System.ComponentModel.TypeConverter> mechanisms.
2931

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

3234
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.
3335

3436
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.
3537

3638
### Designer initialization by a VSPackage
37-
A VSPackage should handle designer initialization by:
39+
40+
A VSPackage should handle designer initialization by:
3841

3942
1. Creating an object implementing the <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> class.
4043

4144
> [!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.
4346
44-
2. Register the class implementing <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension> as providing support for the VSPackage's designer extensions by 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>.
4548

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:
4750

48-
3. Accesses each registered design surface extension provider.
51+
- Accesses each registered design surface extension provider.
4952

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

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).
5356

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:
5558

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

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

6063
## Additional metadata provisioning
61-
A VSPackage can change the configuration of a designer or designer component other than at design time.
6264

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

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

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:
6872

6973
- Global -- for all new instances of a given component
7074

7175
- Local -- pertaining only to instance of the component created on a design surface provided by the current VSPackage.
7276

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

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:
7680

77-
`[ProvideDesignerMetadata(typeof(Color), typeof(CustomBrowser),` `IsGlobal=true` `)]`
81+
`[ProvideDesignerMetadata(typeof(Color), typeof(CustomBrowser),` `IsGlobal=true` `)]`
7882

79-
`internal class MyPackage : Package {}`
83+
`internal class MyPackage : Package {}`
8084

81-
If the global flag was set to `false`, then the metadata change is local to the current designer supported by the current VSPackage:
85+
If the global flag was set to `false`, then the metadata change is local to the current designer supported by the current VSPackage:
8286

83-
`[ProvideDesignerMetadata(typeof(Color), typeof(CustomBrowser),` `IsGlobal=false` `)]`
87+
`[ProvideDesignerMetadata(typeof(Color), typeof(CustomBrowser),` `IsGlobal=false` `)]`
8488

85-
`internal class MyPackage : Package {}`
89+
`internal class MyPackage : Package {}`
8690

8791
> [!NOTE]
88-
> 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.
8993
9094
## See also
95+
9196
- <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtension>
9297
- <xref:Microsoft.VisualStudio.Shell.Design.DesignSurfaceExtensionAttribute>
9398
- <xref:System.ComponentModel.ToolboxItemFilterType>

0 commit comments

Comments
 (0)