Beispiel #1
0
        public static Boolean TryParse(String scriptcolor, out SColor color)
        {
            Byte r, g, b;
            color = null;
            scriptcolor = scriptcolor.Trim();
            if (String.IsNullOrEmpty(scriptcolor))
                return false;

            switch (scriptcolor.Length) {
                case 9:
                case 8:
                    if (!byte.TryParse(scriptcolor.Substring(2, 2), NumberStyles.HexNumber, null, out b) ||
                        !byte.TryParse(scriptcolor.Substring(4, 2), NumberStyles.HexNumber, null, out g) ||
                        !byte.TryParse(scriptcolor.Substring(6, 2), NumberStyles.HexNumber, null, out r)) return false;
                    color = new SColor(r, g, b);
                    return true;
                case 10:
                    Byte a;
                    if (!byte.TryParse(scriptcolor.Substring(2, 2), NumberStyles.HexNumber, null, out a) ||
                        !byte.TryParse(scriptcolor.Substring(4, 2), NumberStyles.HexNumber, null, out b) ||
                        !byte.TryParse(scriptcolor.Substring(6, 2), NumberStyles.HexNumber, null, out g) ||
                        !byte.TryParse(scriptcolor.Substring(8, 2), NumberStyles.HexNumber, null, out r)) return false;
                    color = new SColor(r, g, b, a);
                    return true;
            }
            return false;
        }
Beispiel #2
0
 public Colors(SColor primary, SColor secondary, SColor outline, SColor back)
 {
     pc = primary;
     sc = secondary;
     oc = outline;
     bc = back;
 }