NotEqu's Blog

Warning the User when Caps Lock is On

image

  If you need to build really cool login page, warning the user when caps lock is on can be really great trick. You can see the details and a few more tricks on Scott Mitchell article on 4 Guys From Rolla.com.

http://aspnet.4guysfromrolla.com/articles/051408-1.aspx

Posted: lip 19 2008, 09:47 by NotEqu | with no comments |
Filed under: ,
Source Code Outliner Power Toy

The Source Code Outliner Power Toy is a Visual Studio extension that gives you a tree view of source code's types and members and lets you quickly navigate to them inside the editor. This is great if you are dealing with large code files.

You can download it from here:

http://codeplex.com/SourceCodeOutliner

Posted: lip 17 2008, 03:36 by NotEqu | with no comments |
Filed under:
PowerCommands 1.1 for Visual Studio 2008

PowerCommands   Few months ago Microsoft released a set of useful extensions for the Visual Studio 2008. Here is a list of functions from version 1.1:

  • Collapse Project - collapses a hierarchy in the solution explorer starting from the root selected node. It can be executed from three different places: solution, folders and project nodes respectively
  • Copy Class - copies a selected class entire content to the clipboard. It can be executed from a single project item or a project item with dependent sub items
  • Paste Class - pastes a class entire content from the clipboard. It can be executed from a project or folder node
  • Copy References - copies a reference or set of references to the clipboard. It can be executed from the references node, a single reference node of set of reference nodes
  • Paste References - pastes a reference or set of references from the clipboard. It can be executed from different places depending on the type of project. For C# projects it can be executed from references node. For VB and Website projects it can be executed from the project node
  • Copy As Project Reference - copies a project as a project reference to the clipboard. It can be executed from a project node
  • Edit Project File - opens the MSBuild project file for a selected project inside Visual Studio. It can be executed from a project node
  • Open Containing Folder - opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node
  • Open Command Prompt - opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively
  • Unload Projects - unloads all projects in a solution. It can be executed from the solution node
  • Reload Projects - reloads all unloaded projects in a solution. It can be executed from the solution node
  • Remove and Sort Usings - removes and sort using statements for all classes given a project. It can be executed from a solution node or a single project node.
    Note: The Remove and Sort Usings feature is only available for C# projects since the C# editor implements this feature as a command in the C# editor (which this command calls for each .cs file in the project). The Visual Basic IDE implements this functionality for Imports in an interactive way: Project properties, go to the References tab, then click the Unused References... button, then select which references you want removed via a listbox

You can (must) download the PowerCommands for Visual Studio 2008 from:

http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerCommands&ReleaseId=559

Posted: lip 10 2008, 11:42 by NotEqu | with no comments |
Filed under:
Installer class

  If you want to build your own setup project for any kind of application, it is good to know something about installer classes. I will make a little example to show you how to pass the value from custom setup dialogs to installer class.

  First you add installer class into your project or you can make new project just for installer classes inside your solution. I made widows form application and added installer1.cs into my application.

Slika1

Next, open design window for installer1.cs and in properties window on Events tab choose event you would like to override. In this case let's choose AfterInstall event.

Slika2

  You will see empty method that look's like this:

private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
}

  Add setup project to your solution. Because my installer class is in windows form project, all I have to do is open File System of my setup project and add primary output to Application Folder. Then open User Interface and add dialog you need. I added RadioButtons (3 buttons) and Textboxes (A) for my example. You can change order of dialogs just by dragging them up and down. This will be the order they will show during the installation.

Slika3

  Open properties window for RadioButtons dialog and enter text and values for radio buttons now:

Slika4

  Open properties window for Textboxes dialog. This dialog consists four text boxes and because I only need two, I will set visible property to true for the first two text boxes and false for the rest of them:

Slika5 

  Then open Custom Actions and add custom action you need. For this example we only need action OnInstall. Right click on Install folder and choose Add Custom Action. Then choose Application folder and select the primary output. You can rename it if you wish. I call it OnInstall.

Slika6

  Now we need to pass the values from custom dialogs to installer class. From the previous pictures you can see that RadioButtons dialog has property called ButtonProperty witch value is BUTTON3. BUTTTON3 represents the value we chosen with radio buttons. Open properties window for OnInstall action and for CustomActionData enter:

/TEST=[BUTTON3] /FNAME=[EDITA1] /LNAME=[EDITA2] /PATH="[TARGETDIR]\"

  We sad that BUTTON3 is the value of radio button we chose. EDITA1 and EDITA2 represents the value for text boxes. We have three parameters (TEST, FNAME and LNAME) which will we use to get to this values from installer class.

Slika7

  In Installer1_AfterInstall method we will now enter some code to do something with values from setup project:

 
private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
    string myPassedValue = this.Context.Parameters["TEST"];
    string fName = this.Context.Parameters["FNAME"];
    string lName = this.Context.Parameters["LNAME"];
    string path = this.Context.Parameters["PATH"];
    StreamWriter writer = new StreamWriter("C:\\Install.log", true);
    writer.WriteLine("Install log file");
    writer.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
    writer.WriteLine("Install path is " + path);
    string s = "";
    switch (myPassedValue)
    {
        case "1":
            s = "develop";
            break;
        case "2":
            s = "test";
            break;
        case "3":
            s = "product";
            break;
    }
    writer.WriteLine("You selected " + s);
    writer.WriteLine("First name: " + fName);
    writer.WriteLine("Last name: " + lName);
    writer.Flush();
    writer.Close();
}

 

  You can see that we used TEST, FNAME and LNAME parameters to get values from setup dialogs. All that this method will do is to put this values into install.log file. I hope you will find something more useful to do with installer classes then I in this example. Good luck!