My Development Blog

My Development experiences

Archive for the ‘Tools’ Category

Visual Studio – File Navigation

Posted by ipwright83 on July 25, 2013

tl;dr;

VSFileNav – new improved, themed version for Visual Studio 2012 available for download here.

 

Finding Files in Visual Studio

Once upon a time I used Resharper¬†Express to jump between files in a Visual Studio solution. However in Visual Studio 2010 this feature was removed from the express version ūüė¶

navigation_gotofile

 

At this point I decided to get involved in Visual Studio extension writing and wrote my first extension VSFileNav. This allows you to quickly find files in your solution using ‘contains’ matching or Camel case matching. I use it all the time and find it incredibly useful (as do a few others who’ve rated it). It did however have a few bugs in, and didn’t install straight into VS2012. However a little while ago I finished off an update which features as a separate installer. There is a download link on the extension page but here it is again: VSFileNav VS2012

The behavior is the same as before, with some extra additions. After finally getting my head around the crazy event model in Visual Studio (blasted classes get garbage collected even when you’re hooked up to events unless you keep an explicit reference to items) it should now:

  • Re-cache all the files when you change solution.
  • Add additional files when they’re added to a project.
  • Add additional files in projects, when a project is added to the solution.
  • Remove files when they’re removed from a project…. you get where this is going?
  • Remove files when a project is removed from the solution.
  • Handle renames of both files/projects appropriately.

Additionally, and this bit took about as long as all the other functionality put together, it has been updated to use the VS2012 theme. This includes both the icons/glyphs and colours. Unfortunately due to a bug in Visual Studio this isn’t done automatically but Tools->Options->VSNav Options allows you to switch between the standard light, dark and blue themes. Here are some screenshots:

Dark

Dark

Light

Light

 

Blue

Blue

 

I hope you find it as useful as I do and find the new colour schemes nicer to the eye with the VS themes. Once again the download link is here.

Advertisements

Posted in Tools | 1 Comment »

Multiple Input Devices – Controlling the accelerator pedal

Posted by ipwright83 on April 27, 2012

My work machine has a couple of input devices, mainly to try and reduce the onset of RSI.¬†I’ve got an EM500 Ergonomic Computer Mouse¬†and a Logitech MX600 Laser Mouse

ImageImage

The¬†Ergonomic¬†mouse by the way is brilliant and really helps prevent RSI ensuring that you’re wrist is better supported and more naturally placed. There was one significant problem with it however, the sensitivity was much less than my MX600. This meant if ever myself or a fellow developer wanted to use the MX600 on my machine there was a speed conflict. Either the MX600 had the speed of a¬†Ferrari¬†and you had to be very careful not to twitch the accelerator pedal too much, or the EM500 had the speed of a tortoise.

Changing the speed of the mice in control panel quickly became a hassle, so I had a quick look around to see if there were any applications that would automatically switch it based on the device. I found one but unfortunately it cost $15 and therefore would have been a lot of hassle getting it ordered. I figured it surely can’t be that hard to write my own can it?

MouseSpeedSwitch

I started off by looking for libraries – it’s always better reusing¬†existing¬†code than writing something from scratch. I quickly came across RawInputSharp¬†which is a port of a C++ library for monitoring mouse input. I had an attempt at getting the demo’s in the library working, the compiled version worked fine, but whenever I tried to built it from source it just wouldn’t work. I left it alone and came back to it a few weeks later and discovered the problem was due to the build configuration (the target platform if I remember off the top of my head). I got it all working and was then able to register for mouse events.

public void MouseSpeedSwitch(){
   // Register for the mice
   this.mouseInput = new RawMouseInput();
   this.mouseInput.RegisterForWM_INPUT(this.Handle);
}

A little special handling later to fire the necessary updates:

/// Handle the Mouse Move Events and Update the Mouse Speed 
protected const int WM_INPUT = 0x00FF; 
protected override void WndProc(ref Message m) 
{ 
   switch (m.Msg) 
   { 
      case WM_INPUT: // Read in new mouse values. 
         if (this.mouseInput != null) 
         { 
             this.mouseInput.UpdateRawMouse(m.LParam); 
             MouseMoved(); 
         } 
         break; 
    } 
    base.WndProc(ref m); 
}

At this point I had mouse events and the ID’s of the devices every time I moved a mouse within my application. I made a minor change to the original library which suddenly switched the application to detecting mouse events globally in the operating system, regardless of whether the mouse was in my application or not. Brilliant!

public void RegisterForWM_INPUT(IntPtr hwndTarget) 
{
   RAWINPUTDEVICE rid = new RAWINPUTDEVICE();
   rid.usUsagePage = 0x01;
   rid.usUsage = 0x02; //mouse
   rid.dwFlags = 0x00000100; // Register for events outside the current window
   ...
}

Things were starting to look good at this point. A few simple methods later to retrieve the names of mice from the registry and update the mouse speed and the application was almost complete. I then wrote a little very simple UI so I could use my application:

Once added into the Startup folder in the start menu, I no longer needed to worry about changing the speed of my mouse. Everything would be done automatically ūüôā

Feel free to download the application, it’s free to use for both personal and commercial use – currently hosted here.

Posted in C#, Events, Mouse, Tools | Tagged: , , | Leave a Comment »