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 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 + "}"; }
/// <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);
/// <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 } }
// Unsubscribe from the StrokeHitChanged event when the // user lifts the stylus. protected override void OnStylusUp(StylusEventArgs e) { StylusPointCollection points = e.GetStylusPoints(this); StopEraseHitTesting(points); }
protected override void OnStylusUp(StylusEventArgs e) { if (!this.inCurveMode) { base.OnStylusUp(e); } else { if (this.draggingNubIndex != -1) { OnStylusMove(e); this.draggingNubIndex = -1; this.Cursor = this.lineToolCursor; for (int i = 0; i < this.moveNubs.Length; ++i) { this.moveNubs[i].Visible = true; } } } }
protected override void OnStylusDown(StylusEventArgs e) { bool callBase = false; if (!this.inCurveMode) { callBase = true; } else { PointF mousePtF = new PointF(e.Fx, e.Fy); Point mousePt = Point.Truncate(mousePtF); float minDistance = float.MaxValue; for (int i = 0; i < this.moveNubs.Length; ++i) { if (this.moveNubs[i].IsPointTouching(mousePt, true)) { float distance = Utility.Distance(mousePtF, this.moveNubs[i].Location); if (distance < minDistance) { minDistance = distance; this.draggingNubIndex = i; } } } if (this.draggingNubIndex == -1) { callBase = true; } else { this.Cursor = this.handCursorMouseDown; if (this.curveType == CurveType.NotDecided) { if (e.Button == MouseButtons.Right) { this.curveType = CurveType.Bezier; } else { this.curveType = CurveType.Spline; } } for (int i = 0; i < this.moveNubs.Length; ++i) { this.moveNubs[i].Visible = false; } string helpText2 = PdnResources.GetString("LineTool.CurvingHelpText"); SetStatus(null, helpText2); OnStylusMove(e); } } if (callBase) { base.OnStylusDown(e); Cursor = this.lineToolMouseDownCursor; } }
protected override void OnStylusMove(StylusEventArgs e) { base.OnStylusMove(e); PointF currMouseXY = new PointF(e.Fx, e.Fy); if (mouseDown && ((e.Button & mouseButton) != MouseButtons.None)) { float pressure = GetWidth(e.Pressure); float length; PointF a = lastMouseXY; PointF b = currMouseXY; PointF dir = new PointF(b.X - a.X, b.Y - a.Y); PointF norm; PointF[] poly; RectangleF dotRect = Utility.RectangleFromCenter(currMouseXY, pressure); if (pressure > 0.5f) { renderArgs.Graphics.PixelOffsetMode = PixelOffsetMode.Half; } else { renderArgs.Graphics.PixelOffsetMode = PixelOffsetMode.None; } // save direction before normalizing lastDir = dir; // normalize length = Utility.Magnitude(dir); dir.X /= length; dir.Y /= length; // compute normal vector, calculate perpendicular offest from stroke for width norm = new PointF(dir.Y, -dir.X); norm.X *= pressure; norm.Y *= pressure; a.X -= dir.X * 0.1666f; a.Y -= dir.Y * 0.1666f; lastNorm = norm; poly = MakePolygon( new PointF(a.X - lastNorm.X, a.Y - lastNorm.Y), new PointF(a.X + lastNorm.X, a.Y + lastNorm.Y), new PointF(b.X + norm.X, b.Y + norm.Y), new PointF(b.X - norm.X, b.Y - norm.Y)); RectangleF saveRect = RectangleF.Union( dotRect, RectangleF.Union( Utility.PointsToRectangle(poly[0], poly[1]), Utility.PointsToRectangle(poly[2], poly[3]))); saveRect.Inflate(2.0f, 2.0f); // account for anti-aliasing saveRect.Intersect(ActiveLayer.Bounds); // drawing outside of the canvas is a no-op, so don't do anything in that case! // also make sure we're within the clip region if (saveRect.Width > 0 && saveRect.Height > 0 && renderArgs.Graphics.IsVisible(saveRect)) { Rectangle saveRectRounded = Utility.RoundRectangle(saveRect); saveRectRounded.Intersect(ActiveLayer.Bounds); if (saveRectRounded.Width > 0 && saveRectRounded.Height > 0) { SaveRegion(null, saveRectRounded); this.savedRects.Add(saveRectRounded); if (AppEnvironment.AntiAliasing) { renderArgs.Graphics.SmoothingMode = SmoothingMode.AntiAlias; } else { renderArgs.Graphics.SmoothingMode = SmoothingMode.None; } renderArgs.Graphics.CompositingMode = AppEnvironment.GetCompositingMode(); renderArgs.Graphics.FillEllipse(brush, dotRect); // bail out early if the mouse hasn't even moved. If we don't bail out, we'll get a 0-distance move, which will result in a div-by-0 if (lastMouseXY != currMouseXY) { renderArgs.Graphics.FillPolygon(brush, poly, FillMode.Winding); } } bitmapLayer.Invalidate(saveRectRounded); } lastNorm = norm; lastMouseXY = currMouseXY; } else { lastMouseXY = currMouseXY; lastNorm = PointF.Empty; lastDir = PointF.Empty; this.previewRenderer.BrushSize = AppEnvironment.PenInfo.Width / 2.0f; } this.previewRenderer.BrushLocation = currMouseXY; }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusDown(StylusEventArgs e)
protected override void OnStylusInRange(StylusEventArgs e) { IsStylusInRange = true; base.OnStylusInRange(e); }
/// <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 + ")"; } }
protected override void OnStylusUp(StylusEventArgs e) { base.OnStylusUp(e); Cursor = cursorMouseUp; if (moveOriginMode) { moveOriginMode = false; } else if (mouseDown) { bool doCommit = OnShapeEnd(); if (doCommit) { CommitShape(); } else { // place a 'sentinel' history action on the stack that will be filled in later CompoundHistoryMemento cha = new CompoundHistoryMemento(Name, Image, new List<HistoryMemento>()); HistoryStack.PushNewMemento(cha); this.chaAlreadyOnStack = cha; } } }
protected override void OnStylusMove(StylusEventArgs e) { base.OnStylusMove (e); if (moveOriginMode) { SizeF delta = new SizeF(e.Fx - lastXY.X, e.Fy - lastXY.Y); for (int i = 0; i < points.Count; ++i) { PointF ptF = (PointF)points[i]; ptF.X += delta.Width; ptF.Y += delta.Height; points[i] = ptF; } lastXY = new PointF(e.Fx, e.Fy); } else if (mouseDown && ((e.Button & mouseButton) != MouseButtons.None)) { PointF mouseXY = new PointF(e.Fx, e.Fy); points.Add(mouseXY); } }
protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); if (!this.shapeWasCommited) { CommitShape(); } this.ClearSavedMemory(); this.ClearSavedRegion(); cursorMouseUp = Cursor; Cursor = cursorMouseDown; if (mouseDown && e.Button == mouseButton) { return; } if (mouseDown) { moveOriginMode = true; lastXY = new PointF(e.Fx, e.Fy); OnStylusMove(e); } else if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { // begin new shape this.shapeWasCommited = false; OnShapeBegin(); mouseDown = true; mouseButton = e.Button; using (PdnRegion clipRegion = Selection.CreateRegion()) { renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); } // reset the points we're drawing! points = new List<PointF>(); OnStylusMove(e); } }
protected override void OnStylusUp(StylusEventArgs e) { base.OnStylusUp(e); Cursor = cursorMouseUp; if (mouseDown) { this.previewRenderer.Visible = true; mouseDown = false; if (this.savedRects.Count > 0) { PdnRegion saveMeRegion = Utility.RectanglesToRegion(this.savedRects.ToArray()); HistoryMemento ha = new BitmapHistoryMemento(Name, Image, DocumentWorkspace, ActiveLayerIndex, saveMeRegion, this.ScratchSurface); HistoryStack.PushNewMemento(ha); saveMeRegion.Dispose(); this.savedRects.Clear(); this.ClearSavedMemory(); } this.brush.Dispose(); this.brush = null; } }
private void combobox26_LostStylusCapture(object sender, StylusEventArgs e) { }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusUp(StylusEventArgs e) { base.OnStylusUp(e); Stylus.Capture(this, CaptureMode.None);
private void HandleEventSignaturePadCanvasPreviewStylusUp(object sender, StylusEventArgs e) { ProcessStylusEvent(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); Stylus.Capture(this);
/// <summary> /// Handles the touch move event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusMove(StylusEventArgs e)
protected override void OnStylusOutOfRange(StylusEventArgs e) { //Application.Current.Windows[0].Title = "StylusOutOfRange"; }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusUp(StylusEventArgs e) { base.OnStylusUp(e);
// Token: 0x06006D47 RID: 27975 RVA: 0x001F5EAC File Offset: 0x001F40AC private void OnInkCanvasStylusOutOfRange(object sender, StylusEventArgs args) { this.UpdateInvertedState(args.StylusDevice, false); }
/// <summary> /// Event for mesh highlighting /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ParentStylusInAirMove(object sender, StylusEventArgs e) { // Our stylus position Point stylPt = e.GetPosition(this); // Unhighlight everything foreach (List <GeometryDrawing> mesh in meshesDrawn.Values) { foreach (GeometryDrawing line in mesh) { line.Pen.Thickness = RegularLineThickness; } } foreach (GeometryDrawing gate in gatesDrawn.Values) { gate.Pen.Thickness = RegularLineThickness; } foreach (GeometryDrawing label in labels.Values) { label.Pen.Thickness = RegularLineThickness; } // What do we want to highlight? List <int> meshesHighlighted = new List <int>(); List <String> elementsHighlighted = new List <string>(); // The stylus is only at one place, so if we find an element under it we shouldn't look any more. bool pointFound = false; // Find everything that should be highlighted // Try not to search any more than you have to! // Look at the gates first... foreach (string gate in gatesDrawn.Keys) { if (gatesDrawn[gate].Bounds.Contains(stylPt)) { foreach (int mesh in meshDict[gate]) { if (!meshesHighlighted.Contains(mesh)) { meshesHighlighted.Add(mesh); } } elementsHighlighted.Add(gate); pointFound = true; break; } } // If we haven't found the point, look in the labels if (!pointFound) { foreach (string label in labels.Keys) { if (labels[label].Bounds.Contains(stylPt)) { foreach (int mesh in meshDict[label]) { if (!meshesHighlighted.Contains(mesh)) { meshesHighlighted.Add(mesh); } } elementsHighlighted.Add(label); pointFound = true; break; } } } // If we still haven't found the point, look in the wires if (!pointFound) { foreach (int mesh in meshesDrawn.Keys) { foreach (GeometryDrawing line in meshesDrawn[mesh]) { Rect bounds = new Rect(new Point(line.Bounds.X - 10, line.Bounds.Y - 10), new Size(line.Bounds.Width + 20, line.Bounds.Height + 20)); if (bounds.Contains(stylPt)) { pointFound = true; meshesHighlighted.Add(mesh); foreach (string elem in meshDict.Keys) { if (meshDict[elem].Contains(mesh)) { elementsHighlighted.Add(elem); } } break; } } } } // Now highlight everything that we found if (pointFound) { HighlightElements(elementsHighlighted); HighlightMeshes(meshesHighlighted); } }
protected override void OnStylusDown(StylusEventArgs e) { base.OnStylusDown(e); if (mouseDown) { return; } ClearSavedMemory(); this.previewRenderer.Visible = false; Cursor = cursorMouseDown; if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right)) { mouseButton = e.Button; if ((mouseButton & MouseButtons.Left) == MouseButtons.Left) { brush = AppEnvironment.CreateBrush(false); } else if ((mouseButton & MouseButtons.Right) == MouseButtons.Right) { brush = AppEnvironment.CreateBrush(true); } lastMouseXY.X = e.Fx; lastMouseXY.Y = e.Fy; mouseDown = true; mouseButton = e.Button; using (PdnRegion clipRegion = Selection.CreateRegion()) { renderArgs.Graphics.SetClip(clipRegion.GetRegionReadOnly(), CombineMode.Replace); } this.OnStylusMove(new StylusEventArgs(e.Button, e.Clicks, unchecked(e.Fx + 0.01f), e.Fy, e.Delta, e.Pressure)); } }
void MainWindowStylusUp(object sender, StylusEventArgs e) { DoTapUp(); }
void OnNativeStylusUp(object sender, StylusEventArgs e) => Element.NotifyRowTapped(Control.SelectedIndex, cell: null);
public bool OnMoved(StylusEventArgs e) { // Accept only the saved pointer, reject others return((mDevice != null) && (mDevice == e.StylusDevice)); }
protected override void OnStylusMove(StylusEventArgs e) { if (!this.inCurveMode) { base.OnStylusMove(e); } else if (this.draggingNubIndex != -1) { PointF mousePt = new PointF(e.Fx, e.Fy); this.moveNubs[this.draggingNubIndex].Location = mousePt; List<PointF> points = GetTrimmedShapePath(); points[this.draggingNubIndex] = mousePt; SetShapePath(points); } }
protected override void OnStylusMove(StylusEventArgs e) { StylusPointCollection points = e.GetStylusPoints(this); AddPointsToEraserHitTester(points); }
private void OnStylusEnterEvent(object sender, StylusEventArgs e) { OnEnterEvent(); }
private void StylusEventHandler(object sender, StylusEventArgs e) { }
private void OnStylusLeaveEvent(object sender, StylusEventArgs e) { OnLeaveEvent(); }
private void ProcessStylusEvent(StylusEventArgs e, [CallerMemberName] string callerName = null) { DebugMessage($"{callerName}"); if (strokeMouse != null) { return; } if (callerName == nameof(HandleEventSignaturePadCanvasPreviewStylusDown)) { if (lStroke?.Count == 0) { RecordingStarted?.Invoke(); } strokeStylus = new InkStroke(InkSource.Stylus); foreach (var sp in e.GetStylusPoints(canvasSignaturePad)) { var ip = new InkPoint(sp.ToPoint(), sp.PressureFactor, null, GetCurrentTimestamp()); DebugInkPoint(callerName, strokeStylus.Points.Count, ip); if (ip.Position.X < 0 || ip.Position.X > Width || ip.Position.Y < 0 || ip.Position.Y > Height) { borderTouch = true; return; } strokeStylus.Points.Add(ip); } } else if (strokeStylus != null) { var tsNow = GetCurrentTimestamp(); var sps = e.GetStylusPoints(canvasSignaturePad); if (sps.Count > 1) { var tsLast = strokeStylus.Points.Last().Timestamp; for (var idxSp = 0; idxSp < sps.Count; idxSp++) { var sp = sps[idxSp]; var tsPointApprox = TimeSpan.FromTicks((tsNow.Ticks - tsLast.Ticks) * (idxSp + 1) / sps.Count + tsLast.Ticks); var ip = new InkPoint(sp.ToPoint(), sp.PressureFactor, null, tsPointApprox); DebugInkPoint(callerName, strokeStylus.Points.Count, ip); if (ip.Position.X < 0 || ip.Position.X > Width || ip.Position.Y < 0 || ip.Position.Y > Height) { borderTouch = true; return; } strokeStylus.Points.Add(ip); } } else if (sps.Count > 0) { var ip = new InkPoint(sps[0].ToPoint(), sps[0].PressureFactor, null, tsNow); DebugInkPoint(callerName, strokeStylus.Points.Count, ip); if (ip.Position.X < 0 || ip.Position.X > Width || ip.Position.Y < 0 || ip.Position.Y > Height) { BorderTouch?.Invoke(); return; } strokeStylus.Points.Add(ip); } if (callerName == nameof(HandleEventSignaturePadCanvasPreviewStylusUp)) { DebugMessage($"StrokeCaptured: #{lStroke.Count} Src = {strokeStylus.Source}, Count = {strokeStylus.Points.Count} @ {strokeStylus.Timestamp}"); lStroke.Add(strokeStylus); strokeStylus = null; } } }
private void cProbe_StylusInAirMove(object sender, StylusEventArgs e) { DisplayEvent("StylusInAirMove", e.ToText()); }
protected override void OnStylusOutOfRange(StylusEventArgs e) { IsStylusInRange = false; base.OnStylusOutOfRange(e); }
private void cProbe_StylusOutOfRange(object sender, StylusEventArgs e) { DisplayEvent("StylusOutOfRange", e.ToText()); }
/// <summary> /// Hides all tooltips and stops the timer when the stylus leaves /// the InkCanvas /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InkCanvas_StylusOutOfRange(object sender, StylusEventArgs e) { HideAllTooltips(); hoverTimeUp = false; hoverTimer.Stop(); }
private void cProbe_StylusUp(object sender, StylusEventArgs e) { DisplayEvent("StylusUp", e.ToText()); }
private void HandleStylusLeave(object sender, StylusEventArgs e) { AddPenPointerEvent(PointerEventType.Exited, PointerUpdateKind.Other, false, e); }
public static string ToText(this StylusEventArgs e) { return(e.StylusDevice.ToText()); }
/// <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() + ")"; }
private void image1_StylusUp(object sender, StylusEventArgs e) { e.Handled = true; strokeNumber += 1; }
/// <summary> /// Handles the touch move. /// </summary> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected override void OnStylusMove(StylusEventArgs e)
private void Window_StylusUp(object sender, StylusEventArgs e) { }