2 using System.Collections.Generic;
5 using System.Xml.Serialization;
6 using DirectOutput.General.Generic;
8 namespace DirectOutput.Cab.Color
21 private int _BrightnessRed;
30 get {
return _BrightnessRed; }
31 set { _BrightnessRed = value.Limit(0,255); }
34 private int _BrightnessGreen;
43 get {
return _BrightnessGreen; }
44 set { _BrightnessGreen = value.Limit(0, 255); }
47 private int _BrightnessBlue;
55 get {
return _BrightnessBlue; }
56 set { _BrightnessBlue = value.Limit(0, 255); }
64 public string HexColor
68 return "#{0:X2}{1:X2}{2:X2}".Build(Red, Blue, Green);
82 public bool SetColor(
int Red,
int Green,
int Blue)
96 public bool SetColor(
string Color)
98 if ((Color.Length == 6 && Color.IsHexString()) || (Color.Length == 7 && Color.StartsWith(
"#") && Color.IsHexString(1, 6)))
101 if (Color.StartsWith(
"#"))
109 SetColor(Color.Substring(0 + Offset, 2).HexToInt(), Color.Substring(2 + Offset, 2).HexToInt(), Color.Substring(4 + Offset, 2).HexToInt());
113 string[] SplitColors = Color.Split(
',');
114 if (SplitColors.Length == 3)
116 bool ColorsOK =
true;
117 foreach (
string C
in SplitColors)
126 SetColor(
int.Parse(SplitColors[0]),
int.Parse(SplitColors[1]),
int.Parse(SplitColors[2]));
145 public RGBColor(
int BrightnessRed,
int BrightnessGreen,
int BrightnessBlue){
146 SetColor(BrightnessRed, BrightnessGreen, BrightnessBlue);