Beispiel #1
0
        void click_context_append(object sender, EventArgs e)
        {
            ClearSelector();

            Color color = ColorF.That.ColorControl.GetActiveColorbox().BackColor;

            int id = ColorExists(color);

            if (id == _firstBlankId)
            {
                using (var f = new SwatchDialog(color))
                {
                    if (f.ShowDialog(this) == DialogResult.OK)
                    {
                        ++_firstBlankId;

                        Swatch swatch = _tiles[id];

                        using (Graphics graphics = Graphics.FromImage(_graphic))
                        {
                            using (var brush = new SolidBrush(color))
                                graphics.FillRectangle(brush, swatch.Rect);

                            graphics.DrawRectangle(Pens.Black, swatch.Rect);
                        }

                        swatch.Color       = color;
                        swatch.Description = f.Description;
                        _tiles[id]         = swatch;

                        InvalidateSwatch(_tiles[_sel = id]);

                        SwatchIo.Write(_tiles);
                    }
                }
            }
            else
            {
                InvalidateSwatch(_tiles[_sel = id]);
            }
        }