I am using the Visual Studio SDK to add in some additional functionality to visual studio.
I have a button that when pressed will perform a potentially long running task (maybe 10-15 seconds) and I would like to change the button Icon to include some indication that the task is being performed, and then again change the icon to show that the task has been completed.
Reading through the MSDN articles has shown me how to customise my icon, but I am having trouble figuring out how to change it at run time. The MSDN article configures its icons in an xml config file.
Essentially my question is how do I control the button icon in code? I have provided the link to the MSDN article that I have been using below
http://msdn.microsoft.com/en-us/library/bb165158.aspx
Thanks in advance
James
It is not a good idea (it's non standard, you can use a progress dialog or the status bar of VS instead), but if you really want you can try the following approach:
1) Get the CommandBar that has the button
2) Get the CommandBarControl in the CommandBar.Controls collection
3) Cast the CommandBarControl to CommandBarButton
4) Use the CommandBarButton.Picture and CommandBarButton.Mask properties. See section #2 of my article:
HOWTO: Creating custom pictures for Visual Studio .NET add-ins commands, buttons and toolwindows.
Related
Hey all I have been searching Google for a while now trying to find anything on how to go about setting up you're own button on the VS toolbar.
What I am talking about is this:
And when I click on that button I would like to be able to execute some C# code.
As an example, say I had the word "HELLO" highlighted and I pushed on that button on the toolbar and I wrote some code behind it that, when pressed, have whatever is highlighted turn bold and change color from normal BLACK to .
I was originally thinking that it was called Visual Studio Extensibility Tools but that doesn't seem to be what I am looking for here - it seemed more as a Nuget plugin type of thing?
I'm looking for more like what you can do with the Office suite of products within VS addins - As in make a button for Outlooks toolbar, etc..
The only remotely close thing I could find so far would be this.
If anyone has done this before or at least know what to search for then please let me know!
You were on the right track with Visual Studio Extensiblilty tools.
There are several steps.
Create the Toolbar and add the button.
Create the event handler that runs when the button is clicked.
Determine what document has focus (c# doc, xml doc, vb doc, etc.)
Determine what is selected in the document.
Change the code formatting
Start with an overview of the Extensions SDK.
Here's how to create a toolbar with the VS extensions.
Creating a Toolbar for the IDE
I recently updated my Visual Studio 2013 to Update 2 RTM. Now for my C# files, the navigation bar has a new dropdown for Projects, instead of just having Types and Members like it used to. The Projects dropdown is taking up valuable screen real estate.
Is there a way to hide that Project dropdown in the navigation bar?
See this link for a picture of what a navigation bar looks like.
Update: I added a picture of what my navigation bar looks like for a C# file.
I don't think as things currently stand that you can disable it, but its name is apparently "Context Switcher".
According to this MSDN blog, it would appear to be a new feature intended to help you manage shared files in Universal Apps. I agree that it's confusing, and I'm not a big fan.
A thorough search of the VS options for anything related to "Navigation Bar", "Context Switcher", or "Universal Apps" comes up empty and there don't seem to be any extensions offering this capability either. As far as I know these would be the main avenues for configuration, so my conclusion is that we are stuck with it until the next VS update or until someone gets around to making an extension that can disable it.
If you prefer, you can disable the navigation bar entirely in "Tools > Options > Text Editor > All Languages > Navigation Bar" (or you can disable the bar on a language by language basis.)
Update: As of Visual Studio 2013 Update 3, you can drag and adjust the relative sizing of the 3 drop down lists in the navigation bar.
From a little local testing it looks like the sizing you set is shared between all files and solutions and it persists after closing and reopening visual studio.
I shrank the context switcher down to just the visible text, and it feels more well proportioned and closer to the classic Class and Member drop down layout.
A specific issue has been opened at:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5748900-add-option-to-exclude-the-new-shared-file-dropdow
Please vote !
In Visual Studio 2013 Update 3, which was released this week (http://www.visualstudio.com/news/2014-aug-4-vs) , we have added the ability to re-size the splitters in the Navigation Bar to your own taste. We will save this setting for you. This means if you don't want to use real-estate on the Context Switcher, you can make it very small, but without changing the keyboard behavior of the Navigation Bar. We hope you like this change, which will also appear in the next public release of Visual Studio "14".
There is no (official anyway) way to hide the project dropdown currently. We are considering it though.
Please file a suggestion on http://visualstudio.uservoice.com or file a bug on https://connect.microsoft.com to get your feedback heard.
Is there a way in Visual Studio to add some comment to my code while I am executing debugging?
If I try to do it Visual Studio tells me that changes are not allowed.
Searching on Google I found many people that ask about this feature but I can't find a real solution to insert some comment into my code (only bookmarks).
Is it impossible or is there a way to accomplish this operation?
I know that in Java (using Eclipse) I can do it and it is very comfortable
Why not use the bookmark feature of visual studio?
Look under Edit->Bookmarks->Toggle Bookmark. On my machine that's a shortcut of holding Ctrl and tapping K twice.
There are shortcuts for previous/next bookmark, disable all, etc, etc.
You can also see a list of all bookmarks in the Bookmark Window (under the View menu) which allows you to name your bookmarks...
If you have enabled Edit and Continue (E&C), you should be able to edit code while your program is in break mode, e.g. you've hit a break point. It should be enabled by default, but if for some reason it isn't, you can read how to enable E&C here. For 64-bit applications, support for E&C was added with .NET 4.5.1.
If you just want to add comments as a deugging aid, i.e. not 'real' code comments, you can use a datatip aka pinned watched window's comment. Hover your mouse over a variable until the watch window pops up, pin it (top button) then expand comments (bottom button) and type whatever you want. These pinned windows are retained in between debugging sessions, and so are your comments. Combine this with bookmarks for quick navigation (Ctrl-k-k, Ctrk-k-n). Shown in action here, additional info here
Sure! you can both add comments to your codes and even modify your codes while debugging your application.
But, remember: you should Enable and Disable Edit and Continue(see here) as khellang said, and check you are in break mode(rather than debug mode).
I created a workflow in Microsoft Dynamics CRM 2011 which I then exported and opened the XAML file with VS 2010. It shows me this when I open it:
But there are actually many more steps in this workflow. Why can't I see them or edit them? I tried clicking Expand All at the top right, but that didn't seem to make any difference. If I look at the actual code I can see the numerous steps - but no in the design view. Any ideas why?
The activities in your screenshot are custom activities. By default all you see is this placeholder. You can however create custom activity designers and associate the activities with those. In your custom activity designer you can do anything you can do in WPF including showing the child activities.
I'm trying to embed visual studio as a user control (to enable the user editing a generated source file). Basically most details can be found in a nice CodeProject entry Hosting EXE Applications in a WinForm project.
What bothers me is that after launching VS as a new process it takes some time before it settles down on the form. During this period I'd like it to be hidden, so I tried:
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Also tried to turn on "CreateNoWindow" of ProcessStrartInfo with no successes.
(As a side question, I'm using process.WaitForInputIdle() to wait for VS before capturing its window handle, but on some machines the calls just returns immediatly).
Any clues? other suggestions? thanx in advance.
Robi
If you just want your user to be able to edit a source file inside your app, I'd recommend using a text edit control with syntax highlighting instead of embedding Visual Studio in your project. One option is ICSharpCode.TextEditor.
You can find more info about it in this CodeProject article.