Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register custom file type with custom UI editor in Visual Studio 2010

I found old article called LearnVSXNow and part #30 - Custom Editors in Visual Studio. There is sample project The Blog Item Editor which shows how to make custom file type assigned with custom UI editor for this file type extension (.blit) This sample uses project VSXtra, which is written for Visual Studio 2008.

Can someone point me to some tutorial, how-to, or something how to do the same for Visual Studio 2010 ? My goal is to register custom file type extension (e.g. *.myext1) within visual studio 2010, and assign my own custom UI designer (WinForms, derived from UserControl) to handle editing content of such file visually.

I found some samples, but each of that shows only changes on code text editor (highlight some words, etc). But i want to show my own toolwindow with my usercontrol within it.

PS: Part of creating custom toolwindow with my own usercontrol within it is not problem, i use VSPackage Builder Project Template to build and register it within visx. My problem is how to register custom file type to use this custom toolwindow to edit file.

like image 748
psulek Avatar asked Dec 29 '22 01:12

psulek


1 Answers

While the core text editor changed significantly (nearly a total re-write, designed around MEF) in Visual Studio 2010, the general infrastructure for registering and supplying custom editors/designers did not change.

The 'Creating Custom Text Editors and Designers' page on MSDN is a good place to start. You should also be able to go through the VSPackage wizard and choose "Custom Editor" to get a basic editor in place. It will give you a simple RTF editor.

You can also check out these samples on the MSDN Code Gallery for more ideas and inspiration:

  • Editor with Toolbox Support
  • Designer View Over XML Editor

It is usually recommended that editors reside in a document window (as opposed to a tool window). This is the paradigm that nearly all the built-in editors/designers use in Visual Studio, and it's what users expect when opening something from Solution Explorer. Editing things in a ToolWindow can feel a bit unnatural.

My understanding is that VSXtra provides some additional helper/base classes (beyond what Microsoft supports) to make various tasks (like writing a custom editor/designer) simpler. It is by no means required to create a custom editor though.

like image 188
Aaron Marten Avatar answered Apr 27 '23 21:04

Aaron Marten