Adornement layer in Visual Studio 2010 editor randomly moves by scrolling - visual-studio-2010

I am trying decorate code lines with various metrics collected during an execution of a program. In order to do that I use VS extensibility and adornments layer. However it seems to be somewhat unstable and moves relative to the top of the document when the editor is scrolled and thus spoiling the alignment of code and the adornment. Also it is not always initialized in the top of the editor.
So how to anchor theadornment layer added to the code editor in Visual Studio 2010? I add a canvas into it by the folling way:
_adornmentLayer = view.GetAdornmentLayer("CodeAdornment");
_adornmentLayer.RemoveAllAdornments();
Canvas.SetTop(myOwnCanvas, 0);
adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, myOwnCanvas, null);
I start to have a feeling that it is a bug in the editor layouting.

You might want to make a viewport adornment that will always be on the top of the editor. Otherwise, you might want to use AdornmentPositioningBehavior.TextRelative and give a span for the first line in the document.

Related

A way to group controls in Visual Studio

In Adobe Illustrator and other drawing programs I can group objects so I can move them together, resize them together, or treat them as a single object when I'm doing alignments. Is there a way to do this in Visual Studio 2012? I've seen GroupBox, but that's not what I want because that's a programming object instead of a behavior of the IDE. And how can I make it such that I can, say, keep two controls fixed in position but still align or change the spacing of third a third with respect to them?
In Windows Forms you group controls by dropping them inside the same container. Then moving the container, or disabling it, or hiding it, anything really, also affects every child object too.
Rather than a GroupBox though, I'd recommend a Panel. It's a light weight object who's sole purpose is to just host controls.

Override Visual Studio 2010 UI behavior

I would like to create an extension for visual studio in which some UI behaviors are overridden. I have found many examples of adding UI components to VS, but none where they change them. A very good example of what I want to do is make it so that each tab takes up exactly 50 pixels in width (at the top of the editor window group). Is this possible? If so, what would be a good resource for me?
For your specific example, the Document Tab Well extension inside the Productivity Power Tools pack lets you set minimum and maximum widths for the editor tabs, so you could force it to 50 pixels if you want.
In general, there is no uniform way you can override or replace UI components in Visual Studio. A few components were designed to be easily replaced, while some components cannot be replaced, but many aren't replacable. The general problem with replacing components is it fails the "what if two extensions want to do it test", because it's not clear which replacement wins. Thus most extension points are add-only.
My advice: if you want to replace a specific component, ask a separate question on Stack Overflow and hopefully somebody can chime in on how to customize that particular component.

Spacer between elements in visual studio

What shall i use to make a spacer between elements in visual studio like that in QT
http://www.tuxradar.com/files/qt_menq_spacers.jpg
You might be able to use the Margin and Padding properties of any control to that end.
Edit: In response to your comment, I get the impression that your main goal is not to add a certain amount of space between controls (which would be what the Margin and Padding properties are for), but that you want to align controls along certain lines or edges. In Winforms, this is usually done via a combination of panels and the proper use of a control's Anchor and Dock properties.
You can use Anchor property to position controls relative to the dialogs edges.
And you can use a couple of panels to separate controls into different areas.
But I don´t think there is some thing like the spacers you mentioned in the question.

Visual Studio - Splitting so that Design mode is on top

VS2008 seems to have a new feature that allows one to split a website into the source code and design aspects on the same page. This feature seems great, however it defaults to having the design part on the bottom half of the screen and the code part on the top half.
Unfortunately, my brain doesn't work this way and it ends up being more of a hassle than to just continue switching back and forth when needed like I've done in the past.
Is there a way to swap them so that the design part is on the top and the code part on the bottom? Most other tools in VS are drag and droppable, so I can't see why not, but I'm not finding the setting anywhere. I did a quick google search and found a way to make the split vertical, but thats not what I'm looking for. I'm just looking for the same horizontal split with the design part on top.
Thanks
Here's an alternative approach that may help. If it's a traditional .aspx page (one that has a codebehind), you can open both documents simultaneously. Then right click one in the tab area at the top and select New Horizontal Tab Group. You can manipulate it so that the design window is on top of the code window.
I would be very surprised if this possible, since I have never seen a window configuration that changes the vertical alignment of the Objects and Events drop-down-lists.
I could be wrong, though.
It does seem rather strange - in the xaml designer you can split the screen whichever way you want as there is a button to switch the position of the panes. The options for the html designer only seem to allow a vertical or horizontal split though, there isn't anything in there specifying whether to have code or design at the top, it does seem a little backwards as I imagine most people find it more natural to have the visual designer at the top with the code below.

Drawing a line in Visual Studio .net at design time

The owner of my company wants to be able to draw lines in Visual Studio.net as he did Visual Basic 6.0. So far the only method I have found is a runtime method using system.drawing which of course only work during runtime, and not quite practical for what he wants to do.
Is there any third party control (free or otherwise) that will give him a button at design time to draw lines?
Use the Visual Basic Powerpack (free, from Microsoft, the makers of VB.Net)
The best way to draw a line in design time is to add PictureBox and set its properties as follows:
BackColor - select the color you want
Size - ex: width=1 height=300
The best option is to draw a label and set its properties as follows:
Clear the Text property.
Set the Autosize property to False.
Set BackColor as reqiured.
Set the Enabled property to False (or else it can be moved at run time).
Use Shift + arrows to resize the label, e.g. Shift+↑ to make a thin line and Shift+← to make a small line.

Resources