Guest User

Untitled

a guest
Feb 17th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. class LineRenderer : DynamicRenderer
  2. {
  3. private Point firstPoint;
  4. private Pen pen = new Pen(new SolidColorBrush(Colors.Gray),1);
  5.  
  6. public LineRenderer()
  7. {
  8. firstPoint = new Point(double.PositiveInfinity, double.PositiveInfinity);
  9. }
  10.  
  11. protected override void OnStylusDown(RawStylusInput rawStylusInput)
  12. {
  13. firstPoint = new Point(rawStylusInput.GetStylusPoints().First().ToPoint().X, rawStylusInput.GetStylusPoints().First().ToPoint().Y);
  14. base.OnStylusDown(rawStylusInput);
  15. }
  16.  
  17. protected override void OnDraw(DrawingContext drawingContext,
  18. StylusPointCollection stylusPoints,
  19. Geometry geometry, Brush fillBrush)
  20. {
  21. drawingContext.DrawLine(pen, firstPoint, stylusPoints.First().ToPoint());
  22. }
  23.  
  24. protected override void OnStylusUp(RawStylusInput rawStylusInput)
  25. {
  26. firstPoint = new Point(double.PositiveInfinity, double.PositiveInfinity);
  27. base.OnStylusUp(rawStylusInput);
  28. }
  29. }
  30.  
  31. protected override void OnDraw(DrawingContext drawingContext,
  32. StylusPointCollection stylusPoints,
  33. Geometry geometry, Brush fillBrush)
  34. {
  35. drawingContext.DrawLine(pen, firstPoint, stylusPoints.First().ToPoint());
  36. firstPoint = stylusPoints.First().ToPoint();
  37. }
  38.  
  39. protected override void OnDraw(DrawingContext drawingContext,
  40. StylusPointCollection stylusPoints,
  41. Geometry geometry, Brush fillBrush)
  42. {
  43. if (!_isManipulating)
  44. {
  45. _isManipulating = true;
  46. StylusDevice currentStylus = Stylus.CurrentStylusDevice;
  47. this.Reset(currentStylus, stylusPoints);
  48. }
  49. _isManipulating = false;
  50.  
  51. var pen = new Pen(brush, 2);
  52. drawingContext.DrawLine(pen, startPoint,stylusPoints.First().ToPoint());
  53. }
  54.  
  55.  
  56. protected override void OnStylusDown(RawStylusInput rawStylusInput)
  57. {
  58. StylusPointCollection y = rawStylusInput.GetStylusPoints();
  59. startPoint = (Point)y.First();
  60.  
  61. // Allocate memory to store the previous point to draw from.
  62. prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
  63. base.OnStylusDown(rawStylusInput);
  64. }
Add Comment
Please, Sign In to add comment