How can I change the background color of the code window using an add-in?

Hello,

I need to write add-in thats changes code background in code window.
Is there any samples how to do this?

I will very glad if somebody help me to do this.
Thank you.

[184 byte] By [Zenit] at [2008-2-28]
# 1

Hi Zenit,

The following macro will change the editor background to Green using the DTE. You should be able to easily do this from an addin with some minor adjustments.

Thanks,
AaronM [MSFT]


Imports System
Imports System.Drawing
Imports System.Drawing.Color
Imports EnvDTE
Imports EnvDTE80

Public Module ColorTest
Sub ChangeBackgroundColor()
Dim props As EnvDTE.Properties
props = DTE.Properties("FontsAndColors", "TextEditor")
Dim prop As EnvDTE.FontsAndColorsItems = props.Item("FontsAndColorsItems").Object
prop.Item("Plain Text").Background = ColorTranslator.ToOle(System.Drawing.Color.Green)
End Sub
End Module

Aaron_Marten at 2007-9-7 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 2
Thank you for response Aaron.
But I want to chnge background of selected text in code window(TextSelection).
How can I do this?

Thank you, Yan.

Zenit at 2007-9-7 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 3
Hi Zenit,
If the only thing you need is to programatically change the option for the Selected Text color, you can make a slight change to the code I posted above to access the "Selected Text" property instead of Plain Text.


Imports System
Imports System.Drawing
Imports System.Drawing.Color
Imports EnvDTE
Imports EnvDTE80

Public Module ColorTest
Sub ChangeBackgroundColor()
Dim props As EnvDTE.Properties
props = DTE.Properties("FontsAndColors", "TextEditor")
Dim prop As EnvDTE.FontsAndColorsItems = props.Item("FontsAndColorsItems").Object
prop.Item("Selected Text").Background = ColorTranslator.ToOle(System.Drawing.Color.Green)
End Sub
End Module

You can of course hook something like this up to the various environment events to respond to user actions. If you are trying to something more complicated, please let us know exactly what you're trying to accomplish. Are you looking to create a "highlighting" feature similar to Microsoft Word highlighting? Something else perhaps?

Thanks,
Aaron

Aaron_Marten at 2007-9-7 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 4

Hi, Aaron.

Yes. I mean highlighting.
User selects text and this text changes background. This background saves after selecting another fragment.

Can VSIP help with this problem.

Thank you.

Zenit at 2007-9-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified