1

Kind of the opposite of this question.

While I totally get why someone would want that functionality, on the other hand there are many that liked it inside the IDE.
Not to mention that I use a different browser for FB, and not my default browser for it.

(Sorry to be driving you gus crazy! "Make it this way"/"No put it back" blabla... I get it. But seriously, can't this be an option? Don't care what the default is...)

Fog Creek Case FC1990786

flag
p.s. even a "hidden" registry key for this would work for me... – Avi D Dec 20 2010 at 10:30
Or even a right-click menu option... – Avi D Dec 22 2010 at 0:09

2 Answers

1

I've generated a feature request to make this configurable. I can't guarantee that it will be implemented, but we'll definitely evaluate it.

link|flag
Cheers! Thanks @Rob. Lemme know if I need to do more convincing of why this makes sense :) – Avi D Dec 21 2010 at 8:23
@AviD After speaking with the FogBugz team, we're not planning on reverting the change or creating a setting, unfortunately. – Rob Sobers Dec 21 2010 at 19:13
Aww no, @Rob, really? Thanks anyway... I enjoyed having everything I need for what I'm working on contained in a single window - made me much more productive. Now we have to juggle back and forth, find the right IE window (I usually have many of those open, not directly related to my immediate VS work...), and so on... Have any idea or suggestion for hack? – Avi D Dec 21 2010 at 23:21
1

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
}
}
link|flag
1 
Can I have that proglet please? It drives me batty that FogBugz links open in my default browser, instead of directly within VS. – UnnDunn Oct 20 at 2:12
@UnnDunn, sure thing, here ya go :). I added the source code into the post, just stick it into a EXE project, fix the URL to your FB, build it and run it. – Avi D Nov 10 at 8:54
I had to add a reference to EnvDTE (add reference > .net) and import the namespace in the above class (using EnvDTE;). This then creates an ambiguous reference so replace this line "Process[] procs = Process.GetProcessesByName("Devenv");" with this "System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("Devenv");" – DavidWiltonGIS Mar 6 at 7:45
@David well I actually didnt put the EnvDTE into the using (I did have the reference though), so there was no conflict for me. Whatever your snapple, I guess. – Avi D Apr 19 at 8:01

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.