Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to set per-solution color options (VS2010)?

Is there any way to configure VS2010 to use different color schemes for different solutions? On the Macintosh, in the 1990's, I could add wctb resources to documents so they would open with different color schemes. This made it easier to find the right window to click, and also helped avoid accidentally typing something into the wrong document (otherwise easy to do if one has several similar documents open). Is there any nice way to achieve a similar effect in VS2010? I'd mainly like to change the text background color and window background color.

When I was using vs2005 and vbEx2005, I could set vbEx to one scheme and vs to another, but right now I'm using vs2010 for everything. Is there any nice way to set colors on a per-project basis?

like image 256
supercat Avatar asked Dec 17 '22 20:12

supercat


1 Answers

Here's a nice way of doing it. Select "Macro IDE...", then open up "EnvironmentEvents" and add the following after the "Automatically generated code" region:

    Sub handleColorSettings() Handles SolutionEvents.opened, DocumentEvents.documentopening
        Dim myColor As UInt32
        myColor = &HC0FFFF
        Try
            myColor = UInt32.Parse(IO.File.ReadAllText(DTE.Solution.FullName & ".bgcolor.txt"), Globalization.NumberStyles.AllowHexSpecifier)
        Catch ex As Exception

        End Try
        CType(DTE.Properties("FontsAndColors", "TextEditor").Item("FontsAndColorsItems").Object, EnvDTE.FontsAndColorsItems).Item("Plain Text").Background = myColor
    End Sub

Any time a project is opened, or a file is opened within a project, the system will look for a file with the name "(fullSolutionName).bgcolor.txt". If, e.g., the solution is "myThing.sln", the file used will be "myThing.sln.bgcolor.txt". If such a file is found and it contains a valid hex number, that will be used as the background color. Otherwise, a default color (&hC0FFFF above, but easily changeable) will be used.

like image 157
supercat Avatar answered Jan 04 '23 17:01

supercat