public static List <ColorTagged> Load(string filePath) { if (!File.Exists(filePath)) { return(null); } List <ColorTagged> colorTaggeds = new List <ColorTagged>(); XmlDocument xml = new XmlDocument(); xml.Load(filePath); XmlNode node = xml.LastChild; XmlNodeList nodes = node.ChildNodes; for (int i = 0; i < nodes.Count; i++) { XmlNodeList n = nodes[i].ChildNodes; int tag = Int32.Parse(n[0].InnerText); string name = n[1].InnerText; string value = n[2].InnerText; ColorTagged c = new ColorTagged(tag); c.Name = name; c.Hex = value; colorTaggeds.Add(c); } return(colorTaggeds); }
public bool Equals(ColorTagged color) { if (color == null) { return(false); } return(color.RGB.Equals(RGB)); }
public void Add(ColorTagged colorTagged) { if (!this.Contains(colorTagged)) { this.internalList.Add(colorTagged); colorTagged.TextBrush = GetColorDistance(Color.White, colorTagged.RGB) > 300 ? WhiteBrush : BlackBrush; tag = GetLastTag(); } }
public int CompareTo(object obj) { ColorTagged c = obj as ColorTagged; if (c == null) { return(-1); } else { return(this.Tag.CompareTo(c.Tag)); } }
private void ColorList_ColorTagChangeEvent(ColorTagged obj) { Swatche temp = null; for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++) { temp = flowLayoutPanel1.Controls[i] as Swatche; if (temp.ColorTag.Equals(obj)) { temp.ChangeTag(obj.Tag); flowLayoutPanel1.Controls.SetChildIndex(temp, obj.Tag); } } }
public void Add(Color color, string name) { int index = containsColor(color); if (index > -1) { this.internalList[index].Name = name; } else { ColorTagged t = new ColorTagged(tag); t.RGB = color; t.TextBrush = GetColorDistance(Color.White, t.RGB) > 300 ? WhiteBrush : BlackBrush; t.Name = name; this.internalList.Add(t); this.tag = GetLastTag(); } }
//public void Add(ColorTagged color) //{ // this.internalList.Add(color); //} public void Add(int colorTableIndex, int colorCount = -1) { //int index = containsColor(colorTable[colorTableIndex]); //if (index == -1) //{ ColorTagged t = null; //= new ColorTagged(colorTableIndex, tag); //t.RGB = this.colorTable[colorTableIndex]; //t.Brush = GetColorDistance(Color.White, t.RGB) > 300 ? WhiteBrush : BlackBrush; Color color = colorTable[colorTableIndex]; int index = containsColor(color); if (index > -1) { t = this.internalList[index]; if (!t.ColorTableIndex.Contains(colorTableIndex)) { t.ColorTableIndex.Add(colorTableIndex); } if (colorCount > -1) { t.ColorCount = colorCount; } } else { t = new ColorTagged(this.tag); t.ColorTableIndex.Add(colorTableIndex); t.RGB = this.colorTable[colorTableIndex]; t.TextBrush = GetColorDistance(Color.White, t.RGB) > 300 ? WhiteBrush : BlackBrush; if (colorCount > -1) { t.ColorCount = colorCount; } else { t.ColorCount = 1; } this.internalList.Add(t); this.tag = GetLastTag(); } //} }
public void SetNewColorTag(ColorTagged colorTagged, int newTag) { if (colorTagged.Tag == newTag) { return; } ColorTagged color = null; try { color = this.internalList.Single(c => c.Tag == newTag); } catch { } colorTagged.SetNewTag = newTag; if (color != null) { color.SetNewTag = colorTagged.OldTag; } this.internalList.Sort(); ColorTagChangeEvent?.Invoke(color); }
public bool Contains(ColorTagged color) { return(this.internalList.Contains(color)); }
public Swatche(ColorTagged colorTagged) { InitializeComponent(); this.colorTagged = colorTagged; this.Load += Swatche_Load; }