2 using DirectOutput.Cab.Toys.Layer;
3 using DirectOutput.General.Color;
6 namespace DirectOutput.LedControl.Loader
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; }
75 public void ParseLedcontrolData(
string ColorConfigDataLine,
bool ThrowExceptions =
false)
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);