Exemple #1
0
 public ColorType(object color)
 {
     if (color is ColorType)
     {
         _Color = ((ColorType)color).Color;
     }
     else if (color is Int32)
     {
         _Color = Color.FromArgb(255, Color.FromArgb((int)color));
     }
     else if (color is Color)
     {
         _Color = (Color)color;
     }
     else
     {
         var colorName = Runtime.GetDesignatedString(color).LispToPascalCaseName();
         var member    = typeof(Color).GetRuntimeProperty(colorName);
         if (member == null)
         {
             Runtime.ThrowError("Invalid color name: ", color);
         }
         var color2 = (Color)member.GetValue(null);
         _Color = color2;
     }
 }
Exemple #2
0
        internal static int MakeTerminalAttribute(object value)
        {
            if (value is Int32)
            {
                var n = (int)value;
                return(n);
            }
            else
            {
                switch (Runtime.GetDesignatedString(value))
                {
                case "bold":
                {
                    return(TerminalAttribute.Bold);
                }

                case "italic":
                {
                    return(TerminalAttribute.Italic);
                }

                case "underline":
                {
                    return(TerminalAttribute.Underline);
                }

                case "strikeout":
                case "strike-out":
                {
                    return(TerminalAttribute.StrikeOut);
                }

                case "reverse":
                {
                    return(TerminalAttribute.Reverse);
                }

                default:
                {
                    return(TerminalAttribute.Normal);
                }
                }
            }
        }
Exemple #3
0
        public static Color MakeColor(object color)
        {
            Color _Color;

            if (Runtime.Integerp(color))
            {
                var number = Runtime.AsInt(color);
                _Color = Color.FromArgb(255, Color.FromArgb(number & 0xffffff));
            }
            else if (color is Color)
            {
                _Color = (Color)color;
            }
            else
            {
                var    colorName = Runtime.GetDesignatedString(color);
                object color2;

                if ((color2 = Runtime.GetStaticPropertyValue(typeof(Color), color)) != null)
                {
                    _Color = (Color)color2;
                }
                else if ((color2 = Runtime.GetStaticPropertyValue(typeof(SystemColors), color)) != null)
                {
                    _Color = (Color)color2;
                }
                else
                {
                    try
                    {
                        _Color = ColorTranslator.FromHtml(colorName);
                    }
                    catch
                    {
                        _Color = Color.Black;
                    }
                }
            }

            return(_Color);
        }