Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            Random rand = new Random();

            for (int i = 0; i < 6; i++)
            {
                var btn = new Button();
                btn.Name = "Color" + (i + 1);
                btn.Text = btn.Name;

                btn.Click += new System.EventHandler(this.button1_Click);
                btn.Size   = new Size(100, 25);
                Controls.Add(btn);
                btn.Location  = new System.Drawing.Point(750, 10 + 30 * i);
                btn.BackColor = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));
                buttons.Add(btn);

                var d = new ColorDefinition();

                d = SetFromColor(d, btn.BackColor, true);

                colorDefs.Add(d);
            }
        }
Ejemplo n.º 2
0
        public ColorDefinition SetFromHex(ColorDefinition d, string hex, bool isNew)
        {
            if (isNew)
            {
                d.RgbNew = RGBConverter(hex);
                d.HexNew = hex;
            }
            else
            {
                d.RgbOld = RGBConverter(hex);
                d.HexOld = hex;
            }

            return(d);
        }
Ejemplo n.º 3
0
        public ColorDefinition SetFromColor(ColorDefinition d, Color c, bool isNew)
        {
            if (isNew)
            {
                d.RgbNew = c.R + "," + c.G + "," + c.B;
                d.HexNew = HexConverter(c);
            }
            else
            {
                d.RgbOld = c.R + "," + c.G + "," + c.B;
                d.HexOld = HexConverter(c);
            }

            return(d);
        }
Ejemplo n.º 4
0
        public ColorDefinition SetFromRgb(ColorDefinition d, string rgb, bool isNew)
        {
            if (isNew)
            {
                d.RgbNew = rgb;
                d.HexNew = HexConverter(rgb);
            }
            else
            {
                d.RgbOld = rgb;
                d.HexOld = HexConverter(rgb);
            }

            return(d);
        }