2 using DirectOutput.Cab.Toys.Layer;
3 using DirectOutput.Cab.Color;
6 namespace DirectOutput.LedControl.Loader
20 return new RGBAColorNamed(Name,(
int)(Red * 5.3125), (
int)(Green * 5.3125), (
int)(Blue * 5.3125), (
int)(Alpha * 5.3125));
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 = Values[0].ToInteger();
88 Green = Values[1].ToInteger();
89 Blue = Values[2].ToInteger();
90 Alpha = (Red + Green + Blue == 0 ? 0 : 48);
93 else if (Values.Length == 4 && Values[0].IsInteger() && Values[1].IsInteger() && Values[2].IsInteger() && Values[3].IsInteger())
96 Red = Values[0].ToInteger();
97 Green = Values[1].ToInteger();
98 Blue = Values[2].ToInteger();
99 Alpha = Values[2].ToInteger();
104 Log.
Warning(
"Line {0} has a unknown structure or contains wrong data.".Build(ColorConfigDataLine));
107 throw new Exception(
"Line {0} has a unknown structure or contains wrong data.".Build(ColorConfigDataLine));
125 public ColorConfig(
string ColorConfigDataLine,
bool ThrowExceptions =
false)
127 ParseLedcontrolData(ColorConfigDataLine, ThrowExceptions);