Visual Studio 2013 Add custom toolbar Button - c#

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

Related

C# Control Pane remove or create keyboard shortcut for default menu and "size" option

I am currently in the final stages of releasing an add-in to Microsoft Word 2010 (this likely works for other versions of word as well) using C#, winforms, and Visual Studio Tools for Office. The goal was to create a quick tool to do some office automation and most of the code is written so I would like to avoid significant rewrites. I am very close to release but I work for a large organization that has rigorous accessibility checks. Their current issue is that the pane has a menu that the user can use to resize the pane.
The menu that is causing me all these problems:
Resizing the pane is not important, but the accessibility reviews insist that any visual element must be fully accessible by keyboard to a motor impaired user. First, I would like to know what this menu is called - I have been searching everywhere but can't find reference to it.
Second, I have three options, each of which would solve the problem, but none of which I know how to
I could make keyboard shortcuts that call that specific menu.
I could make keyboard shortcuts that call the same function as the "Size" feature of that menu (when you press "Size" the mouse snaps to the side of the Control Pane and allows the user to maker it larger or smaller) without actually calling it directly from the menu.
I could remove or disable the menu (apparently, if I can simply make that menu visible but inaccessible to all users that would satisfy the accessibility reviewer as it would prove that it is not a needed function).
Again, I do not know how to do any of the three options I listed there. Any help in doing so using C# in Visual Studio Tools for Office would be greatly appreciated.

Trying to make a Visual Studio 2015 Add-In: SDK, API.... (Reagrding ribbon or whatever its called)

I have been trying to get my head around the SDK API for visual studio for a while now. The problem is I know what I want/need to do. However I can not find a code example or API documentation anywhere that allows me to do what I want :(
I know its possible just I cant find documentation to show how.
I want to add another sidebar ribbon for all open files similar to how the breakpoint works (And many test add-ins for VS, NCrunch comes to mind...) that is blank as standard but when clicked allows some logic to be run to add a comment on that line.
Once added a Icon will be then displayed on that line allowing you to click the icon to view/edit the left comment. (The storage of this etc. is not a problem with the implementation I am doing) I just really need to know how to tell the API to add a new ribbon/side thing and plumb in the required logic :/
If this isn't possible I also had the idea of highlighting the word and again a icon popping up but that seems even more annoying to implement hence why I chose the side option if it is at all possible :/
Thanks in Advance to anyone who helps :D
The "sidebar ribbon" is called an editor margin. See Editor Extension Points.
Implement an IWpfTextViewMargin interface to define a margin. You must
also implement the IWpfTextViewMarginProvider interface to create the
margin.

How to set location of IE toolbar created using BHO and Band Objects

I had to create a Toolbar for IE using C#. After much research in the internet and few examples from code project, I have created one. Even the horrible installer/uninstaller part is done. My toolbar basically Searchbar which does a search of the things that the user enter inside the text box. Im using Google and Bing as the search engine of which the user can choose anyone as per his/her convinience. However I would like to make few changes to the Toolbar and I'm wondering how to go ahead in that.
After installing the toolbar I'm finding it somewhere near the MenuBar(after the Tools and Help menu). Is there a way to change the location of the toolbar in IE Browser using C#
I would like to create an Icon somewhere in this area
How should i approach towards this?
I also want to add an uninstall button on which when the user clicks will uninstall the toolbar from IE.
So far I havent been able to achieve any of this. Any help would be really appreciated.

Changing a buttons icon in with the visual studio SDK

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.

Outlook 2010 addin bind event to tab selection

I need to develop an Outlook 2010 add-in and I am new to Visual Studio and C#. I am using Visual Studio 2010 and I've created a project using built-in Outlook 2010 add-in template. I've created a new ribbon and I would like to trigger an event handler when a user selects the ribbon tab. Is that possible? If yes, then what objects and what events should I use? I'd like to have some guidelines on what to do, like a sequence of instructions, 'cause I don't know where to start, really.
Well first of i can help you there but step by step i can suggest a few links that have tutorials on doing this.
But to answer if you can trigger an event if you select the ribbon tab, yes this can be done in C# its usually .focus event.
First of lets say the code might be like this your ribbon name lets say is
Ribbon ribbon1=new ribbon();
if(ribbon.focus()==true)
{
messagebox.show();
}
well i hope u get the idea these are the links that you 'might' :-) have missed
http://msdn.microsoft.com/en-us/library/bb226712%28v=office.12%29.aspx
http://msdn.microsoft.com/en-us/magazine/cc163403.aspx

Categories

Resources