Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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]);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public SwatchControl()
        {
            InitializeComponent();

            if (!ColorF.reallyDesignMode)
            {
                SwatchIo.Fullpath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);                 // local userdir
                SwatchIo.Fullpath = Path.Combine(SwatchIo.Fullpath, SwatchIo.SwatchFile);

//				if (!File.Exists(SwatchIo.Fullpath))
//				{
//					SwatchIo.Fullpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); // roaming userdir
//					SwatchIo.Fullpath = Path.Combine(SwatchIo.Fullpath, SwatchIo.SwatchFile);
//				}

                if (!File.Exists(SwatchIo.Fullpath))
                {
                    SwatchIo.Create();
                }

                if (!SwatchIo._errored && File.Exists(SwatchIo.Fullpath))
                {
                    _fileSwatches = SwatchIo.Read(SwatchIo.Fullpath);

                    if (_fileSwatches.Count < MaxTiles)
                    {
                        _firstBlankId = _fileSwatches.Count;
                    }
                    else
                    {
                        _firstBlankId = MaxTiles;
                    }

                    CreateGraphic();
                }
            }
        }