Answered by:

How to write your own Line Number Margin?

Question

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

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.

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.