}
get { return List2; }
}
- IList<Color> testList = Color.ColorDic.ToList();
+ IList<Color> testList = Color.ColorDic.Values.ToList();
public IList<Color> TestList {
set{
testList = value;
void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
- void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
+ void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.Values.ToList();
protected override void OnLoad (EventArgs e)
{
}
get { return List2; }
}
- IList<Color> testList = Color.ColorDic.ToList();
+ IList<Color> testList = Color.ColorDic.Values.ToList();
public IList<Color> TestList {
set{
testList = value;
void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
- void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
+ void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.Values.ToList();
}
G = _G;
B = _B;
Name = _name;
- ColorDic.Add(this);
+ ColorDic.Add(_name,this);
}
#endregion
- public static List<Color> ColorDic = new List<Color>();
+ public static Dictionary<string, Color> ColorDic = new Dictionary<string, Color>();
internal string Name;
if (c.Length == 1)
{
- foreach (Color cr in ColorDic)
- {
- if (string.Equals(cr.Name,s,StringComparison.Ordinal))
- return cr;
- }
+ if (ColorDic.ContainsKey (s))
+ return ColorDic[s];
+ throw new Exception ("Unknown color name: " + s);
}
return new Color(
double.Parse(c[0]),
{
if (!string.IsNullOrEmpty(Name))
return Name;
-
- foreach (Color cr in ColorDic)
- {
- if (cr == this)
- {
- Name = cr.Name;
- return cr.Name;
- }
- }
+ Color tc = this;
+ if (ColorDic.ContainsValue (this))
+ return ColorDic.FirstOrDefault (c => c.Value == tc).Key;
return string.Format("{0},{1},{2},{3}", R, G, B, A);
}