Ejemplo n.º 1
0
        private void ColorMapControl_MouseUp(object sender, MouseEventArgs e)
        {
            _leftMouseDown = false;

            if (_colormap == null)
            {
                return;
            }

            // check if we have a click event
            if (Math.Abs(_mouseDownPosition.X - e.X) <= 2 && Math.Abs(_mouseDownPosition.Y - e.Y) <= 2)
            {
                int index = WorldToIndex(e.X);

                if (e.Button == MouseButtons.Left)
                {
                    if (ClientSize.Width - e.X < 8)
                    {
                        index = _colormap.Count;
                    }
                    ColorDialog cd = new ColorDialog();
                    cd.FullOpen = true;
                    cd.AnyColor = true;
                    if (cd.ShowDialog() == DialogResult.OK)
                    {
                        _colormap.AddColorAt(cd.Color, index);
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (_colormap.Count > 1)
                    {
                        _colormap.RemoveColorAt(index);
                    }
                }
            }
            else if (_draggingColor)
            {
                _draggingColor = false;
                colormap       = _tempMap;
            }
        }