private void OnPointerReleased(object sender, PointerRoutedEventArgs pointerRoutedEventArgs) { // Get the primary touch point. We do not track multitouch at the moment. var primaryTouchPoint = pointerRoutedEventArgs.GetCurrentPoint(Windows.UI.Xaml.Window.Current.Content); var uiElements = VisualTreeHelper.FindElementsInHostCoordinates(primaryTouchPoint.Position, Windows.UI.Xaml.Window.Current.Content); foreach (var uiElement in uiElements) { // Are we interested? var renderer = uiElement as NControlViewRenderer; if (renderer == null) { continue; } // Get NControlView element var element = renderer.Element; // Get this' position on screen var transform = Windows.UI.Xaml.Window.Current.Content.TransformToVisual(renderer.Control); // Transform touches var touchPoints = pointerRoutedEventArgs.GetIntermediatePoints(Windows.UI.Xaml.Window.Current.Content); var touches = touchPoints .Select(t => transform.TransformPoint(new Windows.Foundation.Point(t.Position.X, t.Position.Y))) .Select(t => new NGraphics.Point(t.X, t.Y)).ToList(); if (element.TouchesEnded(touches)) { break; } } }
protected override void OnPointerMoved(PointerRoutedEventArgs args) { // Get ID from event arguments uint id = args.Pointer.PointerId; // If ID is in dictionary, start a loop if (pointerDictionary.ContainsKey(id)) { PointerInfo pointerInfo = pointerDictionary[id]; foreach (PointerPoint pointerPoint in args.GetIntermediatePoints(this).Reverse()) { // For each point, get new position and pressure Point point = pointerPoint.Position; double radius = appSettings.Thickness * pointerPoint.Properties.Pressure; // Render and flag that it's modified appSettings.IsImageModified = RenderOnBitmap(pointerInfo.PreviousPoint, pointerInfo.PreviousRadius, point, radius, appSettings.Color); // Update PointerInfo pointerInfo.PreviousPoint = point; pointerInfo.PreviousRadius = radius; } // Store PointerInfo back in dictionary pointerDictionary[id] = pointerInfo; } base.OnPointerMoved(args); }
/// <summary> /// The slider's pointer moved event handler /// </summary> /// <param name="sender">the sender object</param> /// <param name="e">Pointer move even args</param> private void Slider_PointerMoved(object sender, PointerRoutedEventArgs e) { //Feed the intermediate move points to the gesture recognizer m_sliderGestureRecognizer.ProcessMoveEvents(e.GetIntermediatePoints(this.Slider)); //Mark event as handled e.Handled = true; }
/// <summary> /// The pointer moved event handler /// </summary> /// <param name="sender">the sender object</param> /// <param name="e">The pointer moved event args</param> private void inkCanvas_PointerMoved(object sender, PointerRoutedEventArgs e) { //Break if the event's pointer is not the currently active pointer if (m_activePointerId != e.Pointer.PointerId) { return; } //We only handle pen input here so we check the device type if (e.Pointer.PointerDeviceType == PointerDeviceType.Pen || e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) { //Check if the pen has contact or is just hovering if (e.Pointer.IsInContact) { //Get a pointer point relative to the inkCanvas PointerPoint pointerPoint = e.GetCurrentPoint(this.inkCanvas); //Update the live stroek using the pointerPoints's position m_renderer.UpdateStroek(pointerPoint); //Get all of the event's intermediate points IList <PointerPoint> interPointerPoints = e.GetIntermediatePoints(this.inkCanvas); //Use the InkManager to process all of the pointer updates for (int i = interPointerPoints.Count - 1; i >= 0; --i) { m_inkMan.ProcessPointerUpdate(interPointerPoints[i]); } //Mark the event as handled e.Handled = true; } else // If the pen has no contact chances are it was lifted off while not in the controls aera { //Use a private helper method to finalize pen input HandlePenUp(e); } } }
private void Grid_PointerPressed(object sender, PointerRoutedEventArgs e) { if (e.Handled) { return; } if (IsEnabled == false) { return; } e.Handled = true; _isPointerCaptured = IconContainer.CapturePointer(e.Pointer); if (_isPointerCaptured == false) { return; } Focus(FocusState.Pointer); var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { gestureRecognizer.ProcessDownEvent(ps[0]); e.Handled = true; } }
protected override void OnPointerReleased(PointerRoutedEventArgs e) { base.OnPointerReleased(e); if (e.Handled) { return; } if (IsEnabled == false) { return; } e.Handled = true; IsPressed = false; ReleasePointerCapture(e.Pointer); _isPointerCaptured = false; UpdateVisualStates(); var points = e.GetIntermediatePoints(null); if (points != null && points.Count > 0) { _gestureRecognizer.ProcessUpEvent(points[0]); e.Handled = true; _gestureRecognizer.CompleteGesture(); } }
protected override void OnPointerPressed(PointerRoutedEventArgs e) { base.OnPointerPressed(e); if (e.Handled) { return; } if (IsEnabled == false) { return; } e.Handled = true; _isPointerCaptured = CapturePointer(e.Pointer); if (_isPointerCaptured == false) { return; } IsPressed = true; Focus(FocusState.Pointer); UpdateVisualStates(); var points = e.GetIntermediatePoints(null); if (points != null && points.Count > 0) { _gestureRecognizer.ProcessDownEvent(points[0]); e.Handled = true; } }
private void OnPointerMoved(object sender, PointerRoutedEventArgs e) { lock (touchPointsRenderer) { touchPointsRenderer.OnPointerMoved(e.GetIntermediatePoints(animatedControl)); } animatedControl.Invalidate(); }
private void PointerMoved(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerDeviceType == PointerDeviceType.Pen && e.Pointer.IsInContact) { //Debug.WriteLine("Moved"); PointerPoint pointerPoint = e.GetCurrentPoint(root); uint id = pointerPoint.PointerId; //Debug.WriteLine(id) ; if (pointerDictionary.ContainsKey(id)) { foreach (PointerPoint point in Enumerable.Reverse(e.GetIntermediatePoints(root)) /*.Reverse()*/) { // Give PointerPoint to InkManager object obj = inkManager.ProcessPointerUpdate(point); // Render the line if (inkManager.Mode == InkManipulationMode.Erasing) { Rect rect = (Rect)obj; if (rect.Width != 0 && rect.Height != 0) { RenderAllStrokes(); } } else { Point point1 = pointerDictionary[id]; Point point2 = pointerPoint.Position; Line line = new Line { X1 = point1.X, Y1 = point1.Y, X2 = point2.X, Y2 = point2.Y, Stroke = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0)), StrokeThickness = inkDrawingAttributes.Size.Width,// * pointerPoint.Properties.Pressure, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round }; boundingRect.Union(point2); NewStrokeGrid.Children.Add(line); pointerDictionary[id] = point2; } } if (StrokeAdding != null) { StrokeAdding(boundingRect); } } e.Handled = true; } }
private void OnPointerMoved(object sender, PointerRoutedEventArgs e) { if (!IsEnabled) { return; } _recogniser.ProcessMoveEvents(e.GetIntermediatePoints(_reference)); }
protected override void OnPointerMoved(PointerRoutedEventArgs args) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(sheetPanel); uint id = pointerPoint.PointerId; InkManager inkManager = this.InkFileManager.InkManager; InkDrawingAttributes inkDrawingAttributes = this.InkFileManager.InkDrawingAttributes; if (pointerDictionary.ContainsKey(id)) { foreach (PointerPoint point in args.GetIntermediatePoints(sheetPanel).Reverse()) { Point point1 = pointerDictionary[id]; Point point2 = pointerPoint.Position; // Give PointerPoint to InkManager object obj = inkManager.ProcessPointerUpdate(point); if (inkManager.Mode == InkManipulationMode.Erasing) { // See if something has actually been removed Rect rect = (Rect)obj; if (rect.Width != 0 && rect.Height != 0) { this.InkFileManager.RenderAll(); } } else if (inkManager.Mode == InkManipulationMode.Selecting) { Polyline polyline = newLineGrid.Children[0] as Polyline; polyline.Points.Add(point2); } else // inkManager.Mode == InkManipulationMode.Inking { // Render the line Line line = new Line { X1 = point1.X, Y1 = point1.Y, X2 = point2.X, Y2 = point2.Y, Stroke = new SolidColorBrush(inkDrawingAttributes.Color), StrokeThickness = inkDrawingAttributes.Size.Width * pointerPoint.Properties.Pressure, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round }; newLineGrid.Children.Add(line); } pointerDictionary[id] = point2; } } base.OnPointerMoved(args); }
void MainPage_PointerPressed(object sender, PointerRoutedEventArgs e) { var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { gr.ProcessDownEvent(ps[0]); e.Handled = true; } }
private void Grid_PointerPressed(object sender, PointerRoutedEventArgs e) { var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { gestureRecognizer.ProcessDownEvent(ps[0]); e.Handled = true; } }
void OnPointerPressed(object sender, PointerRoutedEventArgs e) { var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { _holdObj = sender; gestRec.ProcessDownEvent(ps[0]); e.Handled = true; } }
void MainPage_PointerReleased(object sender, PointerRoutedEventArgs e) { var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { gr.ProcessUpEvent(ps[0]); e.Handled = true; gr.CompleteGesture(); } }
private void OnWebViewPointerWheelChanged(object sender, PointerRoutedEventArgs e) { if (sender is UIElement webContent) { e.GetIntermediatePoints(webContent); if (!e.GetCurrentPoint(this).Properties.IsHorizontalMouseWheel) { var verticalOffset = RootScrollViewer.VerticalOffset - e.GetCurrentPoint(webContent).Properties.MouseWheelDelta; RootScrollViewer.ChangeView(RootScrollViewer.HorizontalOffset, verticalOffset, RootScrollViewer.ZoomFactor); } } }
static void page_PointerMoved(object sender, PointerRoutedEventArgs e) { _gr.ProcessMoveEvents(e.GetIntermediatePoints(null)); e.Handled = true; if (OnGestureRaised != null) { OnGestureRaised(sender, new CustomGestureArgs() { MovedPointerRoutedEventArgs = e }); } }
void OnPointerReleased(object sender, PointerRoutedEventArgs e) { var ps = e.GetIntermediatePoints(null); if (ps != null && ps.Count > 0) { gestRec.ProcessUpEvent(ps[0]); e.Handled = true; gestRec.CompleteGesture(); _holdObj = null; } }
/// <summary> /// Called when pointer moves. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="Windows.UI.Xaml.Input.PointerRoutedEventArgs" /> instance containing the event data.</param> private void OnPointerMoved(object sender, PointerRoutedEventArgs args) { try { this.gestureRecognizer.ProcessMoveEvents(args.GetIntermediatePoints(this.scatterView)); } catch (Exception) { //see https://connect.microsoft.com/VisualStudio/feedback/details/895979/exceptions-thrown-by-gesturerecognizer } args.Handled = true; }
private void OnPointerMoved(object sender, PointerRoutedEventArgs e) { try { this._gestures.ProcessMoveEvents(e.GetIntermediatePoints(this._reference)); } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); dialog.ShowAsync(); } e.Handled = true; }
protected override void OnPointerMoved(PointerRoutedEventArgs args) { if ((args.Pointer.PointerDeviceType == PointerDeviceType.Pen || !hasPen) && args.Pointer.IsInContact) { IEnumerable <PointerPoint> points = args.GetIntermediatePoints(this).Reverse(); foreach (PointerPoint point in points) { inkManager.ProcessPointerUpdate(point); } } base.OnPointerMoved(args); }
void Canvas_PointerMoved(object sender, PointerRoutedEventArgs e) { if (editingRegion == null) { return; } // Add points to the edit region. regionPoints.AddRange(from point in e.GetIntermediatePoints(canvas) select ConvertDipsToPixels(point)); canvas.Invalidate(); e.Handled = true; }
protected override void OnPointerMoved(PointerRoutedEventArgs args) { // Get ID from event arguments uint id = args.Pointer.PointerId; // If ID is in dictionary, start a loop if (pointerDictionary.ContainsKey(id)) { PointerInfo pointerInfo = pointerDictionary[id]; IList <PointerPoint> pointerpoints = args.GetIntermediatePoints(this); for (int i = pointerpoints.Count - 1; i >= 0; i--) { PointerPoint pointerPoint = pointerpoints[i]; // For each point, create a new Line element and add to Grid Point point = pointerPoint.Position; float pressure = pointerPoint.Properties.Pressure; double radius = 24 * pressure; Geometry geometry = CreateTaperedLineGeometry(pointerInfo.PreviousPoint, pointerInfo.PreviosRadius, point, radius); Path path = new Path { Data = geometry, Fill = pointerInfo.Brush }; /* * Line line = new Line * { * X1 = pointerInfo.PreviousPoint.X, * Y1 = pointerInfo.PreviousPoint.Y, * X2 = point.X, * Y2 = point.Y, * Stroke = pointerInfo.Brush, * StrokeThickness = pressure * 24, * StrokeStartLineCap = PenLineCap.Round, * StrokeEndLineCap = PenLineCap.Round * };*/ contentGrid.Children.Add(path); // Update PointerInfo pointerInfo.PreviousPoint = point; } // Store PointerInfo back in dictionary pointerDictionary[id] = pointerInfo; } base.OnPointerMoved(args); }
private void Grid_PointerMoved(object sender, PointerRoutedEventArgs e) { if (startTracking) { lock (pointers) { pointers.AddRange(e.GetIntermediatePoints(this.Root)); theLine.Points.Clear(); foreach (var p in pointers) { theLine.Points.Add(p.Position); } } } }
private void Log(PointerRoutedEventArgs e, string eventName) { var point = e.GetCurrentPoint(this); var message = $"[POINTER] {eventName}: id={e.Pointer.PointerId} " + $"| src={e.OriginalSource}" + $"| frame={point.FrameId}" + $"| type={e.Pointer.PointerDeviceType} " + $"| position={point.Position} " + $"| rawPosition={point.RawPosition} " + $"| inContact={point.IsInContact} " + $"| inRange={point.Properties.IsInRange} " + $"| primary={point.Properties.IsPrimary}" + $"| intermediates={e.GetIntermediatePoints(this)?.Count.ToString() ?? "null"}"; Log(message); }
void OnPointerMoved(object sender, PointerRoutedEventArgs e) { e.Handled = true; //workarround to enable tap events / focus on textbox / ... if (pointerMovedCount <= 2) { pointerMovedCount++; } if (pointerMovedCount == 2 && !wasPointerPressedCalled) { OnPointerPressed(sender, e); return; } this.gestureRecognizer.ProcessMoveEvents(e.GetIntermediatePoints(this.reference)); }
private void ZoomableGridView_PointerMoved(object sender, PointerRoutedEventArgs e) { try { _recognizer.ProcessMoveEvents(e.GetIntermediatePoints(Window.Current.Content as FrameworkElement)); } catch { _recognizer.CompleteGesture(); } if (_popupHost.IsOpen && e.OriginalSource is FrameworkElement element) { OnItemPointerEntered(sender, element.Tag); } }
private void ChartControl_PointerMoved(object sender, PointerRoutedEventArgs e) { e.Handled = true; if (!IsShowCursor() || _mainCollection == null) { return; } var cursorPos = e.GetCurrentPoint(this).Position; _gestureRecognizer.ProcessMoveEvents(e.GetIntermediatePoints(this)); //Debug.WriteLine("Move " + cursorPos.ToString()); if (!IsPointInChart(cursorPos)) { DropPointerAction(); return; } midPoint = cursorPos; if (_drawingCustomGraphics != null) { if (_isCustomGraphicsDrawingStarted) { CreateCurrentCustomGraphicVisual(cursorPos, false); } } else if (IsUpdatingGraphicLocation()) { UpdateGraphicLocation(cursorPos); } else if (pointerAction == PointerAction.None) { SetCursorPosition(cursorPos); RestartTooltipTimer(); } else if (pointerAction == PointerAction.ZoomIn || pointerAction == PointerAction.Select) { CreateSelectionRectVisual(PointSnapper.RoundPoint(startPoint.Value), PointSnapper.RoundPoint(cursorPos)); } else if (pointerAction == PointerAction.Measure) { CreateRulerVisual(PointSnapper.SnapPoint(startPoint.Value), PointSnapper.SnapPoint(cursorPos), GetChange(startPoint.Value.Y, cursorPos.Y)); } }
private void CanvasElement_PointerMoved(object sender, PointerRoutedEventArgs e) { if (_selectionRanges.Any()) { foreach (var point in e.GetIntermediatePoints(_canvasElement)) { if (point.IsInContact) { var position = point.Position; position.X -= _marginWidth + _marginPadding; _selectionRanges.Last().EndIndex = GetHitIndex(position); _canvasElement.Invalidate(); e.Handled = true; } } } }
private void canvasControl_PointerMoved(object sender, PointerRoutedEventArgs e) { if (pickedUp.PatchIndex >= 0) { foreach (var point in e.GetIntermediatePoints(canvasControl)) { if (point.IsInContact) { patchPoints[pickedUp.PatchIndex][pickedUp.PointIndex] = point.Position.ToVector2(); gradientMesh = null; break; } } canvasControl.Invalidate(); e.Handled = true; } }