开发者

How to make Visual Studio look different depending on which solution is open?

I suspect this just isn't possibly, but it doesn't hurt much to ask.

I am working on 2 branches of the same code, so everyth开发者_StackOverflowing looks pretty identical from the solution explorer. But one is the branch, one is the trunk. I have no visual cues as to which one is open at the moment.

Is there anyway to get Visual Studio 2010 to display some visual clue that this project is different from the other?


Unless you write some sort of plugin, no. I do the same thing often, what I usually do is either make it a habit to double check the path before I work on a file (hover the mouse over the tab in VS).

or, I have two monitors, and if I'm working at the same time on two different branches, I'll have one on the left, and one on the right :-)


I had this same problem a while ago, but could not find anything that solved the problem. I got so frustrated that in the end I wrote a simple add-in for Visual Studio that showed the path of the current solution in the title bar of the window. It was not ideal however as you had to click on a tool window (eg. Solution Explorer) to get it to show, but it worked for what I needed.

The code for the addin if you are interested:

public class Connect : IDTExtensibility2
{
    private DTE2 _applicationObject;
    private WindowEvents we;

    [DllImport("user32.dll")]
    private static extern bool SetWindowText(IntPtr hWnd, string lpString);

    public void OnConnection(object application, ext_ConnectMode connectMode,
                               object addInInst, ref Array custom)
    {
        _applicationObject = (DTE2) application;

        we = _applicationObject.Events.get_WindowEvents(null);
        we.WindowActivated += WindowActivated;
    }

    private void WindowActivated(Window GotFocus, Window LostFocus)
    {
        string path = _applicationObject.Solution.FileName;

        if (!string.IsNullOrEmpty(path))
        {
            SetWindowText((IntPtr) _applicationObject.MainWindow.HWnd, path);
        }
    }
}

It's a bit crude, but helped me out a lot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜