private void UnMangleStylusUp(PointerPoint point, CanvasControl canvas) { if (this.currentButton.HasValue) { InkButton?.Invoke(this, new InkButtonEventArgs(currentButton.Value, ButtonStatus.Up, point, this.canvas)); this.currentButton = null; } else { InkButton?.Invoke(this, new InkButtonEventArgs(ButtonType.InContact, ButtonStatus.Up, point, this.canvas)); } if (stylusRangeStatus == StylusRangeStatus.FakingInRange) { stylusRangeStatus = StylusRangeStatus.OutOfRange; InkButton.Invoke(this, new InkButtonEventArgs(ButtonType.InRange, ButtonStatus.Up, point, this.canvas)); } }
protected override void OnPointerExited(PointerRoutedEventArgs e) { Pointer pointer = e.Pointer; if (!weCareAbout(pointer)) return; PointerPoint point = e.GetCurrentPoint(this.canvas); e.Handled = true; InkButton?.Invoke(this, new InkButtonEventArgs(ButtonType.InRange, ButtonStatus.Up, point, this.canvas)); stylusRangeStatus = StylusRangeStatus.OutOfRange; }
private void UnMangleStylusDown(PointerPoint point, CanvasControl canvas) { ButtonType? extraButton = null; if (point.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) { if (point.Properties.IsEraser) { extraButton = ButtonType.Eraser; } else if (point.Properties.IsBarrelButtonPressed) { extraButton = ButtonType.Button2; } } else if (point.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse) { if (point.Properties.IsRightButtonPressed) { extraButton = ButtonType.Button2; } else if (point.Properties.IsMiddleButtonPressed) { extraButton = ButtonType.Eraser; } } this.currentButton = extraButton; // on the PC we are drawing to, In Range events (BTN_TOOL_PEN) need to be received for Touch events (BTN_TOUCH) to be taken notice of. if (stylusRangeStatus != StylusRangeStatus.InRange) { stylusRangeStatus = StylusRangeStatus.FakingInRange; InkButton.Invoke(this, new InkButtonEventArgs(ButtonType.InRange, ButtonStatus.Down, point, this.canvas)); } if (extraButton.HasValue) { InkButton?.Invoke(this, new InkButtonEventArgs(extraButton.Value, ButtonStatus.Down, point, this.canvas)); } else { InkButton?.Invoke(this, new InkButtonEventArgs(ButtonType.InContact, ButtonStatus.Down, point, this.canvas)); } }
public DrawCanvas() { this.InitializeComponent(); points = new Queue<DrawnPoint>(); settings = WinNetStyApp.Current.Settings; redrawTimer = new DispatcherTimer(); redrawTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000/60); redrawTimer.Tick += RedrawScreen; drawing = false; currentButton = null; stylusRangeStatus = StylusRangeStatus.OutOfRange; }