Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LineRenderer : DynamicRenderer
- {
- private Point firstPoint;
- private Pen pen = new Pen(new SolidColorBrush(Colors.Gray),1);
- public LineRenderer()
- {
- firstPoint = new Point(double.PositiveInfinity, double.PositiveInfinity);
- }
- protected override void OnStylusDown(RawStylusInput rawStylusInput)
- {
- firstPoint = new Point(rawStylusInput.GetStylusPoints().First().ToPoint().X, rawStylusInput.GetStylusPoints().First().ToPoint().Y);
- base.OnStylusDown(rawStylusInput);
- }
- protected override void OnDraw(DrawingContext drawingContext,
- StylusPointCollection stylusPoints,
- Geometry geometry, Brush fillBrush)
- {
- drawingContext.DrawLine(pen, firstPoint, stylusPoints.First().ToPoint());
- }
- protected override void OnStylusUp(RawStylusInput rawStylusInput)
- {
- firstPoint = new Point(double.PositiveInfinity, double.PositiveInfinity);
- base.OnStylusUp(rawStylusInput);
- }
- }
- protected override void OnDraw(DrawingContext drawingContext,
- StylusPointCollection stylusPoints,
- Geometry geometry, Brush fillBrush)
- {
- drawingContext.DrawLine(pen, firstPoint, stylusPoints.First().ToPoint());
- firstPoint = stylusPoints.First().ToPoint();
- }
- protected override void OnDraw(DrawingContext drawingContext,
- StylusPointCollection stylusPoints,
- Geometry geometry, Brush fillBrush)
- {
- if (!_isManipulating)
- {
- _isManipulating = true;
- StylusDevice currentStylus = Stylus.CurrentStylusDevice;
- this.Reset(currentStylus, stylusPoints);
- }
- _isManipulating = false;
- var pen = new Pen(brush, 2);
- drawingContext.DrawLine(pen, startPoint,stylusPoints.First().ToPoint());
- }
- protected override void OnStylusDown(RawStylusInput rawStylusInput)
- {
- StylusPointCollection y = rawStylusInput.GetStylusPoints();
- startPoint = (Point)y.First();
- // Allocate memory to store the previous point to draw from.
- prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
- base.OnStylusDown(rawStylusInput);
- }
Add Comment
Please, Sign In to add comment