Sunday, October 5, 2008

.Net free navigation bar (menu)


If you don't want to pay over 500 bucks for a super fancy navigation bar, packed with other tens of never-gonna-use controls, you can modify the below project.


What it does is take one accordion from ASP.Net Ajax Control Toolkit, and make it look like a navigation bar, in a custom control that derives from CompositeControl.

Styles are defined with CSS, you can add pictures to it, and many other things. In the end, the whole code is at disposal, and you can modify it as you think it's necessary for your application.

This is a proof of concept project. Download the VS 2008 C# project here:
If you like it and would like to use it, I would answer your comments and questions when my time allows me to.

Saturday, October 4, 2008

Improve your visual studio experience and productivity

A quicker way to do -> Solution Explorer, Select Project, RightClick, Debug, Start new Instance.



I just couldn't find a shortcut key for doing this automatically. (Except F5 which actually builds all selected projects from Configuration Manager).



On a large scale solution with tens of projects, only selecting the current project in which you currently code, and doing the right click thingie, it's a pain in the ... you know better. :)



Searching the net, couldn't find much info except this excellent post: http://www.chinhdo.com/20070920/top-11-visual-studio-2005-ide-tips-and-tricks-to-make-you-a-more-productive-developer/



This one gave me the idea of implementing a macro for doing this automatically.



Go to: Tools -> Macros -> Macro Explorer.


Right click MyMacros, add a new macro and go to edit mode:
Write these lines:
--------------------------
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RecordingModule

Sub StartDebuggingOnSelectedProject()


If (IsNothing(DTE.ActiveDocument)) Then
MsgBox("Open a document from project desired to start debug on first.", MsgBoxStyle.OkOnly, "No active document found.")
Else
If (MsgBox("Start debugging on" + DTE.ActiveDocument.ProjectItem.ContainingProject.Name, MsgBoxStyle.YesNo, "Debug?") = MsgBoxResult.Yes) Then
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance")
End If
End If

End Sub

End Module
-----------
I only wish Macros were in C# and not VB. :P

Save it, rename it, and go to: Tools-Options-Environment-Keyboard.

On "show commands containing" type the name of your macro until the one you've created appears.
Then, assign a shortcut for it, like CTRL ALT SHIFT F5 or whatever you want, and you've saved yourself enough time of right clicking a menu and choosing some second menu item (which sometimes turns out to be a mistaken click.) :)

Test it by opening a file from the desired project and hitting the keystrokes. You can improve the code, as you need.

Happy coding.