How can I get visual studio text editor background colour? - c#

I want to be able to get the rgb colour of the back of the text editor in visual studio so I can use it in an addin so it goes with the theme the user has set.

If the user has modified the background font it will be stored here:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\FontAndColors\{58E96763-1D3B-4E05-B6BA-FF7115FD0B7B}\Plain Text Background
If the user has not modified the color, you could key off of the theme they are using based on this registry value:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General\CurrentTheme

This is probably what you are after: IVsFontAndColorStorage interface
http://msdn.microsoft.com/en-AU/library/microsoft.visualstudio.shell.interop.ivsfontandcolorstorage.aspx

Related

Visual Studio Color Scheme

So I updated my Visual Studio to the latest version today, and when I'm writing in C#, all the functions and variables are just white in color.
I'm so used to seeing functions in yellow and variables/properties in blue, so I would like to know if it's possible to get the colors back?
In VS 2019, go to "Tools" > "Options" > "Text Editor" > "C#" > "Advanced" and make sure in section "Editor Color Scheme" VS 2019 is selected.
Edit: looks like they changed the options there in an update. I remember that in this options-section in an earlier VS2019 version there was a switch named "Use enhanced colors for C# and Basic"
As johnmoarr suggested, try changing the default Color Scheme of the editor.
If that won't work, you can still apply colors for any element by hand. Therefore open Visual Studio, go to the Tools-menu and open the menu-item Options.
Within the Options window open Environment and then Fonts and Colors. Locate the User Members and User Types within the list of display items just like I did in the following example:
Apply the desired color to the items foreground or background. Example: set item foreground to white for User Members - Methods to display method names with white color:

How to get color values for outlook themes using outlook plugin

is there way to get outlook theme colors for items such as selected mail item color, text color, background color .. etc using outlook plugin and c#.?
Only the themes for all Office applications are available, not the specific UI implementations for each theme (e.g. selections, text, backgrounds, etc.). You could take screenshots and use color pickers in image editing applications to determine the colors of individual elements.
Otherwise the specific theme can be read in the registry in the "UI Theme" key at HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common (e.g. 0 = "Colorful", 4 = "Black", etc.).

Change RichTextBox Font keeping text color

I have a lot of formatted code snippets saved in an XML file.
On request I load them and set as Rtf in a RichTextBox:
string cscode = #"{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fprq1\fcharset0 Courier New;}{\f1\fnil\fcharset0..." etc.
rtb_cs.Rtf = cscode;
The code snippets are copy-pasted from the Visual Studio, so the text is colored differently.
Different Visual Studios are using different Fonts for the text.
Is there a way to change the Font but keep the colors?
I've tried to set the Font property of the RichTextBox, but this also resets the colors.
//This changes colors as well
rtb_cs.Font = new Font(FontFamily.GenericSansSerif, 10);
Take a look at LarsTech's solution here:
Changing font for richtextbox without losing formatting
It works for other settings too.

MS Word 2010 (VSTO) programmatically change page color

I am trying to achieve this by this code:
app.ActiveDocument.Background.Fill.Visible = Office.MsoTriState.msoTrue;
app.ActiveDocument.Background.Fill.ForeColor.RGB = ColorTranslator.ToOle(Color.Red);
app.ActiveDocument.Background.Fill.Solid();
However that does not work. Has anyone have an idea how to accomplish such task?
You are changing the background colour of the page, your code works as intended.
The background colour just won't show up in print view, and the background colour won't be printed. The background colour property in MS Word will change the background in Web View, which is handy if you want to view the Word Document in a Web Browser.
Generally, if you want to print on coloured paper, you would develop the paper separately and change the colour of the fonts on your Word Document appropriately.

Determining Excel BG color in C#

I need to write an app in C# that opens an Excel file which has rows that have either ayellow, blue or just the plain white background color, then only returns the values in Column 'A' that does NOT have a white background(just yellow or blue values in Column A should be returned).
I found code on SO to get the data from the Spreadsheet, but I don't have any info on the background color.
I can confirm, Chris Walsh's answer is good. Definitely use the Microsoft Office Primary Interop Assemblies:
http://www.microsoft.com/download/en/details.aspx?id=3508
You can also take the road of Visual Studio Tools for Office but I recommend the former, it's easier and cleaner.
Here's another code example that shows how you can SET a cell color, so you have a good sample of how to access that property.
http://forums.asp.net/t/1310118.aspx/1?Changing+Cell+color+of+excel+sheet+programatically+

Categories

Resources