Modify the Editor to support a custom file type and construct toolbox items for the document in Visual Studio.
- Technologies: Visual Studio 2015 SDK
- Topics: Visual Studio Shell, VSX
Description
This sample demonstrates how to create a package that provides an Editor type extended with Toolbox support. The Editor Toolbox will have custom options available whenever a .tbx file is opened.
Goals:
- Provide an editor factory.
- Document integration and persistence.
- Toolbox integration
- Handle source-controlled and read-only files.
Requirements
Get all samples
Clone the repo (How to):
git clone https://github.com/Microsoft/VSSDK-Extensibility-Samples.git
Run the sample
- To run the sample, hit F5 or choose the Debug > Start Debugging menu command. A new instance of Visual Studio will launch under the experimental hive.
- Once loaded, create new project (e.g. a C# ConsoleApplication)
- Right-click the project in the File Explorer. Click Add > New File
- In the Add New File dialog, select Text File from the list of options.
- Change the suggested filename to have 'TBX' as a file extension e.g. TextFile1.tbx.
- Click Add to add the new file to your project and close the dialog box
- The VSPackage opens a new file tab with the embedded rich textbox.
- Click View > Toolbox to launch the Toolbox window. The window contains a Toolbox Test tab. As with all toolbox tabs, it has a Pointer tool. Drag the Toolbox Sample Item tool into the .tbx file window.
- NOTE: If your toolbox does not have a Toolbox Test tab or Toolbox Sample Item tool, make sure you have a .tbx file as the active file. The tab and tool are registered specifically to the .tbx file editor.
Source Code Overview
This sample implements an editor for a.tbx** plain text file. The actual UI of this designer is simply a RichTextBox control. This sample demonstrates how to implement integration with Visual Studio Toolbox within the Editor.
The Editor uses SVsToolbox service and implements IVsToolboxUser in order to support Toolbox integration. It handles toolbox items availability and supports drag and drop text from the toolbox.
Related topics