Friday, January 31, 2014

1 finger to draw, 2 fingers to pan, zoom, and drag?

See Move and draw commands syntax to understand what the Data path means. That document explains how each command (e.g. "M", "A", "C") maps to a specific class. For example, "A" is an arc and can be represented with an ArcSegment in your PathGeometry. "C" is a cubic Bezier and can be represented with a BezierSegment, etc.


Based on this you can unwind the Data string something like (untested):



// A Size RotationAngle isLargeArc SweepDirection EndPoint
var arc = new ArcSegment();
arc.Size = new Size(1,1);
arc.RotationAngle = 0;
arc.IsLargeArc = false;
arc.SweepDirection = SweepDirection.Counterclockwise;
arc.Point = new Point(1,9);

// C controlPoint1 controlPoint2 endPoint
var cubicBezier = new BezierSegment();
cubicBezier.Point1 = new Point(1, 10);
cubicBezier.Point2 = new Point(1, 0);
cubicBezier.Point3 = new Point(1, 0);

var figure = new PathFigure();
figure.StartPoint = new Point(1, 0); // M 1,0
figure.Segments.Add(arc); // A 1,1 0 0 0 1,9
figure.Segments.Add(cubicBezier); // C 1,10 1,0 1,0

var pathGeometry = new PathGeometry();
pathGeometry.Figures.Add(figure);

Windows.UI.Xaml.Shapes.Path p = new Windows.UI.Xaml.Shapes.Path();
p.Data = pathGeometry;
p.Stretch = Stretch.Fill;
p.Stroke = Resources["PathBrush"] as Brush;
p.StrokeThickness = 1;
p.UseLayoutRounding = false;
p.Width = 26;

--Rob


No comments:

Post a Comment