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.
Related
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.
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...
I would like to know if there is a way to manipulate an App's UI live while running?
I am not a designer and I have many problems sometimes regarding matching colours etc.
The next problem is that anytime I would like to change e.g. the colour of a control I have to quit the App then go to VS2012, apply my changes, build and execute it again to see simple changes.
I know that I see any changes in the designer but I have to see the resulting screen to get an impression of the whole.
Is there a way to achieve this?
Add a secret keypress while Debug flag is set, that raises a form and allows you to select controls and expose a property sheet for them. Be a bit of work to get right, and a good stick of code even using reflection. Might be better off with a storyboard type app to do your designing.
Unlike styles in WPF which can be dynamically adjusted (which made this type of run-time adjustment simple), there isn't as elegant of a solution for Windows Store apps. Ideally, you'd have all of your UI and colors, etc. defined in XAML files and not settable through other means (as it becomes a longer term maintenance issue).
I'd suggest just adding enough test data and configuration so that you can see the look and feel of the pages (with colors, etc.) at design-time. Blend and Visual Studio are now quite good at showing a very reasonable near final rendering of the elements of the application. It's generally not too difficult to do anymore.
One thing I've done in the past was to make a single page/form that contained all of the styles and controls in a large scroll viewer. Then, we set it so it was configurable to the be the first thing to run. The tweak/build cycle was pretty fast, and the results were still very manageable.
Im working on a C# project and the main window has tabs and a menu on the top. I wanted to add some style to the program and I added some icons and change the colors. Everything is fine in design mode because I can see the changes that I'm doing, But for some reason when I build the program or run debug mode or release everything changes(including the top) except the content of the tabs.The tabs are not locked and also I can see the change in the design mode as I said. any Ideas?
Make sure you are setting all the control's anchors right... if you don't you're likely to get all the controls missplaced on runtime.
What is "the top"?? If you mean that the tab bar changes the order of the content (but still keeps the same content) then perhaps you could tell us what kind of tab are you using... .NET's? a 3rd party?
Can you give us some snapshop of what you see in design mode vs. what you get after you compile?
I have found that with some changes (such as column sizes in a ListView) the changes are not always applied. What seemed to work for me was closing the design view and opening is up again. Probably also had something to do with the fact that my view (interface) was a UserControl that required rebuilding.
For some strange reason, my toopltip in the VS 2008 C# winforms application shows up behind the form! It's very frustrating and I can't figure out what I should do. Anyone face this before? Ideas?
(PS - I'm doing a toolstip.show programmatically within the form)
There are a few things you might want to check:
Make sure the tooltip knows what its parent window is.
Make sure the window the tooltip belongs to is in the foreground (no, this isn't a requirement for displaying tooltips, it just helps debug.)
Try giving focus to the owner of the tooltip. If that fixes the problem, then there's probably an ownership problem with your tooltip.
Try bringing your page element to the front. (Right click on element, bring to front). Is this happening on all tool tips you have configured? And no, I have not seen this before
There is a similar (and known) problem with tooltips appearing behind the Windows task bar. The problem is sporadic and I have never seen a solution. If you're also seeing this behavior sporadically (and I suggest that you try this on different machines), then it may be related. Otherwise, if the problem is consistent across multiple machines, let's see your code, because you're probably doing something wrong.
I have a similar issue. I have a user control written as C++ WTL, being used in a C# .NET2 app. If the control is just on the form then the controls tooltips work fine, however if the user control is on a panel or in a group then the tooltip is behind. I've tried changing the WTL code to force the tip to the front, this works but causes issues with lost focus/selection in other controls.
This problem is almost always caused by the window being TopMost. Try using SetWindowPos to set your tooltip to HWND_TOPMOST. I haven't tried this though...
I've seen this issue happen in both Windows.Forms and Delphi (native windows) based applications, caused by the interaction of "stay on top" with the Windows API.
Essentially, marking a form as TopMost makes it stay on top of some windows, but not others - Window management has more than two distinct levels.
What I found is this: my applications would behave themselves when run normally, with tooltips showing on top. Problems would occur when switching to- and from- other applications - somehow the "TopMost" of the windoww would become "very-ultra-top-most" (non-technical term ;-) ) with the tooltips appearing behind the window.
Having described the problem, I'd like to offer you a solution - but I never did find a good one. Sigh.
Hope that the additional information will be enough for you to find the solution you need.
I have seen this happen on Windows XP, particularly on the taskbar.
Are you sure it's an issue with your application, rather than the OS?