/// <summary> /// Occurs when the stylus is moving in the hover space /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void inkCanvas_StylusInAirMove(object sender, StylusEventArgs e) { if (selectionActive || editActive || labelActive) { return; } else if (widgetsShowing) { System.Windows.Point movePoint = e.GetPosition(sketchPanel.InkCanvas); double distance = Math.Sqrt(Math.Pow((movePoint.X - startPoint.X), 2) + Math.Pow((movePoint.Y - startPoint.Y), 2)); if (distance > widgetRadius + wiggleRoom && !stylusOverWidget(movePoint)) { HideAllWidgets(); } } hoverPoint = e.GetPosition(sketchPanel.InkCanvas); if (!hoverTimer.Enabled) { startPoint = e.GetPosition(sketchPanel.InkCanvas); hoverTimer.Start(); } }
private void OnStylusStuff(object sender, StylusEventArgs args) { if (args.RoutedEvent == UIElement.PreviewStylusUpEvent || (args.RoutedEvent == UIElement.PreviewStylusDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.PreviewStylusMoveEvent && args.Source == null && args.InAir)) { MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); } else if (args.RoutedEvent == UIElement.PreviewStylusDownEvent) { MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _pts[args.StylusDevice.Id] = new FlickData() { DownPoint = args.GetPosition(_attachedElement) }; } else if (args.RoutedEvent == UIElement.PreviewStylusMoveEvent) { if (!_pts.ContainsKey(args.StylusDevice.Id)) { return; } Point current = args.GetPosition(_attachedElement); FlickData data = _pts[args.StylusDevice.Id]; Vector change = Point.Subtract(current, data.DownPoint); double delta = change.Length; if (data.BeginTime == 0 && delta > BeginThreshold) { data.BeginTime = args.Timestamp; } if (data.BeginTime != 0 && delta > EndThreshold && (args.Timestamp - data.BeginTime) < RequiredFlickSpeed.TotalMilliseconds) { MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _pts.Remove(args.StylusDevice.Id); FlickEventArgs fargs = new FlickEventArgs(change / delta); if (Flick != null) { Flick(_attachedElement, fargs); } if (fargs.AlignedDirection.X != 0 && HorizontalFlick != null) { HorizontalFlick(_attachedElement, fargs); } if (fargs.AlignedDirection.Y != 0 && VerticalFlick != null) { VerticalFlick(_attachedElement, fargs); } } } }
protected override void OnPreviewStylusMove(StylusEventArgs e) { base.OnPreviewStylusMove(e); if (_numTouches == 1 && _touchId[0] == e.StylusDevice.Id && !_inZooming) { Point newTouchPosition = e.GetPosition(_canvas); _MovePhoto(new Vector(newTouchPosition.X - _touchLastPts[0].X, newTouchPosition.Y - _touchLastPts[0].Y)); _touchLastPts[0] = newTouchPosition; } else if (_numTouches == 2 && (_touchId[0] == e.StylusDevice.Id || _touchId[1] == e.StylusDevice.Id)) { int index = _touchId[0] == e.StylusDevice.Id ? 0 : 1; Point p0 = e.GetPosition(_canvas); Point p1 = _touchLastPts[1 - index]; double distance = (p0 - p1).Length; double scale = distance / (_touchInitialPts[0] - _touchInitialPts[1]).Length; if (scale > 0.1 && scale < 20) { _ResizePhoto(scale); } _touchLastPts[index] = p0; _inZooming = true; } e.Handled = true; }
private void OnStylusStuff(object sender, StylusEventArgs args) { if (args.RoutedEvent == UIElement.PreviewStylusUpEvent || (args.RoutedEvent == UIElement.PreviewStylusDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.PreviewStylusMoveEvent && args.Source == null && args.InAir)) { _pts.Remove(args.StylusDevice.Id); MultitouchWindow.ClearPhysicalReferenceFrame(args.StylusDevice); MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _processor.ProcessUp((uint)args.StylusDevice.Id, ToDrawingPointF(args.GetPosition(_attachedElement))); } else if (args.RoutedEvent == UIElement.PreviewStylusDownEvent) { System.Windows.Point pt = args.GetPosition(_attachedElement); _pts.Add(args.StylusDevice.Id, pt); MultitouchWindow.PushPhysicalReferenceFrame(args.StylusDevice, this); MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _processor.ProcessDown((uint)args.StylusDevice.Id, ToDrawingPointF(pt)); } else if (args.RoutedEvent == UIElement.PreviewStylusMoveEvent) { if (!_pts.ContainsKey(-1)) { return; } //_processor.ProcessMove((uint)args.StylusDevice.Id, ToDrawingPointF(args.GetPosition(_attachedElement))); } }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusUp(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchUp(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. The // point will be in relation to the text object that captured // the touch. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Up at (" + x + "," + y + ")"; } else { text.TextContent = "NOT Captured. Up detected at (" + x + "," + y + ")"; } }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusDown(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchDown(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { // If the user tapped inside the same control that has the // touch captured, release the capture. if ((x >= 0) && (y >= 0) && (x <= text.ActualWidth) && (y <= text.ActualHeight)) { #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text, CaptureMode.None); #else TouchCapture.Capture(text, CaptureMode.None); #endif text.ForeColor = ColorUtility.ColorFromRGB(0, 0, 0); text.TextContent = "Capture Released."; } // Else, show the point as captured. else { text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; } } // Else, show the point as captured. else { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text); #else TouchCapture.Capture(text); #endif } }
private void MCanvas_StylusMove(object sender, StylusEventArgs e) { float pressure = e.GetStylusPoints((IInputElement)sender).Select(i => i.PressureFactor).Average(); var xy = e.GetPosition((IInputElement)sender); var x = xy.X; var y = xy.Y; bool inair = e.InAir; var point = e.GetStylusPoints((IInputElement)sender).First(); // point descriptors bool barrel = default; int pitch = default; int roll = default; int yaw = default; if (point.Description.HasProperty(StylusPointProperties.BarrelButton)) { barrel = point.GetPropertyValue(StylusPointProperties.BarrelButton) != 0; } /* if (point.Description.HasProperty(StylusPointProperties.PitchRotation)) * pitch = point.GetPropertyValue(StylusPointProperties.PitchRotation); * * if (point.Description.HasProperty(StylusPointProperties.RollRotation)) * roll = point.GetPropertyValue(StylusPointProperties.RollRotation); * * if (point.Description.HasProperty(StylusPointProperties.YawRotation)) * yaw = point.GetPropertyValue(StylusPointProperties.YawRotation); */ mDeviceUpdater.ProcessAndEnqueueUpdate(x, y, xmax, ymax, pressure, inair, false, barrel); textbox.Text = $"at {x}, {y} with pressure {pressure} {(inair ? "in air" : "touching")} - {(barrel ? "barrel" : "")} - {yaw};{pitch};{roll}"; }
private void MainWindow_StylusMove(object sender, StylusEventArgs e) { var point = e.GetPosition(this); EraserView.X = point.X - EraserView.Width / 2; EraserView.Y = point.Y - EraserView.Height / 2; }
private void TargetImagePreviewContactUp(object sender, StylusEventArgs e) { e.Handled = true; e.StylusDevice.Capture(_targetImage, CaptureMode.None); _manipulationProcessor.ProcessUp((uint)e.StylusDevice.Id, e.GetPosition(_targetImage).ToDrawingPointF()); }
protected virtual void OnStylusStuff(object sender, StylusEventArgs args) { if (Container == null) { Container = AssociatedObject; } Point pt = args.GetPosition(Container); if (args.RoutedEvent == UIElement.PreviewStylusUpEvent || (args.RoutedEvent == UIElement.PreviewStylusDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.PreviewStylusMoveEvent && args.Source == null && args.InAir)) { MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); ProcessPointUp(args.StylusDevice.Id, pt); } else if (args.RoutedEvent == UIElement.PreviewStylusDownEvent) { MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); ProcessPointDown(args.StylusDevice.Id, pt); } else if (args.RoutedEvent == UIElement.PreviewStylusMoveEvent) { ProcessPointMove(args.StylusDevice.Id, pt); } }
private void text_StylusMove(object sender, StylusEventArgs e) { Text txt = (Text)sender; int xrel, yrel; e.GetPosition(txt, out xrel, out yrel); txt.TextContent = "Move, screen={" + e.X + "," + e.Y + "}, relative={" + xrel + "," + yrel + "}"; }
private void AddPenPointerEvent(PointerEventType eventType, PointerUpdateKind updateKind, bool isPress, StylusEventArgs e) { var p = e.GetPosition(element); var point = new PointerPoint(); FillPointInformation(ref point, eventType, PointerDeviceType.Pen, updateKind, p); // if this was a press - try to determine which button was pressed if (isPress) { if (e.Inverted) { point.IsRightButtonPressed = true; } else { point.IsLeftButtonPressed = true; } } manager.AddPointerEvent(ref point); }
/*private void timer_tick(Object source, System.Timers.ElapsedEventArgs e) * { * App.Current.Dispatcher.Invoke((Action)delegate * { * if (this.WindowState == WindowState.Minimized) * { * ShowWindow(hWnd, 3); * this.WindowState = WindowState.Maximized; * Console.Write(hWnd); * } * }); * }*/ /*protected override void OnSourceInitialized(EventArgs e) * { * base.OnSourceInitialized(e); * var hwnd = new WindowInteropHelper(this).Handle; * Console.WriteLine("hwnd: "+hwnd); * MainWindow.SetWindowExTransparent(hwnd); * }*/ /*private void Worker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e) * { * int progress = e.ProgressPercentage; * * //you can update progress bar or UI component from the value handled * } * * private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) * { * while (true) * { * //do something here * int progress = 0; * worker.ReportProgress(progress); * } * }*/ private void stylus_move(object sender, StylusEventArgs e) { Point pos = e.GetPosition(this); var point = PointToScreen(pos); this.listPoints.Add(pos); }
public StylusInput(object sender, StylusEventArgs args) : base(sender, args) { Position = args.GetPosition(sender as IInputElement); _inputType = UIInputType.Stylus; switch (args.RoutedEvent.Name) { case "StylusDown": _inputState = UIInputState.Pressed; break; case "StylusUp": _inputState = UIInputState.Released; break; case "StylusMove": _inputState = UIInputState.NotApplied; break; default: _inputType = UIInputType.None; break; } }
public static void OnPreviewStylusMove(StylusEventArgs e) { if (!e.Handled) { _lastposition = e.GetPosition(Application.Current.MainWindow.Content as UIElement); } }
public void ProcessDown(object sender, StylusEventArgs args) { downTime++; Console.WriteLine("downTime:" + downTime); Point location = args.GetPosition(_inkCanvas); int index = _spiralSummarization.getSelectedKeyFrameIndex(location);//, _spiralSummarization); //if (pictureTracker == null) // return; if (index != int.MinValue) { index = _spiralSummarization.KeyFrames.IndexOf(_spiralSummarization.ShowKeyFrames[index]); } if (indexes[0] == int.MinValue) { indexes[0] = index; } else { indexes[1] = index; } Console.WriteLine("index0:" + indexes[0]); Console.WriteLine("index1:" + indexes[1]); PictureTracker pictureTracker = GetPictureTracker(args.StylusDevice.Id, location); pictureTracker.ProcessDown(args.StylusDevice.Id, location); }
private void text_StylusDown(object sender, StylusEventArgs e) { Text txt = (Text)sender; Stylus.Capture(txt, CaptureMode.Element); int xrel, yrel; e.GetPosition(txt, out xrel, out yrel); txt.TextContent = "Down, screen={" + e.X + "," + e.Y + "}, relative={" + xrel + "," + yrel + "}"; }
protected override void OnStylusInRange(StylusEventArgs e) { PenInRangeEventEventArgs args = new PenInRangeEventEventArgs(); args.Stylus_Point = e.GetPosition((InkCanvas)e.Source); OnPenInRangeEvent(args); base.OnStylusInRange(e); }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); int x; int y; e.GetPosition((UIElement)this, out x, out y);
private void image1_StylusMove(object sender, StylusEventArgs e) { Point pt = e.GetPosition(image1); StylusPointCollection sp = e.GetStylusPoints(image1); DrawContinue(pt, sp[0].PressureFactor); e.Handled = true; }
private void text_StylusMove(object sender, StylusEventArgs e) { Text txt = (Text)sender; int xrel, yrel; e.GetPosition(txt, out xrel, out yrel); txt.TextContent = "Move, screen={" + e.X + "," + e.Y + "}, relative={" + xrel + "," + yrel + "}"; }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); int x; int y; e.GetPosition((UIElement)this, out x, out y);
private void ProcessMove(object sender, StylusEventArgs e) { Point newLocation = e.GetPosition(canvas); viewModel.X += newLocation.X - previousLocation.X; viewModel.Y += newLocation.Y - previousLocation.Y; previousLocation = newLocation; }
private void labelButton_Click(object sender, StylusEventArgs e) { if (debug) { Console.WriteLine("___Label from button"); } Point pos = e.GetPosition((IInputElement)sketchPanel.InkCanvas); DisplayLabelMenu(pos); }
private void text_StylusUp(object sender, StylusEventArgs e) { Text txt = (Text)sender; Stylus.Capture(txt, CaptureMode.None); int xrel, yrel; e.GetPosition(txt, out xrel, out yrel); txt.TextContent = "Up, screen={" + e.X + "," + e.Y + "}, relative={" + xrel + "," + yrel + "}"; }
protected override void OnStylusMove(StylusEventArgs args) { base.OnStylusMove(args); if (isDrawing) { Point ptStylus = args.GetPosition(canv); polyStylus.Points.Add(ptStylus); polyShadow.Points.Add(ptStylus + vectShadow); args.Handled = true; } }
private void ElementOnStylusMove(object sender, StylusEventArgs e) { if (e.StylusDevice.Id == stylusId) { var element = (FrameworkElement)sender; var parent = (UIElement)element.Parent; var point = e.GetPosition(parent); OnMove(element, point); } }
private void TargetImagePreviewContactChanged(object sender, StylusEventArgs e) { Point position = e.GetPosition(_targetImage); e.Handled = true; if (position.X < 0 || position.Y < 0 || position.X > _targetImage.Width || position.Y > _targetImage.Height) { e.StylusDevice.Capture(_targetImage, CaptureMode.None); _manipulationProcessor.ProcessUp((uint)e.StylusDevice.Id, e.GetPosition(_targetImage).ToDrawingPointF()); } else { e.StylusDevice.Capture(_targetImage, CaptureMode.SubTree); _manipulationProcessor.ProcessMove((uint)e.StylusDevice.Id, e.GetPosition(_targetImage).ToDrawingPointF()); } }
/// <summary> /// Updates position of mouse and calls display tooltips /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InkCanvas_StylusMove(object sender, StylusEventArgs e) { if (hoverTimeUp && !e.StylusDevice.Inverted) { DisplayHelpTip(e.GetPosition(sketchPanel.InkCanvas)); } else if (!hoverTimer.Enabled) { hoverTimer.Start(); } }
void MainInkCanvas_StylusMove(object sender, StylusEventArgs e) { if (e.GetPosition(MainInkCanvas).X <= 10) { openSidebar(); } else { hideSidebar(); } }
public override void StylusMove(EditorContext context, StylusEventArgs args) { if (isPressed > 0) { if (!args.InAir) { Point mousePos = args.GetPosition(context.EditorControl); Editor.PanEditor(context, Point.Subtract(mousePos, lastPos)); lastPos = mousePos; } } }
public void ProcessUp(object sender, StylusEventArgs args) { Point location = args.GetPosition(_canvas); PictureTracker pictureTracker = GetPictureTracker(args.StylusDevice.Id, location); if (pictureTracker == null) { return; } pictureTracker.ProcessUp(args.StylusDevice.Id, location); }
/// <summary> /// Handles the touch move event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusMove(StylusEventArgs e) { base.OnStylusUp(e); int x = 0; int y = 0; e.GetPosition((UIElement)this, out x, out y); // Add this point to the array. AddPoint(x, y); text.TextContent = "TouchMove (" + x.ToString() + "," + y.ToString() + ")"; }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusUp(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchUp(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. The // point will be in relation to the text object that captured // the touch. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Up at (" + x + "," + y + ")"; } else { text.TextContent = "NOT Captured. Up detected at (" + x + "," + y + ")"; } }
/// <summary> /// Handles the touch move event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusMove(StylusEventArgs e) { base.OnStylusUp(e); int x = 0; int y = 0; e.GetPosition((UIElement)this, out x, out y); // Add this point to the array. AddPoint(x, y); text.TextContent = "TouchMove (" + x.ToString() + "," + y.ToString() + ")"; }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusDown(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchDown(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { // If the user tapped inside the same control that has the // touch captured, release the capture. if ((x >= 0) && (y >= 0) && (x <= text.ActualWidth) && (y <= text.ActualHeight)) { #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text, CaptureMode.None); #else TouchCapture.Capture(text, CaptureMode.None); #endif text.ForeColor = ColorUtility.ColorFromRGB(0, 0, 0); text.TextContent = "Capture Released."; } // Else, show the point as captured. else { text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; } } // Else, show the point as captured. else { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text); #else TouchCapture.Capture(text); #endif } }