Esempio n. 1
0
 public static LColorList Get()
 {
     if (instance == null || instance.dirty)
     {
         lock (typeof(LColorList))
         {
             if (instance == null || instance.dirty)
             {
                 instance = new LColorList();
             }
         }
     }
     return(instance);
 }
Esempio n. 2
0
 public static void FreeStatic()
 {
     instance = null;
 }
Esempio n. 3
0
 /**
  * 转换字符串为color
  *
  * @param c
  */
 public LColor(string c)
 {
     if (c == null)
     {
         SetColor(LColor.white);
         return;
     }
     c = c.Trim().ToLower();
     // 识别字符串格式颜色
     if (c.StartsWith("#"))
     {
         SetColor(HexToColor(c));
     }
     else if (c.StartsWith("Rgb"))
     {
         int start = c.IndexOf('(');
         int end   = c.LastIndexOf(')');
         if (start != -1 && end != -1 && end > start)
         {
             string   result = c.Substring(start + 1, end).Trim();
             string[] list   = StringUtils.Split(result, ',');
             if (list.Length == 3)
             {
                 SetColor(ConvertInt(list[0].Trim()), ConvertInt(list[1].Trim()), ConvertInt(list[2].Trim()));
             }
             else if (list.Length == 4)
             {
                 SetColor(ConvertInt(list[0].Trim()), ConvertInt(list[1].Trim()), ConvertInt(list[2].Trim()),
                          ConvertInt(list[3].Trim()));
             }
         }
     }
     else if (c.StartsWith("Argb"))
     {
         int start = c.IndexOf('(');
         int end   = c.LastIndexOf(')');
         if (start != -1 && end != -1 && end > start)
         {
             string   result = c.Substring(start + 1, end).Trim();
             string[] list   = StringUtils.Split(result, ',');
             if (list.Length == 3)
             {
                 SetColor(ConvertInt(list[1].Trim()), ConvertInt(list[2].Trim()), ConvertInt(list[0].Trim()));
             }
             else if (list.Length == 4)
             {
                 SetColor(ConvertInt(list[1].Trim()), ConvertInt(list[2].Trim()), ConvertInt(list[3].Trim()),
                          ConvertInt(list[0].Trim()));
             }
         }
     }
     else if (c.StartsWith("transparent"))
     {
         SetColor(unchecked ((int)TRANSPARENT));
     }
     else if (MathUtils.IsNan(c))
     {
         SetColor(ConvertInt(c));
     }
     else if (StringUtils.IsHex(c))
     {
         SetColor(HexToColor(c));
     }
     else
     {
         LColor color = LColorList.Get().Find(c);
         if (color != null)
         {
             SetColor(color);
         }
         else
         {
             SetColor(HexToColor(c));
         }
     }
 }
Esempio n. 4
0
 public static string GetColorName(LColor color)
 {
     return(LColorList.Get().Find(color));
 }
Esempio n. 5
0
 public static string GetColorName(int pixel)
 {
     return(LColorList.Get().Find(pixel));
 }
Esempio n. 6
0
 public static LColor FindName(string colorName)
 {
     return(LColorList.Get().Find(colorName));
 }
Esempio n. 7
0
 public static bool PutName(string colorName, LColor color)
 {
     return(LColorList.Get().PutColor(colorName, color));
 }