protected override void OnPointerPressed(PointerRoutedEventArgs e) { var pt = new UniPoint(e.GetCurrentPoint(this).Position.X, e.GetCurrentPoint(this).Position.Y); selCoord = pt; pt.X -= ((Width - cpRender.Bounds.Width) / 2); pt.Y -= ((Height - cpRender.Bounds.Height) / 2); if (!cpRender.Bounds.Contains((System.Drawing.PointF)pt)) { selCoord = null; return; } var c = cpRender.HitTest((int)pt.X, (int)pt.Y); if (c == System.Drawing.Color.Empty) { selCoord = null; return; } SetSelectedColor(c); CapturePointer(e.Pointer); colorDragging = true; ColorHit?.Invoke(this, new ColorHitEventArgs(c)); }
private void PickerSite_MouseMove(object sender, MouseEventArgs e) { var pt = e.GetPosition(PickerSite); var c = cpRender.HitTest((int)pt.X, (int)pt.Y); if (c == System.Drawing.Color.Empty && e.LeftButton != MouseButtonState.Pressed) { Cursor = Cursors.Arrow; } else { Cursor = Cursors.Cross; } if (dragPick) { var ev = new ColorHitEventArgs(c); ColorOver?.Invoke(this, ev); if (e.LeftButton == MouseButtonState.Pressed) { SetSelectedColor(c); ColorHit?.Invoke(this, ev); } } }
void OnTouch(object sender, TouchActionEventArgs args) { if (args.Type == TouchActionType.Pressed || args.Type == TouchActionType.Moved) { var pt = new UniPoint(args.Location.X, args.Location.Y); selCoord = pt; pt.X -= (Width - cpRender.Bounds.Width) / 2; pt.Y -= (Height - cpRender.Bounds.Height) / 2; if (!cpRender.Bounds.Contains((System.Drawing.PointF)pt)) { selCoord = null; Canvas.InvalidateSurface(); return; } var c = cpRender.HitTest((int)pt.X, (int)pt.Y); if (c == System.Drawing.Color.Empty) { selCoord = null; Canvas.InvalidateSurface(); return; } Canvas.InvalidateSurface(); SetSelectedColor(c); ColorHit?.Invoke(this, new ColorHitEventArgs(c)); } else if (args.Type == TouchActionType.Moved) { var pt = new UniPoint(args.Location.X, args.Location.Y); pt.X -= (Width - cpRender.Bounds.Width) / 2; pt.Y -= (Height - cpRender.Bounds.Height) / 2; if (!cpRender.Bounds.Contains((System.Drawing.PointF)pt)) { return; } var c = cpRender.HitTest((int)pt.X, (int)pt.Y); if (c == System.Drawing.Color.Empty) { return; } ColorOver?.Invoke(this, new ColorHitEventArgs(c)); } }
private void PickerSite_MouseDown(object sender, MouseButtonEventArgs e) { if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) { if (Keyboard.Modifiers == ModifierKeys.Control) { SelectedColor = null; SetSelectedColor(null); dragPick = false; return; } var pt = e.GetPosition(PickerSite); var c = cpRender.HitTest((int)pt.X, (int)pt.Y); SetSelectedColor(c); ColorHit?.Invoke(this, new ColorHitEventArgs(c)); dragPick = true; } }