Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public bool Equals(ColorTagged color)
 {
     if (color == null)
     {
         return(false);
     }
     return(color.RGB.Equals(RGB));
 }
Esempio n. 3
0
 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();
     }
 }
Esempio n. 4
0
        public int CompareTo(object obj)
        {
            ColorTagged c = obj as ColorTagged;

            if (c == null)
            {
                return(-1);
            }
            else
            {
                return(this.Tag.CompareTo(c.Tag));
            }
        }
Esempio n. 5
0
        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);
                }
            }
        }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        //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();
            }

            //}
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 public bool Contains(ColorTagged color)
 {
     return(this.internalList.Contains(color));
 }
Esempio n. 10
0
 public Swatche(ColorTagged colorTagged)
 {
     InitializeComponent();
     this.colorTagged = colorTagged;
     this.Load       += Swatche_Load;
 }