posted on Wednesday, November 24, 2004 5:12 PM
by
demiliani
Zooming your code in Visual Studio .NET
It's the time to blog this tip because I receive always the same question... what are these buttons in your Visual Studio .NET?? 
Some times ago I've written an article (in italian) to show a little tip for VS.NET and now I'll try to explain it...
How many times you're going to take a conference or a demo for a customer and you have received the question "Excuse me, can you increase the font size? We can't read the code..."? I think a lot of time...
The normal action to perform this task is going to the Tools --> Options --> Fonts and Colors menu of Visual Studio .NET and change the font dimension.
I've done exactly like these for a lot of time, but some months ago I've learned that VS.NET has a powerful editor for macros... So, why don't create a macro to perform this task? The great thing of a macro is that you can call it from a button placed on the VS.NET toolbar so, imagine how useful could be to have buttons on the VS.NET toolbar to increase or decrease the font size of the code window as you want. 
Performing this task is quite simple...
We can create a new macro for VS.NET by going to the Tools --> Macros --> New Macro Project menu.

A new macro project is started. We've to choose the working directory and the project name and then push the Open button. The Macro Explorer window will magically appear to you.
On the Macro Explorer window you can see a module (Module1). Rename it as you want (I like to do so) and place the code above on it:
Imports EnvDTE Imports System.Diagnostics
Public Module Presentazioni
Public Sub Incrementa() 'Increase the font size DTE.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value += 1 End Sub
Public Sub Decrementa() 'Decrease the font size DTE.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value -= 1 End Sub
Public Sub Config_Presentazioni() 'Configuration used on presentations DTE.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value = 16 End Sub
Public Sub Config_Lavoro() 'Configuration used at work DTE.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value = 10 End Sub
End Module
|

As you can see, I've created a macro that works on the VS.NET environment properties and has 4 methods, 2 for increasing and decreasing the font size and 2 for automatically set font configurations to use at work (normally font size=10) and for presentations (normally font size=16).="/FONT">="/P"> After saving the project, now we've to create the buttons on the VS.NET Toolbar to use the macro. To do this, right click on the VS.NET Toolbar, Customize. on the Customization window, select the Commands tab and on the Categories list select Macros. On the right box you can see the list of your macros available with all their methods.

To add the buttons on the toolbar, just select the methods to add and drag&drop them on the VS.NET toolbar in the position you want. VS.NET will create a button for you. Right click on this button and you can customize it as you want (image, text etc.)
The final result is something like this:

This is what I have on my VS.NET.
By pressing the + or - buttons you can easily increase or decrease the font size of your code window.
You can download the macro code from HERE.
I think it's a tip really useful for presentations...