//Pointerリリース時処理 private void InkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == _penID) { PointerPoint pt = e.GetCurrentPoint(InkCanvas); // _inkManager.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input PointerPoint pt = e.GetCurrentPoint(InkCanvas); // _inkManager.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; // //RenderAllStroke(); //test case で消されてた。 e.Handled = true; }
private void MyCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == _penID) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(MyCanvas); // Pass the pointer information to the InkManager. _inkKhaled.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(MyCanvas); // Pass the pointer information to the InkManager. _inkKhaled.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; // Call an application-defined function to render the ink strokes. e.Handled = true; _undo.Push(l); _redo.Clear(); }
public void InkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { try { if (e.Pointer.PointerId == _penID) { PointerPoint pt = e.GetCurrentPoint(InkCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input } _touchID = 0; _penID = 0; // Call an application-defined function to render the ink strokes. RenderAllStrokes(); e.Handled = true; } catch (Exception ex) { MessageDialog msg = new MessageDialog(ex.Message + " Void - InkCanvas_PointerReleased"); //msg.ShowAsync(); } }
public void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == m_PenId) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(InkCanvas); if (m_CurrentMode == "Erase") { System.Diagnostics.Debug.WriteLine("Erasing : Pointer Released"); m_InkManager.ProcessPointerUp(pt); } else { // Pass the pointer information to the InkManager. CurrentManager.ProcessPointerUp(pt); } } else if (e.Pointer.PointerId == _touchID) { // Process touch input } _touchID = 0; m_PenId = 0; // Call an application-defined function to render the ink strokes. RefreshCanvas(); e.Handled = true; }
protected override void OnPointerReleased(PointerRoutedEventArgs args) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(this); uint id = pointerPoint.PointerId; if (pointerDictionary.ContainsKey(id)) { // Give PointerPoint to InkManager inkManager.ProcessPointerUp(pointerPoint); if (inkManager.Mode == InkManipulationMode.Inking) { // Get rid of the little Line segments newLineGrid.Children.Clear(); // Render the new stroke IReadOnlyList <InkStroke> inkStrokes = inkManager.GetStrokes(); InkStroke inkStroke = inkStrokes[inkStrokes.Count - 1]; RenderStroke(inkStroke); } pointerDictionary.Remove(id); } base.OnPointerReleased(args); }
protected override void OnPointerReleased(PointerRoutedEventArgs args) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(sheetPanel); uint id = pointerPoint.PointerId; InkManager inkManager = this.InkFileManager.InkManager; if (pointerDictionary.ContainsKey(id)) { // Give PointerPoint to InkManager inkManager.ProcessPointerUp(pointerPoint); if (inkManager.Mode == InkManipulationMode.Inking) { // Get rid of the little line segments newLineGrid.Children.Clear(); // Render the new stroke IReadOnlyList <InkStroke> inkStrokes = inkManager.GetStrokes(); InkStroke inkStroke = inkStrokes[inkStrokes.Count - 1]; this.InkFileManager.RenderStroke(inkStroke); } else if (inkManager.Mode == InkManipulationMode.Selecting) { // Get rid of the enclosure line newLineGrid.Children.Clear(); // Render everything so selected items are identified this.InkFileManager.RenderAll(); } pointerDictionary.Remove(id); } base.OnPointerReleased(args); }
private void OnMouseReleasedCanvas(object sender, PointerRoutedEventArgs e) //Event Handler When The Mouse Is Released On The White Canvas { try { if (e.Pointer.PointerId == pointerId) //For Checking If The Same Pointer Is Used { PointerPoint pt = e.GetCurrentPoint(InkCanvas); //For Getting The Current Position Of The Pointer inkManager.ProcessPointerUp(pt); //Registering The Position releasePosition = pt.Position; } if (InkCanvas.Children.Contains(rectangle)) { Rectangle rect = new Rectangle() { Margin = new Thickness(previousPosition.X, previousPosition.Y, 0, 0), Height = Math.Abs(previousPosition.Y - releasePosition.Y), Width = Math.Abs(previousPosition.X - releasePosition.X), StrokeThickness = strokeThickness, Stroke = pen }; InkCanvas.Children.Remove(rectangle); InkCanvas.Children.Add(rect); } else if (InkCanvas.Children.Contains(ellipse)) { Ellipse ell = new Ellipse() { Margin = new Thickness(previousPosition.X, previousPosition.Y, 0, 0), Height = Math.Abs(previousPosition.Y - releasePosition.Y), Width = Math.Abs(previousPosition.X - releasePosition.X), StrokeThickness = strokeThickness, Stroke = pen }; InkCanvas.Children.Remove(ellipse); InkCanvas.Children.Add(ell); } else if (InkCanvas.Children.Contains(straightLine)) { Line sl = new Line() { X1 = previousPosition.X, Y1 = previousPosition.Y, //Cursor Coordinate From The Mouse Press Event X2 = releasePosition.X, Y2 = releasePosition.Y, //Cursor Coordinate From The Mouse Move Event StrokeThickness = strokeThickness, //Set The Thickness Of The Drawing Pen Stroke = pen }; InkCanvas.Children.Remove(straightLine); InkCanvas.Children.Add(sl); } pointerId = 0; //Now User Can Draw With Another Type Of Input[whether its touch or mouse] e.Handled = true; //Tell Event Is Success } catch (Exception ex) { } }
async private void panelcanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { try { if (e.Pointer.PointerId == _penID) { Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(PanelCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input PointerPoint pt = e.GetCurrentPoint(PanelCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; var backMarkup = await ApplicationData.Current.RoamingFolder.CreateFileAsync("markupimage_" + App.Task.CaseNumber + this.listView.SelectedIndex, CreationCollisionOption.ReplaceExisting); if (_inkManager.GetStrokes().Count > 0) { //buffer.Seek(0); using (var os = await backMarkup.OpenAsync(FileAccessMode.ReadWrite)) { await _inkManager.SaveAsync(os); } } // Call an application-defined function to render the ink strokes. e.Handled = true; } catch (Exception ex) { //new MessageDialog(ex.Message,"Error").ShowAsync(); } }
public void PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == _penID) { PointerPoint pt = e.GetCurrentPoint(DrawingCanvas); _inkManager.ProcessPointerUp(pt); } _touchID = 0; _penID = 0; e.Handled = true; }
void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { Canvas canvas = sender as Canvas; InkManager inkManager = MedcialInkManager; if (e.Pointer.PointerId == PenID || e.Pointer.PointerId == TouchID) { inkManager.ProcessPointerUp(e.GetCurrentPoint(canvas)); } TouchID = 0; PenID = 0; e.Handled = true; //Pencil = null; }
void canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == PenID || e.Pointer.PointerId == TouchID) { MyInkManager.ProcessPointerUp(e.GetCurrentPoint(canvas)); } TouchID = 0; PenID = 0; e.Handled = true; Pencil = null; NewLine = null; NewRectangle = null; NewEllipse = null; }
private void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e) { var pointerPoint = e.GetCurrentPoint(this); if (pointerPoint.PointerId == currentPointerId) { inkManager.ProcessPointerUp(pointerPoint); // update the visual tempPathShape.Data = new GeometryGroup(); Invalidate(); OnStrokeCompleted(); } currentPointerId = 0; }
private void PointerReleased(object sender, PointerRoutedEventArgs e) { //Debug.WriteLine("Released"); if (e.Pointer.PointerDeviceType == PointerDeviceType.Pen) { //Debug.WriteLine("Released"); PointerPoint pointerPoint = e.GetCurrentPoint(root); uint id = pointerPoint.PointerId; if (pointerDictionary.ContainsKey(id)) { // Give PointerPoint to InkManager inkManager.ProcessPointerUp(pointerPoint); if (inkManager.Mode == InkManipulationMode.Inking) { // Get rid of the little Line segments NewStrokeGrid.Children.Clear(); // Render the new stroke IReadOnlyList <InkStroke> inkStrokes = inkManager.GetStrokes(); InkStroke inkStroke = inkStrokes[inkStrokes.Count - 1]; if (IgnoreSmallStrokes && inkStroke.BoundingRect.Width < 10 && inkStroke.BoundingRect.Height < 10) { inkStroke.Selected = true; inkManager.DeleteSelected(); } else { RenderStroke(inkStroke); } } pointerDictionary.Remove(id); if (StrokeAdded != null) { StrokeAdded(inkManager); } } e.Handled = true; } }
public void InkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == pointerId) { try { PointerPoint pt = e.GetCurrentPoint(inkCanvas); inkManager.ProcessPointerUp(pt); pointerId = -1; renderer.ExitLiveRendering(pt); renderer.AddInk(inkManager.GetStrokes()[inkManager.GetStrokes().Count - 1]); } catch (Exception ex) { status.Log(ex.Message); } } }
private void inkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == penId) { var pt = e.GetCurrentPoint(inkCanvas); inkManager.ProcessPointerUp(pt); } else { //handle touch } penId = 0; e.Handled = true; }
// </SnippetPointerMovedHandler> // Finish capturing ink data and use it to render ink strokes on // the canvas. // <SnippetPointerReleasedHandler> public void InkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == _penID) { PointerPoint pt = e.GetCurrentPoint(InkCanvas); // Pass the pointer information to the InkManager. _inkManager.ProcessPointerUp(pt); } else if (e.Pointer.PointerId == _touchID) { // Process touch input } _touchID = 0; _penID = 0; // Call an application-defined function to render the ink strokes. RenderAllStrokes(); e.Handled = true; }
void InkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { string log = "Released"; OutputPointerData(e, log); press = false; if (e.Pointer.PointerId == _PenID) { _PenID = 0; try { inkManager.ProcessPointerUp(e.GetCurrentPoint(InkCanvas)); } catch { return; } } e.Handled = true; }
private void HandlePenUp(PointerRoutedEventArgs e) { //Get a pointer point relative to the inkCanvas PointerPoint pointerPoint = e.GetCurrentPoint(this.inkCanvas); //Use the InkManager to process the pointer up event m_inkMan.ProcessPointerUp(pointerPoint); //Stop live stroke rendering m_renderer.FinishRendering(pointerPoint); //Get all of the InkManger's strokes IReadOnlyList <InkStroke> strokes = m_inkMan.GetStrokes(); //Get the last stroke's index int lastStrokeIndex = strokes.Count - 1; //check if the last index is valid and add a permanent ink rendering using the local InkAttributes if (lastStrokeIndex >= 0) { m_renderer.AddPermaInk(strokes[lastStrokeIndex], m_inkAttr); } //Clear the active pointer id m_activePointerId = 0; //Mark the event as handled e.Handled = true; }
void canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == PenID || e.Pointer.PointerId == TouchID) { MyInkManager.ProcessPointerUp(e.GetCurrentPoint(canvas)); } TouchID = 0; PenID = 0; e.Handled = true; Pencil = null; NewLine = null; NewRectangle = null; NewEllipse = null; //to draw line on our writable bitmap not on canvas. if (itisline) { wb.DrawLineDDA((int)lineX1, (int)lineY1, (int)lineX2, (int)lineY2, clr); } //to draw line on our actual rectangle. if (itisrectangle) { if (rectX2 > rectX1 && rectY2 > rectY1) { wb.DrawRectangle((int)rectX1, (int)rectY1, (int)rectX2, (int)rectY2, clr); } else if (rectX2 < rectX1 && rectY2 < rectY1) { wb.DrawRectangle((int)rectX2, (int)rectY2, (int)rectX1, (int)rectY1, clr); } else if (rectX2 > rectX1 && rectY2 < rectY1) { wb.DrawRectangle((int)rectX1, (int)rectY2, (int)rectX2, (int)rectY1, clr); } else if (rectX2 < rectX1 && rectY2 > rectY1) { wb.DrawRectangle((int)rectX2, (int)rectY1, (int)rectX1, (int)rectY2, clr); } } // to draw a ellipse if (itisellipse) { if (elipX2 > elipX1 && elipY2 > elipY1) { wb.DrawEllipse((int)elipX1, (int)elipY1, (int)elipX2, (int)elipY2, clr); } else if (elipX2 < elipX1 && elipY2 < elipY1) { wb.DrawEllipse((int)elipX2, (int)elipY2, (int)elipX1, (int)elipY1, clr); } else if (elipX2 > elipX1 && elipY2 < elipY1) { wb.DrawEllipse((int)elipX1, (int)elipY2, (int)elipX2, (int)elipY1, clr); } else if (elipX2 < elipX1 && elipY2 > elipY1) { wb.DrawEllipse((int)elipX2, (int)elipY1, (int)elipX1, (int)elipY2, clr); } } }
protected override void OnPointerReleased(PointerRoutedEventArgs args) { if (args.Pointer.PointerDeviceType != PointerDeviceType.Pen && hasPen) { return; } inkManager.ProcessPointerUp(args.GetCurrentPoint(this)); // Render the most recent InkStroke IReadOnlyList <InkStroke> inkStrokes = inkManager.GetStrokes(); InkStroke inkStroke = inkStrokes[inkStrokes.Count - 1]; // Create SolidColorBrush used for all segments in the stroke Brush brush = new SolidColorBrush(inkStroke.DrawingAttributes.Color); // Get the segments IReadOnlyList <InkStrokeRenderingSegment> inkSegments = inkStroke.GetRenderingSegments(); // Notice loop starts at 1 for (int i = 1; i < inkSegments.Count; i++) { InkStrokeRenderingSegment inkSegment = inkSegments[i]; // Create a BezierSegment from the points BezierSegment bezierSegment = new BezierSegment { Point1 = inkSegment.BezierControlPoint1, Point2 = inkSegment.BezierControlPoint2, Point3 = inkSegment.Position }; // Create a PathFigure that begins at the preceding Position PathFigure pathFigure = new PathFigure { StartPoint = inkSegments[i - 1].Position, IsClosed = false, IsFilled = false }; pathFigure.Segments.Add(bezierSegment); // Create a PathGeometry with that PathFigure PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(pathFigure); // Create a Path with that PathGeometry Path path = new Path { Stroke = brush, StrokeThickness = inkStroke.DrawingAttributes.Size.Width * inkSegment.Pressure, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, Data = pathGeometry }; // Add it to the Grid contentGrid.Children.Add(path); } base.OnPointerReleased(args); }