Пример #1
0
        // throws ArgumentException if pointerPoint.pointerId is already in live rendering mode
        public void EnterLiveRendering(Windows.UI.Input.PointerPoint pointerPoint, Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes)
        {
            uint pointerId = pointerPoint.PointerId;

            // Create and initialize the data structures necessary to render a polyline in XAML.
            var stroke = new Windows.UI.Xaml.Media.PolyLineSegment();

            stroke.Points.Add(pointerPoint.Position);
            var figure = new Windows.UI.Xaml.Media.PathFigure();

            figure.StartPoint = pointerPoint.Position;
            figure.Segments.Add(stroke);
            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(drawingAttributes.Color);
            path.StrokeThickness    = drawingAttributes.Size.Width;
            path.StrokeLineJoin     = Windows.UI.Xaml.Media.PenLineJoin.Round;
            path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round;

            // Update dictionaries
            liveStrokes.Add(pointerId, stroke); // throws ArgumentException if pointerId is already in the dictionary
            livePaths.Add(pointerId, path);     // throws ArgumentException if pointerId is already in the dictionary

            // Add path to render so that it is rendered (on top of all the elements with same ZIndex).
            // We want the live render to be on top of the Bezier render, so we set the ZIndex of the elements of the
            // live render to 2 and that of the elements of the Bezier render to 1.
            render.Children.Add(path);
            Windows.UI.Xaml.Controls.Canvas.SetZIndex(path, 2);
        }
        // throws ArgumentException if pointerPoint.pointerId is already in live rendering mode
        public void EnterLiveRendering(Windows.UI.Input.PointerPoint pointerPoint, Windows.UI.Input.Inking.InkDrawingAttributes drawingAttributes)
        {
            uint pointerId = pointerPoint.PointerId;

            // Create and initialize the data structures necessary to render a polyline in XAML.
            var stroke = new Windows.UI.Xaml.Media.PolyLineSegment();
            stroke.Points.Add(pointerPoint.Position);
            var figure = new Windows.UI.Xaml.Media.PathFigure();
            figure.StartPoint = pointerPoint.Position;
            figure.Segments.Add(stroke);
            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(drawingAttributes.Color);
            path.StrokeThickness = drawingAttributes.Size.Width;
            path.StrokeLineJoin = Windows.UI.Xaml.Media.PenLineJoin.Round;
            path.StrokeStartLineCap = Windows.UI.Xaml.Media.PenLineCap.Round;

            // Update dictionaries
            liveStrokes.Add(pointerId, stroke); // throws ArgumentException if pointerId is already in the dictionary
            livePaths.Add(pointerId, path);     // throws ArgumentException if pointerId is already in the dictionary

            // Add path to render so that it is rendered (on top of all the elements with same ZIndex).
            // We want the live render to be on top of the Bezier render, so we set the ZIndex of the elements of the
            // live render to 2 and that of the elements of the Bezier render to 1.
            render.Children.Add(path);
            Windows.UI.Xaml.Controls.Canvas.SetZIndex(path, 2);
        }