I can set a colors to object using Bru开发者_运维问答sh as follows:
Brushes.Red
How to apply the same using numbers,
say,
SetColor("#ffffff");
The above is an imaginary example.
You can use ColorTranslator.FromHtml
EDIT - In response to your comment, you can create a brush based on your colour:
SolidBrush brush = new SolidBrush(ColorTranslator.FromHtml("#ffffff"));
You can make Brushes with your own Color:
Color col = Color.FromArgb(255, 255, 255);
SolidBrush br = new SolidBrush(col);
Hope that helps.
In WPF:
var x = (Color)ColorConverter.ConvertFromString("#faffff");
Color color = Color.FromRgb(255, 255, 255);
i assume you know how to calculate the values?
I think you are looking for the Color.FromArgb method. It has an overload that allows specifying the color as an integer number.
Color c = (Color)((new ColorConverter()).ConvertFromString("#ffffff"));
精彩评论