Display graphics inside the Visual Studio editor - visual-studio

I'm trying to augment an existing VS addin with some graphical capabilities. For example, I might want to draw lines between related definitions.
So I'd like to overlay my own WPF control on top of the one used by the editor. How do I get hold of the WPF control used by the editor?

You need to create a new adornment layer for your graphics. See Inside the Editor for more details.

Related

Grunt background image on gruntfile.js in Visual Studio 2015

Just downloaded the VS 2015 RC and have been playing around with Gruntfile.js. I noticed Mads Kristensen demo'ing this, and various JSON files would have a background image displayed in the lower right corner based on the library it was used for (Grunt, Bower, etc...)
It looked like:
Anyone know how to get those background images to display?
It is called Adornments.
From MSDN
Adornments are graphic effects that are not directly related to the
font and color of the characters in the text view. For example, the
red squiggle underline that is used to mark non-compiling code in many
programming languages is an embedded adornment, and tooltips are
pop-up adornments. Adornments are derived from UIElement and implement
ITag. Two specialized types of adornment tag are the
SpaceNegotiatingAdornmentTag, for adornments that occupy the same
space as the text in a view, and the ErrorTag, for the squiggle
underline.
It's not a new feature from VS2015, it already existed in VS2010.
Several extensions allow you to put a custom image as a watermark on the text editor.
If you want to know how it is done under the hood, here is a GitHub repository of an extension.
Here is another MSDN article that explains which classes to implement if you want to create your extension.

How can I create a custom menu/navigation screen in Visual Studio 2012 LightSwitch?

Visual Studio 2012 LightSwitch gives you a default of 5 or 6 screens such as: search, create new, etc..
I would like to create a very basic custom navigation/main menu screen. All this screen would contain is literally 6 vertical buttons in a maximized window (For starters and for simplicity of the question) and each button would pop up another screen.
Is there anything resembling the drag-and-drop of a regular Visual Studio 2012 application? I would basically like to create a new Screen Template called: "Navigation Menu" or something similar.
Thanks, DM.
You can only create a new Screen Template by creating a LightSwitch Screen Template Extension.
However it's not really a job for the faint hearted. I've created a number of extensions over the past couple of years, & I regard the Screen Template Extension to be the hardest to do. I understand what goes into designing a Screen Template. It can be quite code-intensive, depending on what you want the template to create for you. I have a couple of screen templates that I want to create for my own needs, but I keep putting them off.
I don't want to put you off, just give you a heads up about what you're in for, if you do decide to create your own screen template extension.
One question though. Are you wanting to reuse this screen, either in the same application, or in other applications? If ther answer is "no", then creating a screen template extension would be overkill.
If you're only wanting one of these screens, to do what you described, all you have to do is add a RowsLayout control to a screen, then add one RowsLayout controlfor each navigation "button" that you want on the screen. Use the Add Button context menu option (right-click the RowsLayout control) to add a button. Set the size etc to what you want, & set the RowsLayout controls Horizontal Alignment setting to Center.
The buttons won't be all that "sexy", they'll just be larger versions of the same buttons that you'll see anywhere else in the application (except for size, if you decide to change that). The main advantage is that you can do it, quickly, & out of the box.
Or you could do something like in this article, Course Manager VS 2012 Sample Part 6 – Home Screen, if you want to improve the look of the screen.

VSPackage Builder search dialogue

I'd like to add a search dialogue popup, really just a text box or something at the top right of the current document. I've messed around with the VSPackage builder and it's easy enough, but I'm having trouble finding out which UI elements I should be looking at.
A ToolWindow doesn't quite fit I don't think -- I'd like what I'm doing to be borderless. I tried just using a custom WPF window by itself but that doesn't play well with the IDE.
It sounds what you're after is an editor viewport adornment.
This is a type of extension that has a class inherited from Microsoft.VisualStudio.Text.Editor.IWpfTextViewCreationListener
To create an adornment, you can use the Editor Viewport Adornment project template under Visual C#\Extensibility.
Try this example:
http://www.codeproject.com/Articles/55196/Code-InfoBox-Visual-Studio-Extension-VSX-2010

Where do I find, and how do I setup VS with a more "attractive" UI controls?

So today I can create a website using VS and drag and drop some ugly outdated buttons and form elements (e.g. that standard grey button, and square non styled text boxes and drop downs). I know you could replace a button with a graphic, but im no graphic designer. I want to be able to download and install some free plugin/extension that will give me a bunch of different "cool" looking options for buttons (and all the other standard form controls). So in short, I dont need new controls per say (though they are welcome and encouraged as well) but rather, I simply want a bunch of different "cool looking" visual options for the existing .net form controls, so I can make a website that doesn't look like its 90's.
I use vs 05 and 08.
for free controls have a look at codeplex:
http://dj.codeplex.com
http://yuidotnet.codeplex.com
for commercial level controls, Telerik, DevExpress, Infragistics...

Can I create a Visual Studio 2010 Add-In that Uses a WPF Display?

We're working on creating a specialized graphical editor for our enterprise applications. We've looked at and rejected DSLs. Ideally I'd like to have the main interface of the editor be docked like the code windows and use WPF for drawing. Can anyone point me to some documentation to get me on the right path?
Thanks.
Colin.
UPDATE: It's beginning to look like "no." From http://msdn.microsoft.com/en-us/library/bb166228.aspx: "Document windows are created by implementing an editor. The IVsEditorFactory interface creates document windows as part of instantiating an editor. For more information, see Accessing the Editor By Using Legacy Interfaces."
Following the link to http://msdn.microsoft.com/en-us/library/dd885127.aspx gives this this bit of advice: "You can access the Visual Studio editor from legacy interfaces. The Visual Studio SDK includes adapters known as shims, which enable these interfaces to interact with the new editor. Nevertheless, we recommend that you update your legacy code to use the new editor API. Your code will perform better and you can use new technologies such as the Windows Presentation Foundation (WPF) and the Managed Extensibility Framework (MEF)."
So, to sum up: if you want to implement an editor you have to use the legacy interfaces, but you shouldn't use the legacy interfaces because then you can't use WPF or MEF.
Seriously Microsoft, WTF?
UPDATE 2: Now that I have the proper names ("custom editor"), I was able to find the following topic: http://social.msdn.microsoft.com/Forums/en-US/vsxprerelease/thread/9e605d0f-1296-47c9-a534-e54905251ebe
I still don't see why they couldn't have included that somewhere prominent in the MSDN docs. You know, like somewhere near where they tell you that you can't use WPF if you're using the legacy interfaces.
Creating a custom editor doesn't have to be terribly painful. Yes, a custom editor will require implementing a few interfaces, but you can still use WPF to actually create the control that is hosted in the VS document frame.
DiveDeeper's blog has some great resources for learning about creating a custom editor.
Creating a simple custom editor - the basics
Creating a simple custom editor - the first 10 meters
Creating a simple custom editor - under pressure
I'd recommend using a library like VSXtra to do a lot of the work for you. It will provide you with a nice base implementation of an editor factory, editor pane, package, etc. Istvan Novak writes about building a custom editor with his VSXtra library in this blog post.

Resources