private void panelcanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { // Get information about the pointer location. PointerPoint pt = e.GetCurrentPoint(PanelCanvas); _previousContactPt = pt.Position; // Accept input only from a pen or mouse with the left button pressed. PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; if (pointerDevType == PointerDeviceType.Pen || pointerDevType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } else if (pointerDevType == PointerDeviceType.Touch) { // Process touch input _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } }
/// <summary> /// The pointer pressed event handler /// </summary> /// <param name="sender">the sender object</param> /// <param name="e">The pointer pressed event args</param> private void inkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { //Break if we already have an active pointer if (m_activePointerId != 0) { return; } //We only handle pen input here so we check the device type if ((e.Pointer.PointerDeviceType == PointerDeviceType.Pen || e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) && e.Pointer.IsInContact) { //Get a pointer point relative to the inkCanvas PointerPoint pointerPoint = e.GetCurrentPoint(this.inkCanvas); //Begin live stroke rendering at the pointerPoint's position m_renderer.StartRendering(pointerPoint, m_inkAttr); //Set the InkManager's mode to inking m_inkMan.Mode = InkManipulationMode.Inking; //Use the InkManager to process the pointer down event m_inkMan.ProcessPointerDown(pointerPoint); //Set the pointer device id as the currently active pointer id m_activePointerId = e.Pointer.PointerId; //Mark the event as handled e.Handled = true; } }
protected override void OnPointerPressed(PointerRoutedEventArgs args) { if (args.Pointer.PointerDeviceType == PointerDeviceType.Pen || !hasPen) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(this); uint id = pointerPoint.PointerId; // Initialize for inking or erasing if (!pointerPoint.Properties.IsEraser) { inkManager.Mode = InkManipulationMode.Inking; } else { inkManager.Mode = InkManipulationMode.Erasing; } // Give PointerPoint to InkManager inkManager.ProcessPointerDown(pointerPoint); // Add an entry to the dictionary pointerDictionary.Add(args.Pointer.PointerId, pointerPoint.Position); // Capture the pointer CapturePointer(args.Pointer); } base.OnPointerPressed(args); }
private void PointerPressed(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerDeviceType == PointerDeviceType.Pen && e.Pointer.IsInContact) { //Debug.WriteLine("Pressed"); PointerPoint pointerPoint = e.GetCurrentPoint(root); if (!pointerPoint.Properties.IsEraser) { inkManager.Mode = InkManipulationMode.Inking; } else { inkManager.Mode = InkManipulationMode.Erasing; } if (pointerDictionary.ContainsKey(e.Pointer.PointerId)) { pointerDictionary[e.Pointer.PointerId] = pointerPoint.Position; } else { inkManager.ProcessPointerDown(pointerPoint); } pointerDictionary[e.Pointer.PointerId] = pointerPoint.Position; e.Handled = true; boundingRect = new Rect() { X = pointerPoint.Position.X, Y = pointerPoint.Position.Y, Width = 0, Height = 0 }; } }
private void OnCanvasPointerPressed(object sender, PointerRoutedEventArgs e) { if (!IsInputEnabled) { return; } if (currentPointerId != 0) { // we only handle a single "pen" at a time return; } var pointerDevice = e.Pointer.PointerDeviceType; var pointerPoint = e.GetCurrentPoint(this); // accept pen, touch and left mouse if (pointerDevice != PointerDeviceType.Mouse || pointerPoint.Properties.IsLeftButtonPressed) { currentPointerId = pointerPoint.PointerId; CapturePointer(e.Pointer); inkManager.ProcessPointerDown(pointerPoint); // update the visual var geo = new PathGeometry(); geo.MoveTo(pointerPoint.Position.X, pointerPoint.Position.Y); tempPathShape.Data = geo; SetPathProperties(tempPathShape); } }
public void InkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { try { // Get information about the pointer location. PointerPoint pt = e.GetCurrentPoint(InkCanvas); _previousContactPt = pt.Position; // Accept input only from a pen or mouse with the left button pressed. PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; if (pointerDevType == PointerDeviceType.Pen || pointerDevType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } else if (pointerDevType == PointerDeviceType.Touch) { // Process touch input } } catch (Exception ex) { MessageDialog msg = new MessageDialog(ex.Message + " Void - InkCanvas_PointerPressed"); //msg.ShowAsync(); } }
protected override void OnPointerPressed(PointerRoutedEventArgs args) { if (args.Pointer.PointerDeviceType == PointerDeviceType.Pen || !hasPen) { PointerPoint pointerPoint = args.GetCurrentPoint(this); inkManager.ProcessPointerDown(pointerPoint); } base.OnPointerPressed(args); }
protected override void OnPointerPressed(PointerRoutedEventArgs args) { if (args.Pointer.PointerDeviceType == PointerDeviceType.Pen || !hasPen) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(this); // アプリバーで消去と選択ができるように手を加えています // マウスの右クリックで描画しないようにしています。アプリバーを表示。 if ((!hasPen) && (pointerPoint.Properties.IsRightButtonPressed)) { base.OnPointerPressed(args); return; } uint id = pointerPoint.PointerId; // アプリバーで消去と選択ができるように手を加えています // Initialize for erasing, selecting, or inking if (pointerPoint.Properties.IsEraser || inkManager.Mode == InkManipulationMode.Erasing) { inkManager.Mode = InkManipulationMode.Erasing; } else if (pointerPoint.Properties.IsBarrelButtonPressed || inkManager.Mode == InkManipulationMode.Selecting) { inkManager.Mode = InkManipulationMode.Selecting; // Create Polyline for showing enclosure Polyline polyline = new Polyline { Stroke = selectionBrush, StrokeThickness = 1 }; polyline.Points.Add(pointerPoint.Position); newLineGrid.Children.Add(polyline); } else { inkManager.Mode = InkManipulationMode.Inking; } // Give PointerPoint to InkManager inkManager.ProcessPointerDown(pointerPoint); // Add an entry to the dictionary pointerDictionary.Add(args.Pointer.PointerId, pointerPoint.Position); // Capture the pointer CapturePointer(args.Pointer); } base.OnPointerPressed(args); }
void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (DrawingTool != "Eraser") { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Cross, 1); } else { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1); } Canvas canvas = sender as Canvas; InkManager inkManager = MedcialInkManager; switch (DrawingTool) { case "Pencil": { var MyDrawingAttributes = new InkDrawingAttributes(); MyDrawingAttributes.Size = new Size(StrokeThickness, StrokeThickness); MyDrawingAttributes.Color = BorderColor; MyDrawingAttributes.FitToCurve = true; inkManager.SetDefaultDrawingAttributes(MyDrawingAttributes); PreviousContactPoint = e.GetCurrentPoint(canvas).Position; if (e.GetCurrentPoint(canvas).Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. inkManager.ProcessPointerDown(e.GetCurrentPoint(canvas)); PenID = e.GetCurrentPoint(canvas).PointerId; e.Handled = true; } } break; case "Eraser": { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1); StartPoint = e.GetCurrentPoint(canvas).Position; Pencil = new Polyline(); Pencil.Stroke = new SolidColorBrush(Colors.White); Pencil.StrokeThickness = 10; canvas.Children.Add(Pencil); } break; default: break; } }
public void InkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (pointerId == -1) { try { PointerPoint pt = e.GetCurrentPoint(inkCanvas); renderer.EnterLiveRendering(pt, drawingAttributes); inkManager.ProcessPointerDown(pt); pointerId = (int)pt.PointerId; } catch (Exception ex) { status.Log(ex.Message); } } }
protected override void OnPointerPressed(PointerRoutedEventArgs args) { if (args.Pointer.PointerDeviceType == PointerDeviceType.Pen) { // Get information PointerPoint pointerPoint = args.GetCurrentPoint(sheetPanel); uint id = pointerPoint.PointerId; InkManager inkManager = this.InkFileManager.InkManager; // Initialize for inking, erasing, or selecting if (pointerPoint.Properties.IsEraser) { inkManager.Mode = InkManipulationMode.Erasing; this.InkFileManager.UnselectAll(); } else if (pointerPoint.Properties.IsBarrelButtonPressed) { inkManager.Mode = InkManipulationMode.Selecting; // Create Polyline for showing enclosure Polyline polyline = new Polyline { Stroke = selectionBrush, StrokeThickness = 1 }; polyline.Points.Add(pointerPoint.Position); newLineGrid.Children.Add(polyline); } else { inkManager.Mode = InkManipulationMode.Inking; this.InkFileManager.UnselectAll(); } // Give PointerPoint to InkManager inkManager.ProcessPointerDown(pointerPoint); // Add an entry to the dictionary pointerDictionary.Add(args.Pointer.PointerId, pointerPoint.Position); // Capture the pointer this.CapturePointer(args.Pointer); } base.OnPointerPressed(args); }
private void inkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { var pt = e.GetCurrentPoint(inkCanvas); startPoint = pt.Position; //check pointer is a pen/stylus or mouse with left click if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen || (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) ) { penId = pt.PointerId; inkManager.ProcessPointerDown(pt); } else { //handle touch } e.Handled = true; }
public void PointerPressed(object sender, PointerRoutedEventArgs e) { //Where are we? PointerPoint pt = e.GetCurrentPoint(DrawingCanvas); _previousContactPt = pt.Position; //When drawing with a mouse device, only draw if the left button is pressed PointerDeviceType pointerDeviceType = e.Pointer.PointerDeviceType; if (pointerDeviceType == PointerDeviceType.Pen || pointerDeviceType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { _inkManager.ProcessPointerDown(pt); _penID = pt.PointerId; e.Handled = true; } else if (pointerDeviceType == PointerDeviceType.Touch) { //Process touch input } }
private void OnMouseDownCanvas(object sender, PointerRoutedEventArgs e) //Event Handler When The Mouse Is Pressed On The White Canvas { try { BrushSizeHandler(); //Handles The Size Of The Brush PointerDeviceType pointerType = e.Pointer.PointerDeviceType; //For Determining The Pointer Type (Touch or Mouse) PointerPoint pt = e.GetCurrentPoint(InkCanvas); //Get The Current Position Of The Cursor previousPosition = pt.Position; //Register The Position Of The Cursor When Pressed if (pointerType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { //For Checking If Pointer Is Mouse And If Left Clicked inkManager.ProcessPointerDown(pt); //For Processing The Click Event pointerId = pt.PointerId; //Register The Pointer Id e.Handled = true; //Tell Event Is Success } } catch (Exception ex) { } }
void InkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { string log = "Pressed"; OutputPointerData(e, log); press = true; PointerPoint po = e.GetCurrentPoint(InkCanvas); if (po.PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) { _PenID = po.PointerId; _PrevPoint = po.Position; if (po.Properties.IsEraser) { // 消しゴムモード inkManager.Mode = InkManipulationMode.Erasing; } else { // ペンモード inkManager.Mode = InkManipulationMode.Inking; } try { inkManager.ProcessPointerDown(po); } catch { return; } } e.Handled = true; }
public void OnCanvasPointerPressed(object sender, PointerRoutedEventArgs e) { // Get information about the pointer location. PointerPoint pt = e.GetCurrentPoint(InkCanvas); _previousContactPt = pt.Position; // Accept input only from a pen or mouse with the left button pressed. PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; if (pointerDevType == PointerDeviceType.Pen || pointerDevType == PointerDeviceType.Mouse && pt.Properties.IsLeftButtonPressed) { if (m_CurrentMode == "Erase") { System.Diagnostics.Debug.WriteLine("Erasing : Pointer Pressed"); m_InkManager.ProcessPointerDown(pt); } else { // Pass the pointer information to the InkManager. CurrentManager.ProcessPointerDown(pt); } m_PenId = pt.PointerId; e.Handled = true; } else if (pointerDevType == PointerDeviceType.Touch) { // Process touch input } }
void canvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (DrawingTool != "Eraser") { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Cross, 1); } else { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1); } switch (DrawingTool) { //all events are working on canvas.. we will be collecting points to draw on writablebitmap also. case "Line": { NewLine = new Line(); NewLine.X1 = e.GetCurrentPoint(canvas).Position.X; NewLine.Y1 = e.GetCurrentPoint(canvas).Position.Y; lineX1 = e.GetCurrentPoint(canvas).Position.X; lineY1 = e.GetCurrentPoint(canvas).Position.Y; NewLine.X2 = NewLine.X1 + 1; NewLine.Y2 = NewLine.Y1 + 1; NewLine.StrokeThickness = StrokeThickness; NewLine.Stroke = new SolidColorBrush(BorderColor); canvas.Children.Add(NewLine); } break; case "Pencil": { /* Old Code * StartPoint = e.GetCurrentPoint(canvas).Position; * Pencil = new Polyline(); * Pencil.Stroke = new SolidColorBrush(BorderColor); * Pencil.StrokeThickness = StrokeThickness; * canvas.Children.Add(Pencil); */ var MyDrawingAttributes = new InkDrawingAttributes(); MyDrawingAttributes.Size = new Size(StrokeThickness, StrokeThickness); MyDrawingAttributes.Color = BorderColor; MyDrawingAttributes.FitToCurve = true; MyInkManager.SetDefaultDrawingAttributes(MyDrawingAttributes); PreviousContactPoint = e.GetCurrentPoint(canvas).Position; //PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; to identify the pointer device if (e.GetCurrentPoint(canvas).Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. MyInkManager.ProcessPointerDown(e.GetCurrentPoint(canvas)); PenID = e.GetCurrentPoint(canvas).PointerId; e.Handled = true; } } break; case "Rectagle": { NewRectangle = new Rectangle(); X1 = e.GetCurrentPoint(canvas).Position.X; Y1 = e.GetCurrentPoint(canvas).Position.Y; X2 = X1; Y2 = Y1; NewRectangle.Width = X2 - X1; NewRectangle.Height = Y2 - Y1; rectX1 = X1; rectY1 = Y1; NewRectangle.StrokeThickness = StrokeThickness; NewRectangle.Stroke = new SolidColorBrush(BorderColor); // NewRectangle.Fill = new SolidColorBrush(FillColor); canvas.Children.Add(NewRectangle); } break; case "Ellipse": { NewEllipse = new Ellipse(); X1 = e.GetCurrentPoint(canvas).Position.X; Y1 = e.GetCurrentPoint(canvas).Position.Y; X2 = X1; Y2 = Y1; elipX1 = X1; elipY1 = Y1; NewEllipse.Width = X2 - X1; NewEllipse.Height = Y2 - Y1; NewEllipse.StrokeThickness = StrokeThickness; NewEllipse.Stroke = new SolidColorBrush(BorderColor); //NewEllipse.Fill = new SolidColorBrush(FillColor); canvas.Children.Add(NewEllipse); } break; case "Eraser": { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1); StartPoint = e.GetCurrentPoint(canvas).Position; Pencil = new Polyline(); Pencil.Stroke = new SolidColorBrush(Colors.Wheat); Pencil.StrokeThickness = 10; canvas.Children.Add(Pencil); } break; default: break; } }
void canvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (DrawingTool != "Eraser") { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Cross, 1); } else { Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.UniversalNo, 1); } switch (DrawingTool) { case "Line": { NewLine = new Line(); NewLine.X1 = e.GetCurrentPoint(canvas).Position.X; NewLine.Y1 = e.GetCurrentPoint(canvas).Position.Y; NewLine.X2 = NewLine.X1 + 1; NewLine.Y2 = NewLine.Y1 + 1; NewLine.StrokeThickness = StrokeThickness; NewLine.Stroke = new SolidColorBrush(BorderColor); canvas.Children.Add(NewLine); } break; case "Pencil": { var MyDrawingAttributes = new InkDrawingAttributes(); MyDrawingAttributes.Size = new Size(StrokeThickness, StrokeThickness); MyDrawingAttributes.Color = BorderColor; MyDrawingAttributes.FitToCurve = true; MyInkManager.SetDefaultDrawingAttributes(MyDrawingAttributes); PreviousContactPoint = e.GetCurrentPoint(canvas).Position; //PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; to identify the pointer device if (e.GetCurrentPoint(canvas).Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. MyInkManager.ProcessPointerDown(e.GetCurrentPoint(canvas)); PenID = e.GetCurrentPoint(canvas).PointerId; e.Handled = true; } } break; case "Rectagle": { NewRectangle = new Rectangle(); X1 = e.GetCurrentPoint(canvas).Position.X; Y1 = e.GetCurrentPoint(canvas).Position.Y; X2 = X1; Y2 = Y1; NewRectangle.Width = X2 - X1; NewRectangle.Height = Y2 - Y1; NewRectangle.StrokeThickness = StrokeThickness; NewRectangle.Stroke = new SolidColorBrush(BorderColor); NewRectangle.Fill = new SolidColorBrush(FillColor); canvas.Children.Add(NewRectangle); } break; case "Ellipse": { NewEllipse = new Ellipse(); X1 = e.GetCurrentPoint(canvas).Position.X; Y1 = e.GetCurrentPoint(canvas).Position.Y; X2 = X1; Y2 = Y1; NewEllipse.Width = X2 - X1; NewEllipse.Height = Y2 - Y1; NewEllipse.StrokeThickness = StrokeThickness; NewEllipse.Stroke = new SolidColorBrush(BorderColor); NewEllipse.Fill = new SolidColorBrush(FillColor); canvas.Children.Add(NewEllipse); } break; case "Eraser": { var MyDrawingAttributes = new InkDrawingAttributes(); MyDrawingAttributes.Size = new Size(10, 10); MyDrawingAttributes.Color = Colors.White; MyDrawingAttributes.FitToCurve = true; MyInkManager.SetDefaultDrawingAttributes(MyDrawingAttributes); PreviousContactPoint = e.GetCurrentPoint(canvas).Position; //PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType; to identify the pointer device if (e.GetCurrentPoint(canvas).Properties.IsLeftButtonPressed) { // Pass the pointer information to the InkManager. MyInkManager.ProcessPointerDown(e.GetCurrentPoint(canvas)); PenID = e.GetCurrentPoint(canvas).PointerId; e.Handled = true; } } break; default: break; } }