29 public string Name {
get; set; }
37 public int Red {
get; set; }
44 public int Green {
get; set; }
51 public int Blue {
get; set; }
65 get {
return _Alpha; }
66 set { _Alpha = value; }
80 string[] NameValues = ColorConfigDataLine.Split(
new string[] {
"=" }, StringSplitOptions.RemoveEmptyEntries);
81 if (NameValues.Length == 2)
83 string[] Values = NameValues[1].Split(
new string[] {
"," }, StringSplitOptions.RemoveEmptyEntries);
84 if (Values.Length == 3 && Values[0].IsInteger() && Values[1].IsInteger() && Values[2].IsInteger())
87 Red = (int)(Values[0].ToInteger().Limit(0, 48) * 5.3125);
88 Green = (int)(Values[1].ToInteger().Limit(0, 48) * 5.3125);
89 Blue = (int)(Values[2].ToInteger().Limit(0, 48) * 5.3125);
90 Alpha = (Red + Green + Blue == 0 ? 0 : 255);
93 else if (Values.Length == 4 && Values[0].IsInteger() && Values[1].IsInteger() && Values[2].IsInteger() && Values[3].IsInteger())
96 Red = (int)(Values[0].ToInteger().Limit(0, 48)* 5.3125);
97 Green = (int)(Values[1].ToInteger().Limit(0, 48)* 5.3125);
98 Blue = (int)(Values[2].ToInteger().Limit(0, 48)* 5.3125);
99 Alpha = (int)(Values[2].ToInteger().Limit(0, 48) * 5.3125);
103 else if (NameValues[1].StartsWith(
"#") && (NameValues[1].Length==7 || NameValues[1].Length==9) && NameValues[1].Substring(1).IsHexString())
107 Name = NameValues[0];
118 Log.
Warning(
"Line {0} has a unknown structure or contains wrong data.".Build(ColorConfigDataLine));
121 throw new Exception(
"Line {0} has a unknown structure or contains wrong data.".Build(ColorConfigDataLine));
139 public ColorConfig(
string ColorConfigDataLine,
bool ThrowExceptions =
false)
141 ParseLedcontrolData(ColorConfigDataLine, ThrowExceptions);
This class stores information on colors used for toys and effects (e.g. RGBLed).
The namespace DirectOutput.Cab.Toys contains all toy related classes.
static void Warning(string Message)
Writes a warning message to the log.
A simple logger used to record important events and exceptions.
int Red
Brightness for Red.
RGBAColorNamed GetCabinetColor()
Gets a cabinet RGBAColor object representing the values in the ColorConfig object-.
int Green
Brightness for Green.
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
ColorConfig()
Initializes a new instance of the ColorConfig class.
Color configuration from a LedControl file.
int Blue
Brightness for Blue.
int Alpha
Alpha value for the color.
ColorConfig(string ColorConfigDataLine, bool ThrowExceptions=false)
Initializes a new instance of the ColorConfig class. Parses the ledcontrol data for a color definitio...
bool SetColor(int Red, int Green, int Blue, int Alpha)
Sets the RGBA components of the Color.
Namespace for objects dealing with layers
void ParseLedcontrolData(string ColorConfigDataLine, bool ThrowExceptions=false)
Parses the ledcontrol data for a color definition.
The namespace DirectOutput.General contains classes for general use.
This class stores information on colors used for toys (e.g. RGBLed).