// // 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; }
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; }
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); } }
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(); }
// // 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; }
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()); }
/// <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)); }