Generating Pseudo Random Numbers in MATLAB

I wrote the code found in this post in the Student Version of MATLAB R2009a (7.8.0.347) on Windows Vista SP2.

This function will return a vector of size i containing randomly generated numbers uniformly distributed between 0 and 1.… Continue reading

Windows Vista – Moving C:Users to Another Location

Moving your personal documents to a location other than the system partition is a good idea for several reasons. Namely, if your system crashes, you can format and reinstall Windows without affecting your personal files or requiring you to move them to another location. Of course, this does not work if the entire drive crashes and takes your personal files with it!

Follow these steps (D: is the name of my location, change it to match yours):

  1. Backup your C:Users folder to an external location
  2. Boot from Windows Vista install DVD
  3. Click “Repair” from main install screen
  4. Click Command Prompt
      • robocopy C:Users D:Users /mir /xj
      • rmdir /S /Q C:Users
      • rmdir “C:Documents and Settings”
      • mklink /J C:Users D:Users
      • mklink /J “C:Documents and Settings” D:Users
      1. Reboot

      You’ll notice that C:Users now has an arrow on its icon designating that it is a link to another location. Remember to set proper permissions and remove read-only status from the new D:Users so all applications work properly!… Continue reading

      Creating a Professional ToolStrip in Windows Forms Part 2

      In my previous post, I explained how to create the basic UI elements of a simple Windows Forms application with a nice looking vertical ToolStrip menu to host buttons and labels without ever leaving the Designer. In this post, I’ll explain how to wire up some events, load in some UserControl objects, and add a custom rendering method to style our MouseClick events on the ToolStrip buttons. We’ll begin by opening the project from our previous post. (seen here)

      Prerequisites

      • Microsoft Visual Studio 2008 (or 2005, but I wrote this using 2008)
      • .NET Framework 3.5 (or 2.0, but I wrote this using 3.5)
      • Basic x,y coordinate knowledge to draw and position rectangles
      • Intermediate knowledge of C# and Windows Forms
        • Inheritance and overrides
        • Event handling

      Step 1 – Create a Custom Rendering Class

      • Right click on the Project in the Solution Explorer, Add –> New Item… –> Class (.cs).
      • Name this class customRenderer.cs and click OK.

      This class is going to inherit from ToolStripProfessionalRenderer so that we can override some of the rendering methods and make them do whatever we want. In this case, however, we will only be overriding the OnRenderButtonBackground method.

      By overriding this method, we can change the behavior of how backgrounds are rendered. Some conditions will need to be applied in order to enforce that custom rendering only occurs on ToolStripButton objects and only when the objects are in a Checked state.… Continue reading

      Creating a Professional ToolStrip in Windows Forms

      Ever wanted to create a professional looking menu in your Windows Forms applications complete with big buttons, nice mouse over effects, and images? Well, look no further. In this post, I’ll show you how to implement a graphical ToolStrip menu to navigate through a Single Document Interface (SDI). You’ll notice that the finished interface is rather similar to Spybot – Search and Destroy. Keep in mind that the following example is rather simple and leaves a lot of room for expansion.

      Prerequisites

      • Microsoft Visual Studio 2008 (or 2005, but I wrote this using 2008)
      • .NET Framework 3.5 (or 2.0, but I wrote this using 3.5)
      • Beginner’s Knowledge Windows Forms

      Step 1 – Create the Form Shell to Host the Menu

      • Create a new Windows Forms Application Project.
      • Select Form1 and adjust it’s size in the Properties Window to 964,600 (the exact size isn’t important, but you want to leave room for other controls once the menu is operational).

      Step 2 – Add the Menus

      • From the Toolbox:
        • Drag in a MenuStrip and snap it to the top of Form1 by either dragging it until the blue line snaps to the top of the form, or drop it in Form1 and set the MenuStrip object’s Dock property to Top.
        • Drag in a TableLayoutPanel to the center of the form.
          • From the submenu that pops up when you drop in the TableLayoutPanel, click “Remove Last Row.”
          • Set this new Container’s Dock property to Fill.
          • From the Toolbox, drag in a ToolStrip and drop it into the left column of the new TableLayoutPanel.
      Continue reading