예제 #1
0
        //
        // OnMouseMove event handler
        //
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // Keep track of the current mouse position so we can invalidate the region
            _mouseCellX = Math.Max(0, Math.Min(_cellsPerRow - 1, e.X / _cellWidth));
            _mouseCellY = Math.Max(0, Math.Min((int)Math.Ceiling(_colorSwatch.ColorCount / (float)(_cellsPerRow)) - 1, e.Y / _cellHeight));

            // Invalidate the mouse region
            Rectangle newCellRect = GetMouseCellArea();

            if (newCellRect != _lastMouseCellArea)
            {
                Rectangle oldRec = _lastMouseCellArea;
                Rectangle newRec = newCellRect;

                oldRec.Inflate(2, 2);
                newRec.Inflate(2, 2);

                Invalidate(oldRec);
                Invalidate(newRec);

                if (_mouseDown && _mouseOver)
                {
                    // Gets the color the user clicked on
                    ColorSelect?.Invoke(this, new ColorSelectEventArgs(GetColorUnderMouse()));
                }
            }

            _lastMouseCellArea = newCellRect;
        }
예제 #2
0
        private void SVPanel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B));
            ColorSelect.Invoke(Color.FromArgb(A, R, G, B), e);


            SVPanelDrag = false;
        }
예제 #3
0
 private void UserControl_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (SVPanelDrag | HueBarDrag)
     {
         SVPanelDrag          = false;
         HueBarDrag           = false;
         LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B));
         ColorSelect.Invoke(Color.FromArgb(A, R, G, B), e);
     }
 }
예제 #4
0
        private void ColorPanel1_ColorSelect(object sender, EventArgs e)
        {
            var color = (sender as ColorPanel.ColorChunk).Color;

            controller.ToolSelection = new PenSelection(color.ToArgb());
            ColorSelect.Invoke(sender, e);

            Close();
            Dispose();
        }
예제 #5
0
        //
        // OnMouseDown event handler
        //
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // Gets the color the user clicked on
            ColorSelect?.Invoke(this, new ColorSelectEventArgs(GetColorUnderMouse()));

            _mouseDown = true;
        }
예제 #6
0
        private void ColorRGBRefresh()
        {
            Color MainColor = Color.FromRgb(R, G, B);

            ColorToHSV(MainColor, ref Saturation, ref Value);
            // ColorHSVRefresh()
            double RealWidth  = SVPanel.ActualWidth;
            double RealHeight = SVPanel.ActualHeight;

            PickerStylus.Margin = new Thickness(Saturation * RealWidth - 7, (1 - Value) * RealHeight - 7, 0, 0);

            CurrentColor.Background = new SolidColorBrush(MainColor);

            LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B));
            ColorSelect.Invoke(Color.FromArgb(A, R, G, B), new RoutedEventArgs());
        }
예제 #7
0
 /// <summary>
 /// Fires the color change event with the given color
 /// </summary>
 /// <param name="color">The color to fire the event with</param>
 /// <param name="colorIndex">Which color index to fire the event fore. Defaults to the current color</param>
 public void FireColorChangeEvent(Color color, ColorPickerColor colorIndex = ColorPickerColor.CurrentColor)
 {
     ColorSelect?.Invoke(this, new ColorPickEventArgs(color, color, colorIndex));
 }