public static Windows.UI.Xaml.Shapes.Path CreateBezierPath(Windows.UI.Input.Inking.InkStroke stroke) { // Create Bezier geometries using information provided by the stroke's segments var figure = new Windows.UI.Xaml.Media.PathFigure(); var segments = stroke.GetRenderingSegments().GetEnumerator(); segments.MoveNext(); // First segment is degenerate and corresponds to initial position figure.StartPoint = segments.Current.Position; // Now loop through all remaining segments while (segments.MoveNext()) { var bs = new Windows.UI.Xaml.Media.BezierSegment(); bs.Point1 = segments.Current.BezierControlPoint1; bs.Point2 = segments.Current.BezierControlPoint2; bs.Point3 = segments.Current.Position; figure.Segments.Add(bs); } // Create and initialize the data structures necessary to render the figure var geometry = new Windows.UI.Xaml.Media.PathGeometry(); geometry.Figures.Add(figure); var path = new Windows.UI.Xaml.Shapes.Path(); path.Data = geometry; // Set the stroke's graphical properties, which are controlled by the Path object path.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(stroke.DrawingAttributes.Color); path.StrokeThickness = stroke.DrawingAttributes.Size.Width; path.StrokeLineJoin = Windows.UI.Xaml.Media.PenLineJoin.Round; path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round; return(path); }
public static Windows.UI.Xaml.Shapes.Path CreateBezierPath(Windows.UI.Input.Inking.InkStroke stroke) { // Create Bezier geometries using information provided by the stroke's segments var figure = new Windows.UI.Xaml.Media.PathFigure(); var segments = stroke.GetRenderingSegments().GetEnumerator(); segments.MoveNext(); // First segment is degenerate and corresponds to initial position figure.StartPoint = segments.Current.Position; // Now loop through all remaining segments while (segments.MoveNext()) { var bs = new Windows.UI.Xaml.Media.BezierSegment(); bs.Point1 = segments.Current.BezierControlPoint1; bs.Point2 = segments.Current.BezierControlPoint2; bs.Point3 = segments.Current.Position; figure.Segments.Add(bs); } // Create and initialize the data structures necessary to render the figure var geometry = new Windows.UI.Xaml.Media.PathGeometry(); geometry.Figures.Add(figure); var path = new Windows.UI.Xaml.Shapes.Path(); path.Data = geometry; // Set the stroke's graphical properties, which are controlled by the Path object path.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(stroke.DrawingAttributes.Color); path.StrokeThickness = stroke.DrawingAttributes.Size.Width; path.StrokeLineJoin = Windows.UI.Xaml.Media.PenLineJoin.Round; path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round; return path; }