예제 #1
0
        void click_context_relabel(object sender, EventArgs e)
        {
            Swatch swatch = _tiles[_sel];

            using (var f = new SwatchDialog(swatch))
            {
                if (f.ShowDialog(this) == DialogResult.OK &&
                    f.Description != swatch.Description)
                {
                    swatch.Description = f.Description;
                    _tiles[_sel]       = swatch;               // effin structs

                    SwatchIo.Write(_tiles);
                }
            }
        }
예제 #2
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]);
            }
        }
예제 #3
0
        void click_context_delete(object sender, EventArgs e)
        {
            using (Graphics graphics = Graphics.FromImage(_graphic))
            {
                --_firstBlankId;

                Swatch swatch, swatch1;
                int    id = _sel; _sel = -1;

                for (; id != MaxTiles; ++id)
                {
                    swatch = _tiles[id];

                    if (id + 1 != MaxTiles)
                    {
                        swatch1 = _tiles[id + 1];

                        swatch.Color       = swatch1.Color;
                        swatch.Description = swatch1.Description;
                    }
                    else
                    {
                        swatch.Color       = Color.Empty;
                        swatch.Description = Swatch.NoLabel;
                    }
                    _tiles[id] = swatch;                     // effin structs

                    DrawSwatch(graphics, swatch);
                    InvalidateSwatch(swatch);

                    if (swatch.Color == Color.Empty)
                    {
                        break;
                    }
                }
            }
            SwatchIo.Write(_tiles);
        }