An adornment for the IDE itself - c#

Trying to get started with VS2015 Extensibility. What I have in mind can be classified as an adornment. So I did some research and found sample templates and some MSDN pages that helped me create a basic adornment. Unfortunately though these pages always talk about text adornments that work inside the text editors only, whereas my adornment will work across the entire IDE, so at times visuals might appear on top of the Solution Explorer, or the Toolbox etc. There doesn't appear to be a built-in template for that. Can anyone point me in the correction direction about it?

Related

AvalonDock: Auto-hide tool cannot be shown once hidden

I'm using Dirkster99/AvalonDock 4.70.0
I have an MVVM architecture that's very similar in structure to the VS2013 sample application.
When I use a layout initialiser to make one of my tools auto-hide (just as the sample does), everything displays and functions correctly until I forcibly hide the tool (either by clicking on the X at top right, or by using the menu that is bound to the IsVisible property). Then, I find I can't make the tool visible again (by means of the menu).
I cannot work out what I'm doing that is different from the sample, which works perfectly in this regard.
If I disable the layout initializer and place the tool with others (so it does not auto-hide), it hides and shows correctly. If I float the tool before the hide, then it shows again correctly.
Can anyone suggest how I can debug this? I've tried many times to trace the sample app alongside mine to work out how their behaviour differs, but the flow it quite complex and it's difficult to trace through event invocations. I've also tried to disable all the subtleties and complexities of the VS2013 sample in order to highlight the differences, but without success.
More information: I can demonstrate the same behaviour with the 2013 sample application. It turns out that if you change the theme from its initial setting, then the hide/show sequence does not bring back the tool window. This applies whatever is chosen as the initial theme. I'll report this as a bug on GitHub.

Visual Studio display glitching out

I'm having a persistent problem with my VS2010. After working for a while, the display will start to glitch out. The code all shows as black-on-black (I use a dark background because it's easier on the eyes, but even when I switched to the default, it just makes the text white-on-white instead.) All tooltip hovers appear in the upper-left corner of the screen instead of where they're supposed to. If you select text, the code that gets selected is nowhere near where you clicked the mouse. (Not that you can read the text anyhow since it's the same color as the background.) And none of the dockable panels will appear or if they do they're all glitched out as well. The only solution seems to be closing the program and restarting it. I've been using this copy of VS2010 for years without issue, and my other projects don't seem to have any problems. This one is C#, uses a lot of Windows Forms (not WPF), has some customized Controls, but otherwise isn't all that unusual. I have the following extensions:
CodeMaid
CSharpIntellisensePresenter
InheritanceMargin
ProductivityPowerTools
Tunnel Vision Labs Output Window Services
WatermarkTextBox Control
Some of these are recently installed so they may be the culprits. Has anyone had any display problems with any of these extensions? I can live without most of them, but I'm not sure if it'll make a difference. There's no easy way to test it either, as the glitch only shows up every couple of hours or so.

Add custom editor windows to Visual Studio window panes

My Problem
I'm trying to build an extension to Visual Studio that allows code to be edited on a per-function basis, rather than a per-file basis. I'm basically attempting to display code in a similar fashion to Microsoft Debugger Canvas.
I'm wondering how to host multiple Visual Studio editors within a single window (I believe the windows are implementing IVsWindowFrame). The functionality I'm after can be seen below:
Each editor window retains typical functionality and interacts with third-party extensions as expected. (For example, VsVim functions correctly within these windows).
What I've Tried
I've spent almost two weeks researching and trying this stuff and I'm having a lot of trouble figuring out which services, interfaces and classes I'm going to be using.
Reading through MSDN
First off, most of the documentation discusses how to edit a single editor window and add adornments, tags, margins etc. It doesn't discuss the possibility of spawning multiple editors within a window pane.
I've looked through the documentation on a vast number of interfaces of interest to me including IVsTextBuffer, IVsTextView and IVsInvisibleEditor. Unfortunately I can't get some of these interfaces to play nicely together.
On top this, the usually excellent MSDN is extremely lacking in this area. Many of the interfaces contain only a list of members without even a basic remark on intended use and functional. (IComponentModel, for example).
Many of the interfaces make reference to a set of Editor Samples but the code cannot be read or downloaded on MSDN. Apparently it shipped with Visual Studio 2005, but I don't have this version of Visual Studio, nor can I find it.
Interacting with IVsUIShell
I can get access to all WindowFrames open using IVsUIShell.GetDocumentWindowEnum();
I see there is an IVsUiShell.CreateDocumentWindow() method, but I'm completely unfamiliar with the parameters it accepts, or if this is the correct path to go down.
What I need to do
Programatically create a dockable window pane
Programatically add editors to this window pane. (And ensure they're correctly registered within Visual Studio, the running document table, etc.)
Edit:
I'm sorry, I should have expanded on my steps. When I said I needed to register with the running document table and Visual Studio, it's because I want to actually edit the original document in my custom editor. Below is a short example of the functionality available in Debugger Canvas that I'm trying to recreate:
http://i.imgur.com/aYm8A5E.gif (I can't embed a .gif)
Alternatively:
If anyone knows where I can find the editor samples included with Visual Studio 2005 such as the Basic Editor Sample I'm sure I could figure this stuff out. The MSDN documentation has no code samples regarding these interfaces, which has made my job extremely difficult.
The Git Source Control Provider is an open source extension includes a tool pane that embeds a standard editor as a control within a custom WPF tool window. I would use this code as a reference for any Visual Studio 2010+ extension where I wanted to host an editor window in some custom location.
PendingChangesView.xaml includes a ContentControl named DiffEditor, the content of which will be the editor.
PendingChangesView.xaml.cs includes a method ShowFile, which calls a method to create the editor control and assigns the result as the content of DiffEditor.
ToolWindowWithEditor.cs includes a method SetDisplayedFile which returns a Tuple<Control, IVsTextView> interface, which provides access to a Control that can be added to a ContentControl as well as the IVsTextView for the text view. The heavy lifting is in this method.
Note that the SetDisplayedFile method includes several lines with the following form:
textViewHost.TextView.Options.SetOptionValue({name}, {value});
These lines perform key functionality for the Git Source Control Provider such as removing margins and making the window read only. There are many options available, so you'll want to review the documentation for DefaultTextViewOptions and DefaultTextViewHostOptions to apply the ones appropriate for your particular extension.
I haven't actually looked at the files that #280Z28 (why this username?) posted. I used to work on the Visual Studio editor and what you are trying to do has multiple facets to it that you should tackle independently:
Hosting multiple command targets inside a single IVsWindowFrame (this means that you'll have different elements inside the same pane from the point of view of Visual Studio's shell, and each of them need to have their own command handling. Consider the case where you put your caret in one of the mini-editors and want to undo using Ctrl+Z, moments later, you then place your caret into another mini-editor and do the same. Even though the WPF and Win32 focus have remained inside the same window frame (from the point of view of the Visual Studio Shell), the commands need to be routed to different components.
Using editor's that are displaying parts of another document. The mechanisms here that will be your friend are in the projection namespace. Projection essentially allows you to project a piece of buffer (or buffers) into a view. Ellision buffers are special case projection buffers that project from one source buffer into a target view while hiding areas of the buffer (this is most likely what you want). An example of a projection buffer is what happens inside a cshtml file. In that case, there is one buffer containing all the C# code, one buffer containing all the javascript, and one buffer containing the html and each compiler works off of that buffer, but the end user sees a projection of all these buffers into the editor's view with only relevant parts displayed (for example C# import statements are elided even though they exist in the real C# buffer.)
Managing the running document so that when an edit is made in a mini-editor, the real document is dirtied. You need to handle cases where the parent file is already open in the RDT in which case you want to dirty the same document when changes are made, and also cases where the document is not open, in which case you need to create a new entry in the RDT.
Also, please post to the Visual Studio forums, there are people who regularly check the forums and route the questions to corresponding devs.
Generally speaking, when it comes to the editor, avoid any traditional interfaces (anything that does not use MEF), so samples from Visual Studio 2005 should not be used as a reference point.
If you care enough and are in Seattle, you can try to go to campus as an MVP. There are days where you come to campus, and members of varying team will grab a laptop and come to your conference room and you can debug code together or hack away (while having access to debugging symbols and what not).
Last but not least, contact the code canvas guys, I'm sure they've solved many of the problems you are facing.
You need to register a tool window with your package extension; this can be done via the ProvideToolWindow attribute. The following article contains all the required information on how an editor can be hosted in a tool window: http://bit.ly/9VWxPR
Take a look at the WpfTextViewHost class; the article explains that this type is actually an UIElement, so I imagine that it´s possible to host multiple instances of it...

Minor web-forms designer thingy

As a high-school student [that pretty much has C# knowledge of a first degree] - I got an assignment for the Israelish 'Bagrut' exams [which are the final, most important exams in high-school] - before we actually went through the materiel in-class [about 3 years earlier.]
It was to make a simple dynamic website, maybe a basic social website or an online-store, with importance of server-side ASP.NET.
My teacher gave me a book from 2006 called 'ASP.NET & XML Web Services' - and I've started learning.
The problem is, I have VS2010 Ultimate with .NET FW 4 installed, and apparently, is majorly different from the C# Express that the book author has.
On my VS, the Design Editor of the HTML is not allowing me to have the WinForms level of freedom, but makes me write the CSS myself, not show me the common XY based designer, but something like a blog WYSIWYG - without the freedom of moving stuff around.
As I do not want to work too hard converting the book instructions to my VS, I would like to know if its possible to get the [probably obsolete] WinForms - WebForms designer - and not by downloading a very old version of VS.
I've tried playing around a bit with VS, and found out that the book used System.Web.UI.Page, while my VS uses System.Web.UI.HtmlControls.HtmlForm - even manually changing to UI.Page did nothing to the designer.
Is it possible to 'go back' to the WinForm type of designer? Thank you!
No, it's not possible to do what you want. You are referring to the ugly, terrible, thing-that-should-have-never-been-created-in-the-first-place grid layout thing that Visual Studio 2003 used to have. Learn a bit of HTML. Tables are easy enough to learn and lay out things properly on your markup.
Designing webforms is much different than designing winforms, as the designer uses HTML for the markup. There's really no way to change that, but there should be a design view that allows you to drag and drop, and move things around similarly to how you would a windows form.
As for the design aspect of your site, there is probably no way to escape CSS. The design view should help you with the layout, but most of the styling and aesthetics will have to do be done in CSS.
Page shown in design view
Toolbox
View (Design/Split/Source)
Solution Explorer
Properties Window
Run (F5)
Umm, I'm no web developer and I have no real opinion about whether WebForms is really as evil as Icarus says, but I'm going to have to just throw out there as an alternate answer to his - don't learn to lay out your HTML using tables - HTML tables are for tabular data. Learn to layout your HTML using <span> and <div>, because that is the correct and standards-compliant way to do it. Also because every time you use tables for layout, a skinny-jeans-and-thick-rimmed-glasses wearing hipster dies somewhere, and we need them and their creativity.
You can switch between Content (where you can move your 'stuff') and Code in the HTML Designer, but the point is that VS2010 (be it Express or Ultimate) is for professional development and if you are unwilling to get to know HTML and CSS, there is not point in using it.
You'd be better using other tools like Adobe Dreamweaver or free tools like Amaya
Update: Try WebMatrix

In Visual C# 2010 Express, how do I add dots to the forms and see how big labels are?

I'm trying to learn how to make databases, using C# as the "master language". I've installed Microsoft Visual C# 2010 Express, created an application, etc. There's a bit of a problem though. The form on the GUI developer doesn't look normal. Usually on these things you'll see dots evenly-spaced all across the form. Also when you drag, let's say, labels on to the thing, it's pretty easy to gather exactly how big they are in both dimensions in most other IDEs. Lastly between the dots and the ease of visibility - and control - of the sizing of labels, you can usally line labels, textboxes, and other stuff up pretty easily.
In this IDE that's not quite the case. They've taken away the "coordinate dots", they've made the positioning of everything much more precise, you can't clearly see how big a label is after you put it down, etc. My question is this: How, if possible, could I switch the thing to the more traditional style in those regards?
I know my wording on this may be hard to follow. I don't know the exact terminology of some of this stuff.
Thanks!
In Visual Studio 2010 Professional, you can switch to grid mode instead of lines mode from the Options dialog box, by selecting Windows Forms Designer then setting the LayoutMode option to SnapToGrid.
Can you try that in Express?
I think you are writing off the IDE far too quickly - all this functionality is available in pro but can't vouch for express; perhaps you should try adding a bunch of controls to a form and dragging them round holding keys like [ctrl] - you will probably find most of what you need is right under your fingertips it just different to other IDEs
Like Frederic suggests the options panel contains some settings for the designer. Also ShowGrid can help with visual cues.
However I recommend using a LayoutManager like the TableLayoutPanel or FlowLayoutPanel and using the docking/anchoring techniques which eliminate boring pixel perfection problems you'll get by doing the alignments yourself. I am of course assuming you're doing a "normal" winforms Form here...
Have a look at this MSDN article: http://msdn.microsoft.com/en-us/library/ms171689.aspx

Categories