locked
How to write your own Line Number Margin?

    Question

  • Hello,

    Today I tried to make my first Extension for VS2010.

    Since what I want to do is more complex I tried to imitate the Column that shows the Line Numbers of the code (when enabled) and failed.

    Since I'm totaly in the dark I would be great if someone can send me an extension that does exactly what the Line Numbers (I think its the LineNumberMargin) does (Font and Fontstyle included) so that I can  build on this.

    I also tried to find the class with reflector to copy that functionality but I did not find it. If someone can tell me the right dll so that I can analyse it for myself, this would be realy great. If it's not an .net dll than this is of course not an option ^^.

     

    Thanks

    • Moved by Noah Richards Monday, January 31, 2011 9:40 PM Question about editor extensibility (From:Visual Studio Extensibility)
    Sunday, January 30, 2011 7:04 PM

Answers

  • The line number margin is part of the standalone editor assembly, which is Microsoft.VisualStudio.Platform.VSEditor.dll (under Common7\IDE\CommonExtensions\Microsoft\Editor).

    I'll warn you, though, that it is somewhat complicated for performance reasons.  We discovered (somewhat later while building Visual Studio 2010) that adding and removing items from the WPF visual tree is pretty expensive, so the code deals with caching visual elements and updating them as scrolling occurs.  It also has code around picking the right font family/size and text rendering mode.

    I know a few other people on the team have talked about writing a PerLineVisualMargin base class, but they haven't had the time to get to it.  I know that isn't consolation, but feedback like this helps us to recognize where we should be focusing.

    Sorry for the trouble, and I hope that the line number impl can help.

    Thanks,
    -Noah

    Monday, January 31, 2011 9:39 PM

All replies

  • The line number margin is part of the standalone editor assembly, which is Microsoft.VisualStudio.Platform.VSEditor.dll (under Common7\IDE\CommonExtensions\Microsoft\Editor).

    I'll warn you, though, that it is somewhat complicated for performance reasons.  We discovered (somewhat later while building Visual Studio 2010) that adding and removing items from the WPF visual tree is pretty expensive, so the code deals with caching visual elements and updating them as scrolling occurs.  It also has code around picking the right font family/size and text rendering mode.

    I know a few other people on the team have talked about writing a PerLineVisualMargin base class, but they haven't had the time to get to it.  I know that isn't consolation, but feedback like this helps us to recognize where we should be focusing.

    Sorry for the trouble, and I hope that the line number impl can help.

    Thanks,
    -Noah

    Monday, January 31, 2011 9:39 PM
  • Thanks that's helping me a lot.

     

    Michael

    Thursday, February 03, 2011 5:48 AM