Okay, so after a little bit of playing around (well, this really bugged me), I hacked together a lil bit of proglet, to redirect FB requests back to VS tabs...
If anyone else wants this too, let me know and I'll send it over. As I said, it's a little bit hacky, but it works nice...
As per requested, here is the code in its entirety (as I said, it's a bit hacky, so dont judge me ;) ).
Of course, I take no responsibility for this code whatsoever, and of course backup your registry and test this, yadda yadda.
If you do have improvements, though, I'd be glad to get them too... :)
using System;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using Microsoft.Win32;
namespace FBinIDE
{
class Program
{
#region [ Enums and Constants ]
private const string FB_URL = @"https://****.fogbugz.com/";
private const string FB_VALUENAME = "FBinIDE";
private const string DEFAULT_VALUENAME = "Default Browser";
private const string COMMAND_VALUENAME = @"Progid";
private const string PROGID = @"FBinIDE";
private const string PROGCOMMAND_KEYNAME = @"shell\open\command";
private const string CLASSES_REGPATH = @"Software\Classes";
private const string COMMAND_REGPATH = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice";
#endregion [ Enums and Constants ]
[STAThread]
public static void Main(string[] args)
{
try
{
if (args == null || args.Length != 1 || String.IsNullOrEmpty(args[0]))
Install();
else if (args[0] == "-u")
Uninstall();
else
SelectBrowser(args[0]);
}
catch (Exception ex)
{
Console.WriteLine("There was an error running FBinIDE: \n" + ex.Message);
}
}
private static void Install()
{
// Set ProgId keys
string cmd = String.Format("\"{0}\" \"%1\"", Assembly.GetExecutingAssembly().Location);
RegistryKey classesKey = Registry.CurrentUser.OpenSubKey(CLASSES_REGPATH, true);
RegistryKey progId = OpenOrCreateSubKey(classesKey, PROGID);
RegistryKey progCommandKey = OpenOrCreateSubKey(progId, PROGCOMMAND_KEYNAME);
progCommandKey.SetValue(String.Empty, cmd, RegistryValueKind.String);
// Set Association Keys - Select ProgIds
RegistryKey commandKey = Registry.CurrentUser.OpenSubKey(COMMAND_REGPATH, true);
string original = commandKey.GetValue(COMMAND_VALUENAME).ToString();
if (original == PROGID)
return;
commandKey.SetValue(DEFAULT_VALUENAME, original, RegistryValueKind.String);
SetFBToDefault();
}
private static void Uninstall()
{
SetBrowserToDefault();
GetShellCommandKey().DeleteValue(DEFAULT_VALUENAME, false);
RegistryKey classesKey = Registry.CurrentUser.OpenSubKey(CLASSES_REGPATH, true);
classesKey.DeleteSubKeyTree(PROGID, false);
}
private static void SelectBrowser(string url)
{
if (url.StartsWith(FB_URL, StringComparison.InvariantCultureIgnoreCase))
{
if (!SendToVS(url))
SendToRealDefault(url);
}
else
SendToRealDefault(url);
}
private static void SetBrowserToDefault()
{
GetShellCommandKey().SetValue(COMMAND_VALUENAME, GetShellCommandKey().GetValue(DEFAULT_VALUENAME), RegistryValueKind.String);
}
private static void SetFBToDefault()
{
GetShellCommandKey().SetValue(COMMAND_VALUENAME, PROGID, RegistryValueKind.String);
}
private static void SendToRealDefault(string url)
{
SetBrowserToDefault();
System.Diagnostics.Process.Start(url);
SetFBToDefault();
}
private static bool SendToVS(string url)
{
Process[] procs = Process.GetProcessesByName("Devenv");
if (procs == null || procs.Length == 0)
return false;
EnvDTE.DTE dte;
try
{
dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");
}
catch
{
return false;
}
dte.ExecuteCommand("nav", url + @" /new");
return true;
}
#region Helper Methods
private static RegistryKey OpenOrCreateSubKey(RegistryKey baseKey, string subKeyPath)
{
return baseKey.OpenSubKey(subKeyPath, true) ?? baseKey.CreateSubKey(subKeyPath);
}
private static RegistryKey GetShellCommandKey()
{
//string regPath = String.Format( @"{0}\{1}", PROTOCOL_REGPATH, COMMAND_REGPATH );
return Registry.CurrentUser.OpenSubKey(COMMAND_REGPATH, true);
}
#endregion
}
}