コード例 #1
0
ファイル: KalkColorRgb.cs プロジェクト: xoofx/kalk
 public static bool TryGetKnownColor(string color, out int rgb)
 {
     if (color == null)
     {
         throw new ArgumentNullException(nameof(color));
     }
     return(KnownColors.TryGetValue(color, out rgb));
 }
コード例 #2
0
        public static Color?AsColor(this string?attr)
        {
            if (string.IsNullOrEmpty(attr))
            {
                return(null);
            }

            var name = attr;

            if (KnownColors.TryGetValue(name, out var c))
            {
                return(c);
            }

            try
            {
                return(ParseFromString(name));
            }
            catch (Exception)
            {
                return(null);
            }
        }