locked
Customizing Visual Studio Text Editor RRS feed

  • Question

  • Hi,

    I would like to customize the Visual Studio text editor but I am not sure about the technology I should use. I would like to write a VS extension which allows the programmer to insert some defined WPF control (Grid, List, ...) and to exchange data with this WPF control using C# or F#. It is may be a big step so at first, I would be happy if I only could insert a Grid at the cursor position in the editor.

    But how to do this? I am intending to use the Visual Studio SDK and MEF. In the Visual Studio "New Project" Wizard, there are 4 possibilities: Editor Classifier, Editor Margin, Editor Adornment and Editor Viewport Adornment.  I think the best one could be the "Editor Adornment" because I want to insert the WPF control at the cursor position in the editor.

    Is this a good choice to use MEF and the Editor Adornment?
    Is there another better way to solve this problem?

    Any advice would be welcome.

    Thanks,

    Olivier

    Tuesday, September 14, 2010 12:15 PM

Answers

  • Hi Olivier,

    The technologies you mention pertain to customizing the visual studio 2010 code editor. That is, adding adornments, classifiers, etc, are all scenarios that involve the 2010 code editor.

    But the scenario you initially describe sounds as if you want your own custom designer (or editor), based on a Grid or list control. If that's the case, then what you need to do is build your own custom editor, there are a good number of examples of each in the VSX samples on code gallery.

    If you are trying to do something like add a WPF user control onto the surface of the code editor, that not something I've seen done before. Theoretically, I suppose this is possible, but you'd need to provide some additional detaills such as where/when the control will be displayed, and how/if it would interact with the source.

    Thanks,


    Ed Dore
    Thursday, September 16, 2010 8:23 PM

All replies

  • Hi Olivier,

    The technologies you mention pertain to customizing the visual studio 2010 code editor. That is, adding adornments, classifiers, etc, are all scenarios that involve the 2010 code editor.

    But the scenario you initially describe sounds as if you want your own custom designer (or editor), based on a Grid or list control. If that's the case, then what you need to do is build your own custom editor, there are a good number of examples of each in the VSX samples on code gallery.

    If you are trying to do something like add a WPF user control onto the surface of the code editor, that not something I've seen done before. Theoretically, I suppose this is possible, but you'd need to provide some additional detaills such as where/when the control will be displayed, and how/if it would interact with the source.

    Thanks,


    Ed Dore
    Thursday, September 16, 2010 8:23 PM
  • Hi Ed,

    I actually try to add a WPF control onto the surface of the code editor. The user should click on a toolbar to insert this WPF control at the cursor position inside the code editor. Clicking on the WPF control should allow to use it (for example a DataGrid). Moreover when the user close the code file and re-open it, the WPF control should appears (serializable). When the user change the code, the position of the WPF control should be adapted to the change, also it should be able to be gragged and dropped onto the code editor. Something equivalent is done in the InsertImage samples from the VSX samples link you send me (thank you for this).

    Moreover, the WPF control should have properties (Strings, arrays, objects) which I would like to access (read) at compile time.

    I am not sure to understand the difference between using MEF and the own custom designer. If I understand well, I can create a custom designer to open some custom files (for example a bill editor). What I would like to do is to mix code and WPF controls in the same file (ok let the WPF control have a reference to an extra file) and it seems to be an extension of the existing code editor more than a custom editor. Can you may be tell more about the purpose of a custom editor?

     

    Olivier

    Thursday, September 30, 2010 10:47 AM