The Open With command just passes the path of the file as the first argument to the application so all you need to do is
public static void Main(string[] args)
{
if(args[0] != null)
{
//args[0] contans a path to the file do whatever you need to do to display it
}
else
{
//Start normally
}
}
To automaticly put your program in the open with list you will need to add some reg keys in HKEY_CLASSES_ROOT\YOUR_EXT\
. Here is a SO answer saying how to do it
Or you could just add it by hand to the open with list the normal way.