Inheritance: Geometry, IPathGeometry
Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Arc"/> class"
        /// </summary>
        public Arc()
        {
            this.Stroke = new SolidColorBrush(Colors.White);
            this.StrokeThickness = 2;
            this.Fill = new SolidColorBrush(Colors.Red);
            this.UseLayoutRounding = true;

            this.pathGeometry = new PathGeometry();
            this.pathFigure = new PathFigure();

            this.pathFigure.IsClosed = true;
            this.pathFigure.IsFilled = true;

            this.arcSegment = new ArcSegment();
            this.arcSegment.IsLargeArc = false;
            this.arcSegment.SweepDirection = SweepDirection.Clockwise;
            this.lineSegment = new LineSegment();

            this.pathFigure.Segments.Add(this.arcSegment);
            this.pathFigure.Segments.Add(this.lineSegment);

            this.pathGeometry.Figures.Add(this.pathFigure);
            this.Data = this.pathGeometry;

            this.ellipseGeometry = new EllipseGeometry();

            this.Tapped += this.OnArcTapped;
        }
        /// <summary>
        /// Main back conversion routine - converts PathGeometry object to its string equivalent
        /// </summary>
        /// <param name="geometry">Path Geometry object</param>
        /// <returns>String equivalent to PathGeometry contents</returns>
        public string ConvertBack(PathGeometry geometry)
        {
            if (geometry == null)
                throw new ArgumentException("Path Geometry cannot be null!", nameof(geometry));

            return ParseBack(geometry);
        }
        /// <summary>
        /// Main back conversion routine - converts PathGeometry object to its string equivalent
        /// </summary>
        /// <param name="geometry">Path Geometry object</param>
        /// <returns>String equivalent to PathGeometry contents</returns>
        public string ConvertBack(PathGeometry geometry)
        {
            if (null == geometry)
                throw new ArgumentException("Path Geometry cannot be null!");

            return ParseBack(geometry);
        }
Beispiel #4
0
        public static Path GetCircleSegment(Point centerPoint, double radius, double angle)
        {
            var path = new Path();
            var pathGeometry = new PathGeometry();

            var circleStart = new Point(centerPoint.X, centerPoint.Y - radius);

            var arcSegment = new ArcSegment
            {
                IsLargeArc = angle > 180.0,
                Point = ScaleUnitCirclePoint(centerPoint, angle, radius),
                Size = new Size(radius, radius),
                SweepDirection = SweepDirection.Clockwise
            };

            var pathFigure = new PathFigure
            {
                StartPoint = circleStart,
                IsClosed = false
            };

            pathFigure.Segments.Add(arcSegment);
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            return path;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Create the AppBarButton for the 'Triangle' command
            AppBarButton triangle = new AppBarButton();
            triangle.Label = "Triangle";

            // This button will use the PathIcon class for its icon which allows us to 
            // use vector data to represent the icon
            PathIcon trianglePathIcon = new PathIcon();
            PathGeometry g = new PathGeometry();
            g.FillRule = FillRule.Nonzero;

            // Just create a simple triange shape
            PathFigure f = new PathFigure();
            f.IsFilled = true;
            f.IsClosed = true;
            f.StartPoint = new Windows.Foundation.Point(20.0, 5.0);
            LineSegment s1 = new LineSegment();
            s1.Point = new Windows.Foundation.Point(30.0, 30.0);
            LineSegment s2 = new LineSegment();
            s2.Point = new Windows.Foundation.Point(10.0, 30.0);
            LineSegment s3 = new LineSegment();
            s3.Point = new Windows.Foundation.Point(20.0, 5.0);
            f.Segments.Add(s1);
            f.Segments.Add(s2);
            f.Segments.Add(s3);
            g.Figures.Add(f);

            trianglePathIcon.Data = g;

            triangle.Icon = trianglePathIcon;

            ((CommandBar)BottomAppBar).PrimaryCommands.Insert(2, triangle);
        }
        public Path GetCircleSegment(Point centrePoint, Point currentPoint, double radius, double stripWidth, double angle)
        {
            var path = new Path { Stroke = _strokeBrush };

            var pathGeometry = new PathGeometry();

            var circleStart = new Point(centrePoint.X, centrePoint.Y - radius);

            // Arc
            var arcSegment = new ArcSegment
            {
                IsLargeArc = angle > 180.0,
                Point = _mathHelper.ScaleUnitCirclePoint(centrePoint, angle, radius),
                Size = new Size(radius, radius),
                SweepDirection = SweepDirection.Clockwise
            };

            //The path figure includes first, the first line from the centre to line1End, then the arc
            var pathFigure = new PathFigure { StartPoint = circleStart, IsClosed = false };

            pathFigure.Segments.Add(arcSegment);
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            path.StrokeThickness = stripWidth;

            return path;
        }
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     PathGeometry geo = new PathGeometry();
     geo.Figures.Add(figure);
     path p = new path();
     p.Data = geo;
     p.Stroke = black;
     G.Children.Add(p);
 }
        public static void AddPathGeometry(
            this D2D.GeometrySink sink, Jupiter.Media.PathGeometry pathGeometry)
        {
            sink.SetFillMode(pathGeometry.FillRule.ToSharpDX());

            foreach (var childFigure in pathGeometry.Figures)
            {
                sink.AddPathFigure(childFigure);
            }
        }
Beispiel #9
0
        public PieSlice()
        {
            pathFigure = new PathFigure { IsClosed = false ,IsFilled = false};
            arcSegment = new ArcSegment { SweepDirection = SweepDirection.Clockwise };
            pathFigure.Segments.Add(arcSegment);

            PathGeometry pathGeometry = new PathGeometry();
            pathGeometry.Figures.Add(pathFigure);

            this.Data = pathGeometry;
            UpdateValues();
        }
Beispiel #10
0
 public Sticker(Point Location, Double Radius)
 {
     PathFigure figure = new PathFigure();
     PathGeometry geo = new PathGeometry();
     geo.Figures.Add(figure);
     this.Data = geo;
     this.Location = Location;
     this.Radius = Radius;
     this.Tapped += Sticker_Tapped;
     this.Holding += Sticker_Holding;
     this.ManipulationMode = Windows.UI.Xaml.Input.ManipulationModes.All;
 }
 public PathGeometry Pattern()
 {
     PathGeometry geo = new PathGeometry();
     PathFigure figure = new PathFigure();
     geo.Figures.Add(figure);
     figure.StartPoint = new Point(Info[0].X, Info[0].Y);
     for (int i = 0; i < Arcs; i++)
     {
         ArcData a = Info[(i + 1) % Arcs] as ArcData;
         figure.Segments.Add(new ArcSegment { Point = new Point(a.X, a.Y), Size = new Size(a.SizeX, a.SizeY), IsLargeArc = a.IsLarge, RotationAngle = a.Rotation, SweepDirection = a.SweepDirection });
     }
     return geo;
 }
Beispiel #12
0
        public PiePath()
        {
            pathFigure = new PathFigure { IsClosed = true };
            lineSegment = new LineSegment();
            arcSegment = new ArcSegment { SweepDirection = SweepDirection.Clockwise };
            pathFigure.Segments.Add(lineSegment);
            pathFigure.Segments.Add(arcSegment);

            PathGeometry pathGeometry = new PathGeometry();
            pathGeometry.Figures.Add(pathFigure);

            this.Data = pathGeometry;
            UpdateValues();
        }
Beispiel #13
0
        public void UpdatePath()
        {
            // ensure variables
            if (GetValue(StartAngleProperty) == DependencyProperty.UnsetValue)
                throw new ArgumentNullException("Start Angle is required");
            if (GetValue(RadiusProperty) == DependencyProperty.UnsetValue)
                throw new ArgumentNullException("Radius is required");
            if (GetValue(AngleProperty) == DependencyProperty.UnsetValue)
                throw new ArgumentNullException("Angle is required");

            Width = Height = 2 * (Radius + StrokeThickness);
            var endAngle = StartAngle + Angle;

            // path container
            var figureP = new Point(Radius, Radius);
            var figure = new PathFigure
            {
                StartPoint = figureP,
                IsClosed = true,
            };

            //  start angle line
            var lineX = Radius + Math.Sin(StartAngle * Math.PI / 180) * Radius;
            var lineY = Radius - Math.Cos(StartAngle * Math.PI / 180) * Radius;
            var lineP = new Point(lineX, lineY);
            var line = new LineSegment { Point = lineP };
            figure.Segments.Add(line);

            // outer arc
            var arcX = Radius + Math.Sin(endAngle * Math.PI / 180) * Radius;
            var arcY = Radius - Math.Cos(endAngle * Math.PI / 180) * Radius;
            var arcS = new Size(Radius, Radius);
            var arcP = new Point(arcX, arcY);
            var arc = new ArcSegment
            {
                IsLargeArc = Angle >= 180.0,
                Point = arcP,
                Size = arcS,
                SweepDirection = SweepDirection.Clockwise,
            };
            figure.Segments.Add(arc);

            // finalé
            Data = new PathGeometry { Figures = { figure } };
            InvalidateArrange();
        }
        public void SetMouth()
        {
            int index = _laugh ? 0 : 1;

            var figure = new PathFigure() { StartPoint = _mouthPoints[index, 0] };
            figure.Segments = new PathSegmentCollection();
            var segment1 = new QuadraticBezierSegment();
            segment1.Point1 = _mouthPoints[index, 1];
            segment1.Point2 = _mouthPoints[index, 2];
            figure.Segments.Add(segment1);
            var geometry = new PathGeometry();
            geometry.Figures = new PathFigureCollection();
            geometry.Figures.Add(figure);

            mouth.Data = geometry;
            _laugh = !_laugh;
        }
        private static PathGeometry CloneDeep(PathGeometry pathGeometry)
        {
            var newPathGeometry = new PathGeometry();
            foreach (var figure in pathGeometry.Figures)
            {
                var newFigure = new PathFigure();
                newFigure.StartPoint = figure.StartPoint;
                foreach (var segment in figure.Segments)
                {
                    var segmentAsPolyLineSegment = segment as PolyLineSegment;
                    if (segmentAsPolyLineSegment != null)
                    {
                        var newSegment = new PolyLineSegment();
                        foreach (var point in segmentAsPolyLineSegment.Points)
                        {
                            newSegment.Points.Add(point);
                        }
                        newFigure.Segments.Add(newSegment);
                    }

                    var segmentLineSegment = segment as LineSegment;
                    if (segmentLineSegment != null)
                    {
                        var newSegment = new LineSegment();
                        newSegment.Point = new Point(segmentLineSegment.Point.X, segmentLineSegment.Point.Y);
                        newFigure.Segments.Add(newSegment);
                    }

                    var segmentBezierSegment = segment as BezierSegment;
                    if (segmentBezierSegment != null)
                    {
                        var newSegment = new BezierSegment();
                        newSegment.Point1 = new Point(segmentBezierSegment.Point1.X, segmentBezierSegment.Point1.Y);
                        newSegment.Point2 = new Point(segmentBezierSegment.Point2.X, segmentBezierSegment.Point2.Y);
                        newSegment.Point3 = new Point(segmentBezierSegment.Point3.X, segmentBezierSegment.Point3.Y);
                        newFigure.Segments.Add(newSegment);
                    }
                }

                newPathGeometry.Figures.Add(newFigure);
            }
            return newPathGeometry;
        }
Beispiel #16
0
        private Path MkPath(double indx, double increment)
        {
            Path path = new Path();
            path.Stroke = new SolidColorBrush(Colors.Red);
            path.Name = string.Format("Braid{0}", indx);
            path.Tag = indx;

            GeometryGroup g = new GeometryGroup();
            path.Data = g;
            PathGeometry pg = new PathGeometry();
            g.Children.Add(pg);

            //pg.Figures.Add(BuildStrand(indx * repeatAngle, 0, increment));
            for (int i = 0; i < bd.NumStrands; i++)
            {
                pg.Figures.Add(BuildStrand(indx * repeatAngle, i, increment));
            } 
            return path;
        }
Beispiel #17
0
 private path[] KTSerializer(String Data)
 {
     path[] Result = new path[2] { new path(), new path() };
     Result[(int)Paths.Transparent].Fill = new SolidColorBrush(Colors.Black);
     Result[(int)Paths.Opaque].Fill = new SolidColorBrush(Colors.White);
     String[] TO = Data.Split(new Char[] { '_' },StringSplitOptions.RemoveEmptyEntries);
     for (int t = 0; t < 2; t++)
     {
         String[] Split = TO[t].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         PathGeometry geo = new PathGeometry();
         geo.FillRule = FillRule.Nonzero;
         for (int i = 1; i < Split.Length; i++)
         {
             geo.Figures.Add(this.Parse(Split[i]));
         }
         Result[t].Data = geo;
     }
     return Result;
 }
Beispiel #18
0
        public CurvePanel()
        {
            _bgcanvas = new Canvas();
            _bgcanvas.VerticalAlignment = VerticalAlignment.Stretch;
            _bgcanvas.HorizontalAlignment = HorizontalAlignment.Stretch;
            _path = new Path();
            _path.Stroke = Stroke;
            _path.StrokeThickness = StrokeThickness;
            PathGeometry geo = new PathGeometry();
            _bfigure = new PathFigure();
            _bseg = new BezierSegment();
            _bfigure.Segments.Add(_bseg);
            geo.Figures.Add(_bfigure);
            _path.Data = geo;
            _bgcanvas.Children.Add(_path);
            this.Children.Add(_bgcanvas);

            this.SizeChanged += OnSizeChanged;
        }
    /// <summary>
    /// Override for the path's redraw mehtod, controlling how the path is drawns
    /// </summary>
    protected override void Redraw()
    {
        Debug.Assert(GetValue(StartAngleProperty) != DependencyProperty.UnsetValue);
            Debug.Assert(GetValue(RadiusProperty) != DependencyProperty.UnsetValue);
            Debug.Assert(GetValue(AngleProperty) != DependencyProperty.UnsetValue);

            Width = Height = 2 * (Radius);
            var endAngle = StartAngle + Angle;

            // path container
            var figure = new PathFigure
            {
                StartPoint = new Point(Radius, Radius),
                IsClosed = true,
                IsFilled = true
            };

            //  start angle line
            var lineX = Radius + Math.Sin(StartAngle * Math.PI / 180) * Radius;
            var lineY = Radius - Math.Cos(StartAngle * Math.PI / 180) * Radius;
            var line = new LineSegment { Point = new Point(lineX, lineY) };
            figure.Segments.Add(line);

            // outer arc
            var arcX = Radius + Math.Sin(endAngle * Math.PI / 180) * Radius;
            var arcY = Radius - Math.Cos(endAngle * Math.PI / 180) * Radius;
            var arc = new ArcSegment
            {
                IsLargeArc = Angle >= 180.0,
                Point = new Point(arcX, arcY),
                Size = new Size(Radius, Radius),
                SweepDirection = SweepDirection.Clockwise,
            };

            figure.Segments.Add(arc);

            Data = new PathGeometry { Figures = { figure } };
            InvalidateArrange();
    }
Beispiel #20
0
        public static Geometry CreateArcGeometry(double minAngle, double maxAngle, double radius, int thickness, SweepDirection sweepDirection)
        {
            //the range will have 4 segments (arc, line, arc, line)
            //if the sweep angle is bigger than 180 use the large arc
            //first use the same sweep direction as the control. invert for the second arc.
            PathFigure figure = new PathFigure();
            figure.IsClosed = true;
            figure.StartPoint = new Point((radius - thickness) * Math.Sin(minAngle * Math.PI / 180),
                -(radius - thickness) * Math.Cos(minAngle * Math.PI / 180));

            //first arc segment
            ArcSegment arc = new ArcSegment();
            arc.Point = new Point((radius - thickness) * Math.Sin(maxAngle * Math.PI / 180),
                -(radius - thickness) * Math.Cos(maxAngle * Math.PI / 180));
            arc.Size = new Size(radius - thickness, radius - thickness);
            arc.SweepDirection = sweepDirection;
            if (Math.Abs(maxAngle - minAngle) > 180) arc.IsLargeArc = true;
            figure.Segments.Add(arc);
            //first line segment
            LineSegment line = new LineSegment();
            line.Point = new Point(radius * Math.Sin(maxAngle * Math.PI / 180),
                -radius * Math.Cos(maxAngle * Math.PI / 180));
            figure.Segments.Add(line);
            //second arc segment
            arc = new ArcSegment();
            arc.Point = new Point(radius * Math.Sin(minAngle * Math.PI / 180),
                -radius * Math.Cos(minAngle * Math.PI / 180));
            arc.Size = new Size(radius, radius);
            arc.SweepDirection = SweepDirection.Counterclockwise;
            if (sweepDirection == SweepDirection.Counterclockwise)
                arc.SweepDirection = SweepDirection.Clockwise;
            if (Math.Abs(maxAngle - minAngle) > 180) arc.IsLargeArc = true;
            figure.Segments.Add(arc);

            PathGeometry path = new PathGeometry();
            path.Figures.Add(figure);
            return path;
        }
        public Drawing()
        {
            this.InitializeComponent();
            //path

            PathGeometry geo = new PathGeometry();
            geo.Figures.Add(figure);// constructor(new shape)
            geo.Figures.Add(f);
            figure.StartPoint = new Point(25, 25);
            f.StartPoint = new Point(75, 75);
            path p = new path();//constructor
            p.Data = geo;
            p.Stroke = new SolidColorBrush(new Color {A = 100});
            CompositeTransform c = new CompositeTransform();
            p.RenderTransform = c;
            c.TranslateX = 0;
            c.TranslateY = 0;
            G.Children.Add(p);
            f.Segments.Add(new LineSegment { Point = new Point(100, 100) });
            f.Segments.Add(new LineSegment { Point = new Point(100, 150) });
            figure.Segments.Add(new LineSegment { Point = new Point(50, 50) });
            figure.Segments.Add(new LineSegment { Point = new Point(50, 100) });
            p.Fill = black;
        }
        /// <summary>
        /// The draw polygons.
        /// </summary>
        /// <param name="polygons">
        /// The polygons.
        /// </param>
        /// <param name="fill">
        /// The fill.
        /// </param>
        /// <param name="stroke">
        /// The stroke.
        /// </param>
        /// <param name="thickness">
        /// The thickness.
        /// </param>
        /// <param name="dashArray">
        /// The dash array.
        /// </param>
        /// <param name="lineJoin">
        /// The line join.
        /// </param>
        /// <param name="aliased">
        /// The aliased.
        /// </param>
        public void DrawPolygons(
            IList<IList<ScreenPoint>> polygons,
            OxyColor fill,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPenLineJoin lineJoin,
            bool aliased)
        {
            var path = new Path();
            this.SetStroke(path, stroke, thickness, lineJoin, dashArray, aliased);
            if (fill != null)
            {
                path.Fill = this.GetCachedBrush(fill);
            }

            var pg = new PathGeometry { FillRule = FillRule.Nonzero };
            foreach (var polygon in polygons)
            {
                var figure = new PathFigure { IsClosed = true };
                bool first = true;
                foreach (ScreenPoint p in polygon)
                {
                    if (first)
                    {
                        figure.StartPoint = p.ToPoint(aliased);
                        first = false;
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment { Point = p.ToPoint(aliased) });
                    }
                }

                pg.Figures.Add(figure);
            }

            path.Data = pg;
            this.Add(path);
        }
        /// <summary>
        /// The draw line segments.
        /// </summary>
        /// <param name="points">
        /// The points.
        /// </param>
        /// <param name="stroke">
        /// The stroke.
        /// </param>
        /// <param name="thickness">
        /// The thickness.
        /// </param>
        /// <param name="dashArray">
        /// The dash array.
        /// </param>
        /// <param name="lineJoin">
        /// The line join.
        /// </param>
        /// <param name="aliased">
        /// The aliased.
        /// </param>
        public void DrawLineSegments(
            IList<ScreenPoint> points,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPenLineJoin lineJoin,
            bool aliased)
        {
            var path = new Path();
            this.SetStroke(path, stroke, thickness, lineJoin, dashArray, aliased);
            var pg = new PathGeometry();
            for (int i = 0; i + 1 < points.Count; i += 2)
            {
                // if (points[i].Y==points[i+1].Y)
                // {
                // var line = new Line();

                // line.X1 = 0.5+(int)points[i].X;
                // line.X2 = 0.5+(int)points[i+1].X;
                // line.Y1 = 0.5+(int)points[i].Y;
                // line.Y2 = 0.5+(int)points[i+1].Y;
                // SetStroke(line, OxyColors.DarkRed, thickness, lineJoin, dashArray, aliased);
                // Add(line);
                // continue;
                // }
                var figure = new PathFigure { StartPoint = points[i].ToPoint(aliased), IsClosed = false };
                figure.Segments.Add(new LineSegment { Point = points[i + 1].ToPoint(aliased) });
                pg.Figures.Add(figure);
            }

            path.Data = pg;
            this.Add(path);
        }
        /// <summary>
        /// Updates the PieDataPoint's Geometry property.
        /// </summary>
        /// <param name="pieDataPoint">PieDataPoint instance.</param>
        /// <param name="plotAreaWidth">PlotArea width.</param>
        /// <param name="plotAreaHeight">PlotArea height.</param>
        internal static void UpdatePieDataPointGeometry(PieDataPoint pieDataPoint, double plotAreaWidth, double plotAreaHeight)
        {
            double diameter = (plotAreaWidth < plotAreaHeight) ? plotAreaWidth : plotAreaHeight;
            diameter *= 0.95;
            double plotAreaRadius = diameter / 2;
            double maxDistanceFromCenter = 0.0;
            double sliceRadius = plotAreaRadius - maxDistanceFromCenter;

            Point translatePoint = new Point(plotAreaWidth / 2, plotAreaHeight / 2);

            if (pieDataPoint.ActualRatio == 1)
            {
                foreach (DependencyProperty dependencyProperty in new DependencyProperty[] { PieDataPoint.GeometryProperty, PieDataPoint.GeometrySelectionProperty, PieDataPoint.GeometryHighlightProperty })
                {
                    Geometry geometry =
                        new EllipseGeometry
                        {
                            Center = translatePoint,
                            RadiusX = sliceRadius,
                            RadiusY = sliceRadius
                        };
                    pieDataPoint.SetValue(dependencyProperty, geometry);
                }
            }
            else
            {
                if (pieDataPoint.ActualRatio == 0.0)
                {
                    pieDataPoint.Geometry = null;
                    pieDataPoint.GeometryHighlight = null;
                    pieDataPoint.GeometrySelection = null;
                }
                else
                {
                    double ratio = pieDataPoint.ActualRatio;
                    double offsetRatio = pieDataPoint.ActualOffsetRatio;
                    double currentRatio = offsetRatio + ratio;

                    Point offsetRatioPoint = ConvertRatioOfRotationToPoint(offsetRatio, sliceRadius, sliceRadius);

                    Point adjustedOffsetRatioPoint = offsetRatioPoint.Translate(translatePoint);

                    // Calculate the last clockwise point in the pie slice
                    Point currentRatioPoint =
                        ConvertRatioOfRotationToPoint(currentRatio, sliceRadius, sliceRadius);

                    // Adjust point using center of plot area as origin
                    // instead of 0,0
                    Point adjustedCurrentRatioPoint =
                        currentRatioPoint.Translate(translatePoint);

                    foreach (DependencyProperty dependencyProperty in new DependencyProperty[] { PieDataPoint.GeometryProperty, PieDataPoint.GeometrySelectionProperty, PieDataPoint.GeometryHighlightProperty })
                    {
                        // Creating the pie slice geometry object
                        PathFigure pathFigure = new PathFigure { IsClosed = true };
                        pathFigure.StartPoint = translatePoint;
                        pathFigure.Segments.Add(new LineSegment { Point = adjustedOffsetRatioPoint });
                        bool isLargeArc = (currentRatio - offsetRatio) > 0.5;
                        pathFigure.Segments.Add(
                            new ArcSegment
                            {
                                Point = adjustedCurrentRatioPoint,
                                IsLargeArc = isLargeArc,
                                Size = new Size(sliceRadius, sliceRadius),
                                SweepDirection = SweepDirection.Clockwise
                            });

                        PathGeometry pathGeometry = new PathGeometry();
                        pathGeometry.Figures.Add(pathFigure);
                        pieDataPoint.SetValue(dependencyProperty, pathGeometry);
                    }
                }
            }
        }
Beispiel #25
0
        private void UpdatePath()
        {
            var pathGeometry = new PathGeometry();
            var pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(Radius, Radius);
            pathFigure.IsClosed = true;

            // Starting Point
            var lineSegment = 
                new LineSegment 
                {
                    Point = new Point(
                        Radius + Math.Sin(StartAngle * Math.PI / 180) * Radius,
                        Radius - Math.Cos(StartAngle * Math.PI / 180) * Radius)
                };

            // Arc
            var arcSegment = new ArcSegment();
            arcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
            arcSegment.Point =
                new Point(
                        Radius + Math.Sin(EndAngle * Math.PI / 180) * Radius,
                        Radius - Math.Cos(EndAngle * Math.PI / 180) * Radius);
            arcSegment.Size = new Size(Radius, Radius);
            arcSegment.SweepDirection = SweepDirection.Clockwise;
            pathFigure.Segments.Add(lineSegment);
            pathFigure.Segments.Add(arcSegment);
            pathGeometry.Figures.Add(pathFigure);
            this.Data = pathGeometry;
            this.InvalidateArrange();
        }
        private void NodeLinked(NodeConnection from, NodeConnection to)
        {
            Debug.WriteLine("Linked {0} -> {1}", from.ConnectedNodeId, to.ConnectedNodeId);
            NodeBase nodeFrom = null;
            NodeBase nodeTo = null;

            foreach (var child in this.canvasDiagram.Children)
            {
                if (child is NodeBase)
                {
                    var node = child as NodeBase;
                    if (node.NodeId == from.ConnectedNodeId)
                    {
                        nodeFrom = node;
                    }
                    if (node.NodeId == to.ConnectedNodeId)
                    {
                        nodeTo = node;
                    }
                }
            }

            var fromPoint = nodeFrom.GetPosition();
            var toPoint = nodeTo.GetPosition();
            Point distance = new Point(toPoint.X - fromPoint.X, toPoint.Y - fromPoint.Y);

            BezierSegment segment = new BezierSegment();
            segment.Point1 = new Point(fromPoint.X + distance.X / 3, fromPoint.Y - 100);
            segment.Point2 = new Point(fromPoint.X + distance.X * 2 / 3, toPoint.Y + 100);
            segment.Point3 = nodeTo.GetPosition();

            PathFigure figure = new PathFigure();
            figure.StartPoint = nodeFrom.GetPosition();
            figure.Segments.Add(segment);

            PathGeometry geo = new PathGeometry();
            geo.Figures.Add(figure);

            Windows.UI.Xaml.Shapes.Path path = new Windows.UI.Xaml.Shapes.Path();
            path.StrokeThickness = 2;
            path.Stroke = new SolidColorBrush(Colors.Black);

            path.Data = geo;

            this.canvasDiagram.Children.Add(path);
        }
		private void DrawChart()
		{
			if ((dataSet != null) && (dataSet.Length > 0))
			{
				var path = new Windows.UI.Xaml.Shapes.Path();
				path.Stroke = chartColor;
				path.StrokeThickness = 15;
				path.StrokeLineJoin = PenLineJoin.Round;
				path.StrokeStartLineCap = PenLineCap.Round;
				path.StrokeEndLineCap = PenLineCap.Round;

				var geometry = new PathGeometry();

				var figure = new PathFigure();
				figure.IsClosed = false;
				figure.StartPoint = new Point(offsetList[0].OffsetX, offsetList[0].OffsetY);

				for (int i = 0; i < offsetList.Count; i++)
				{
					var segment = new LineSegment();
					segment.Point = new Point(offsetList[i].OffsetX, offsetList[i].OffsetY);
					figure.Segments.Add(segment);
				}
				geometry.Figures.Add(figure);
				path.Data = geometry;
				Children.Add(path);
			}
		}
Beispiel #28
0
 public static void Write(this StreamGeometryContext ctx, PathGeometry pathGeometry)
 {
     pathGeometry.Figures.ForEach(ctx.Write);
 }
Beispiel #29
0
        public object ConvertToNative(Geometry geometry)
        {
            winMedia.Geometry winGeometry = null;

            // Determine what type of geometry we're dealing with.
            if (geometry is LineGeometry)
            {
                LineGeometry xamGeometry = geometry as LineGeometry;
                winGeometry = new winMedia.LineGeometry
                {
                    StartPoint = ConvertPoint(xamGeometry.StartPoint),
                    EndPoint   = ConvertPoint(xamGeometry.EndPoint)
                };
            }

            else if (geometry is RectangleGeometry)
            {
                Rect rect = (geometry as RectangleGeometry).Rect;
                winGeometry = new winMedia.RectangleGeometry
                {
                    Rect = new winFound.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }

            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry xamGeometry = geometry as EllipseGeometry;
                winGeometry = new winMedia.EllipseGeometry
                {
                    Center  = ConvertPoint(xamGeometry.Center),
                    RadiusX = xamGeometry.RadiusX,
                    RadiusY = xamGeometry.RadiusY
                };
            }

            else if (geometry is GeometryGroup)
            {
                GeometryGroup xamGeometry = geometry as GeometryGroup;
                winGeometry = new winMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(xamGeometry.FillRule)
                };

                foreach (Geometry xamChild in xamGeometry.Children)
                {
                    winMedia.Geometry winChild = ConvertToNative(xamChild) as winMedia.Geometry;
                    (winGeometry as winMedia.GeometryGroup).Children.Add(winChild);
                }
            }

            else if (geometry is PathGeometry)
            {
                PathGeometry xamPathGeometry = geometry as PathGeometry;

                winMedia.PathGeometry winPathGeometry = new winMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(xamPathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in xamPathGeometry.Figures)
                {
                    winMedia.PathFigure winPathFigure = new winMedia.PathFigure
                    {
                        StartPoint = ConvertPoint(xamPathFigure.StartPoint),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    winPathGeometry.Figures.Add(winPathFigure);

                    foreach (PathSegment xamPathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (xamPathSegment is LineSegment)
                        {
                            LineSegment xamSegment = xamPathSegment as LineSegment;

                            winMedia.LineSegment winSegment = new winMedia.LineSegment
                            {
                                Point = ConvertPoint(xamSegment.Point)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (xamPathSegment is PolyLineSegment)
                        {
                            PolyLineSegment          xamSegment = xamPathSegment as PolyLineSegment;
                            winMedia.PolyLineSegment winSegment = new winMedia.PolyLineSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // BezierSegment
                        if (xamPathSegment is BezierSegment)
                        {
                            BezierSegment xamSegment = xamPathSegment as BezierSegment;

                            winMedia.BezierSegment winSegment = new winMedia.BezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                                Point3 = ConvertPoint(xamSegment.Point3)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyBezierSegment
                        else if (xamPathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment          xamSegment = xamPathSegment as PolyBezierSegment;
                            winMedia.PolyBezierSegment winSegment = new winMedia.PolyBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // QuadraticBezierSegment
                        if (xamPathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment xamSegment = xamPathSegment as QuadraticBezierSegment;

                            winMedia.QuadraticBezierSegment winSegment = new winMedia.QuadraticBezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyQuadraticBezierSegment
                        else if (xamPathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment          xamSegment = xamPathSegment as PolyQuadraticBezierSegment;
                            winMedia.PolyQuadraticBezierSegment winSegment = new winMedia.PolyQuadraticBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }


                        // ArcSegment
                        else if (xamPathSegment is ArcSegment)
                        {
                            ArcSegment          xamSegment = xamPathSegment as ArcSegment;
                            winMedia.ArcSegment winSegment = new winMedia.ArcSegment();

                            winSegment.Size           = new winFound.Size(xamSegment.Size.Width, xamSegment.Size.Height);
                            winSegment.RotationAngle  = xamSegment.RotationAngle;
                            winSegment.IsLargeArc     = xamSegment.IsLargeArc;
                            winSegment.SweepDirection = xamSegment.SweepDirection == SweepDirection.Clockwise ? winMedia.SweepDirection.Clockwise : winMedia.SweepDirection.Counterclockwise;
                            winSegment.Point          = ConvertPoint(xamSegment.Point);

                            winPathFigure.Segments.Add(winSegment);
                        }
                    }
                }

                winGeometry = winPathGeometry;
            }

            // Set transform.
            if (geometry.Transform != null)
            {
                winGeometry.Transform = (winMedia.Transform)geometry.Transform.GetNativeObject();
            }

            return(winGeometry);
        }
Beispiel #30
0
        private void VisualizeGraph(RainData rainData, bool animated = true)
        {
            List<int> pointValues;
            if (rainData == null || rainData.Points == null)
                pointValues = new List<int>();
            else
                pointValues = rainData.Points.Take(25).Select(p => p.AdjustedValue).ToList();

            while (pointValues.Count < 25)
                pointValues.Add(pointValues.LastOrDefault());

            var path = GraphView.Data as PathGeometry;
            var graphSize = new Size(GraphContainer.ActualWidth, GraphContainer.ActualHeight);
            var step = graphSize.Width / Model.Entries;
            Func<int, double> xForIndex = idx => idx == 0 ? -2 : idx * step;

            var x = 0;
            var max = (graphSize.Height / 12.0 * 11.0) - 10;
            var allZeros = pointValues.Take(Model.Entries + 1).All(p => p == 0);
            var points = pointValues.Select(v => {
                var y = allZeros ? max - 20 : Math.Max(1, max - (v * max / 100));
                var p = new Point(xForIndex(x), y);
                x++;
                return p;
            }).ToList();
            points.Add(new Point(graphSize.Width + 2, points.Last().Y));
            points.Add(new Point(graphSize.Width + 2, graphSize.Height + 2));

            PathFigure figure;
            var startPoint = new Point(-2.0, graphSize.Height + 2);
            if (path == null) {
                path = new PathGeometry();
                figure = new PathFigure() { StartPoint = startPoint, IsClosed = true };
                path.Figures.Add(figure);
                foreach (var p in points) {
                    figure.Segments.Add(new LineSegment() { Point = p });
                }
                GraphView.Data = path;
            }

            var entriesAnimated = graphEntries != Model.Entries && graphEntries > 0 && Model.Entries > 0;
            if (entriesAnimated)
                UpdateEntriesImage();

            var ms300 = TimeSpan.FromMilliseconds(entriesAnimated ? 450 / Math.Abs(Model.Entries - graphEntries) : animated ? 300 : 0);
            graphEntries = Model.Entries;
            var storyboard = new Storyboard() { Duration = ms300 };


            figure = path.Figures[0];
            var anim = new PointAnimation() { Duration = ms300, To = startPoint, FillBehavior = FillBehavior.HoldEnd, EnableDependentAnimation = true };
            Storyboard.SetTarget(anim, figure);
            Storyboard.SetTargetProperty(anim, "StartPoint");
            storyboard.Children.Add(anim);

            for (var i = 0; i < points.Count; ++i) {
                anim = new PointAnimation() { Duration = ms300, To = points[i], FillBehavior = FillBehavior.HoldEnd, EnableDependentAnimation = true };
                Storyboard.SetTarget(anim, figure.Segments[i]);
                Storyboard.SetTargetProperty(anim, "Point");
                storyboard.Children.Add(anim);
            }

            var strokeAnim = new ColorAnimation() { Duration = ms300, FillBehavior = FillBehavior.HoldEnd, To = allZeros ? Colors.Transparent : graphStrokeColor, EnableDependentAnimation = true };
            Storyboard.SetTarget(strokeAnim, GraphView.Stroke);
            Storyboard.SetTargetProperty(strokeAnim, "Color");
            storyboard.Children.Add(strokeAnim);

            var fillTopAnim = new ColorAnimation() { Duration = ms300, FillBehavior = FillBehavior.HoldEnd, To = allZeros ? Colors.Black : graphFillFrom, EnableDependentAnimation = true };
            Storyboard.SetTarget(fillTopAnim, ((LinearGradientBrush)GraphView.Fill).GradientStops[0]);
            Storyboard.SetTargetProperty(fillTopAnim, "Color");
            storyboard.Children.Add(fillTopAnim);

            storyboard.Begin(() => GraphView.Data = path);
        }
Beispiel #31
0
        public static WMedia.Geometry ToWindows(this Geometry geometry)
        {
            WMedia.Geometry wGeometry = null;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;
                wGeometry = new WMedia.LineGeometry
                {
                    StartPoint = lineGeometry.StartPoint.ToWindows(),
                    EndPoint   = lineGeometry.EndPoint.ToWindows()
                };
            }
            else if (geometry is RectangleGeometry)
            {
                var rect = (geometry as RectangleGeometry).Rect;
                wGeometry = new WMedia.RectangleGeometry
                {
                    Rect = new WFoundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
                wGeometry = new WMedia.EllipseGeometry
                {
                    Center  = ellipseGeometry.Center.ToWindows(),
                    RadiusX = ellipseGeometry.RadiusX,
                    RadiusY = ellipseGeometry.RadiusY
                };
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;
                wGeometry = new WMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(geometryGroup.FillRule)
                };

                foreach (Geometry children in geometryGroup.Children)
                {
                    WMedia.Geometry winChild = children.ToWindows();
                    (wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                WMedia.PathGeometry wPathGeometry = new WMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(pathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in pathGeometry.Figures)
                {
                    WMedia.PathFigure wPathFigure = new WMedia.PathFigure
                    {
                        StartPoint = xamPathFigure.StartPoint.ToWindows(),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    wPathGeometry.Figures.Add(wPathFigure);

                    foreach (PathSegment pathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            WMedia.LineSegment winSegment = new WMedia.LineSegment
                            {
                                Point = lineSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment        polyLineSegment = pathSegment as PolyLineSegment;
                            WMedia.PolyLineSegment wSegment        = new WMedia.PolyLineSegment();

                            foreach (var point in polyLineSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // BezierSegment
                        if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            WMedia.BezierSegment wSegment = new WMedia.BezierSegment
                            {
                                Point1 = bezierSegment.Point1.ToWindows(),
                                Point2 = bezierSegment.Point2.ToWindows(),
                                Point3 = bezierSegment.Point3.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment        polyBezierSegment = pathSegment as PolyBezierSegment;
                            WMedia.PolyBezierSegment wSegment          = new WMedia.PolyBezierSegment();

                            foreach (var point in polyBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // QuadraticBezierSegment
                        if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment quadraticBezierSegment = pathSegment as QuadraticBezierSegment;

                            WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
                            {
                                Point1 = quadraticBezierSegment.Point1.ToWindows(),
                                Point2 = quadraticBezierSegment.Point2.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment        polyQuadraticBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            WMedia.PolyQuadraticBezierSegment wSegment = new WMedia.PolyQuadraticBezierSegment();

                            foreach (var point in polyQuadraticBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            WMedia.ArcSegment wSegment = new WMedia.ArcSegment
                            {
                                Size           = new WFoundation.Size(arcSegment.Size.Width, arcSegment.Size.Height),
                                RotationAngle  = arcSegment.RotationAngle,
                                IsLargeArc     = arcSegment.IsLargeArc,
                                SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
                                Point          = arcSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                    }
                }

                wGeometry = wPathGeometry;
            }

            return(wGeometry);
        }
        private void DrawEWNS_map()
        {
            if (this.Longitudes.Count() < 4 || this.Latitudes.Count() < 4)
            {
                return;
            }

            Size size = this.m_renderSize;// this.grdHostGrid.RenderSize;
            float[] ews = this.m_longitudes;
            float[] nss = this.m_latitudes;

            GeometryGroup rootGroup = new GeometryGroup();
            //创建起点和终点
            float startX = ews.First();
            float startY = nss.First();
            rootGroup.Children.Add(new EllipseGeometry() { Center = new Point(startX, startY), RadiusX = 10, RadiusY = 10 });
            rootGroup.Children.Add(new EllipseGeometry() { Center = new Point(startX, startY), RadiusX = 8, RadiusY = 8 });

            PathGeometry pg = new PathGeometry() { Figures = new PathFigureCollection() };
            PathFigure figure = new PathFigure() { IsClosed = false, StartPoint = new Point(startX, startY) };
            figure.IsFilled = false;


            PolyBezierSegment segments = this.CreateSegments(ews, nss);

            figure.Segments.Add(segments);
            pg.Figures.Add(figure);
            rootGroup.Children.Add(pg);
            this.grdHostGrid.Data = rootGroup;
        }
Beispiel #33
0
        private void UpdatePath()
        {
            var radius = this.Radius - this.StrokeThickness / 2;

            if (_isUpdating ||
                this.ActualWidth == 0 ||
                radius <= 0)
            {
                return;
            }

            var pathGeometry = new PathGeometry();
            var pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(radius, radius);
            pathFigure.IsClosed = true;

            // Starting Point
            var lineSegment =
                new LineSegment
                {
                    Point = new Point(
                        radius + Math.Sin(StartAngle * Math.PI / 180) * radius,
                        radius - Math.Cos(StartAngle * Math.PI / 180) * radius)
                };

            // Arc
            var arcSegment = new ArcSegment();
            arcSegment.IsLargeArc = (EndAngle - StartAngle) >= 180.0;
            arcSegment.Point =
                new Point(
                        radius + Math.Sin(EndAngle * Math.PI / 180) * radius,
                        radius - Math.Cos(EndAngle * Math.PI / 180) * radius);
            arcSegment.Size = new Size(radius, radius);
            arcSegment.SweepDirection = SweepDirection.Clockwise;
            pathFigure.Segments.Add(lineSegment);
            pathFigure.Segments.Add(arcSegment);
            pathGeometry.Figures.Add(pathFigure);
            this.Data = pathGeometry;
            this.InvalidateArrange();
        }
Beispiel #34
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _path = (Path)GetTemplateChild(pathName);
            _thumbGrid = (Grid)GetTemplateChild(thumbGridName);
            _readingBlock = (TextBlock)GetTemplateChild(readingName);

            PathGeometry geo = new PathGeometry();
            _bfigure = new PathFigure();
            _bseg = new BezierSegment();
            _bfigure.Segments.Add(_bseg);
            geo.Figures.Add(_bfigure);
            _path.Data = geo;

            this.SizeChanged += OnSizeChanged;
        }
Beispiel #35
0
        public static Path DecodeGeometry(Tile.Feature feature, float scale)
        {
            //System.Diagnostics.Debug.WriteLine("----Start decode----");
            //System.Diagnostics.Debug.WriteLine("type: " + feature.Type);
            //System.Diagnostics.Debug.WriteLine("geometries: " + feature.Geometries.Length);

            Queue <uint> q    = new Queue <uint>(feature.Geometries);
            Path         path = new Path();

            Windows.UI.Xaml.Media.PathGeometry pathGeometry = new Windows.UI.Xaml.Media.PathGeometry();

            PathFigure figure = null;
            float      cx     = 0;
            float      cy     = 0;

            while (q.Count > 0)
            {
                var cmd = DecodeCommand(q.Dequeue());
                switch (cmd.Item1)
                {
                case GeometryCommand.MoveTo:
                    if (figure != null)
                    {
                        pathGeometry.Figures.Add(figure);
                    }
                    figure            = new PathFigure();
                    cx               += DecodeParameter(q.Dequeue()) * scale;
                    cy               += DecodeParameter(q.Dequeue()) * scale;
                    figure.StartPoint = new Windows.Foundation.Point(cx, cy);

                    //System.Diagnostics.Debug.Write("MoveTo ");
                    //for(int it=0; it<cmd.count*2;it++)
                    //{
                    //	System.Diagnostics.Debug.Write(DecodeParameter(q.Dequeue()) + " ");
                    //}
                    //System.Diagnostics.Debug.WriteLine("");
                    break;

                case GeometryCommand.LineTo:
                    for (int it = 0; it < cmd.count; it++)
                    {
                        cx += DecodeParameter(q.Dequeue()) * scale;
                        cy += DecodeParameter(q.Dequeue()) * scale;
                        figure.Segments.Add(new LineSegment()
                        {
                            Point = new Windows.Foundation.Point(cx, cy)
                        });
                    }

                    //System.Diagnostics.Debug.Write("LineTo ");
                    //for (int it = 0; it < cmd.count * 2; it++)
                    //{
                    //	System.Diagnostics.Debug.Write(DecodeParameter(q.Dequeue()) + " ");
                    //}
                    //System.Diagnostics.Debug.WriteLine("");
                    break;

                case GeometryCommand.ClosePath:
                    figure.Segments.Add(new LineSegment()
                    {
                        Point = figure.StartPoint
                    });
                    pathGeometry.Figures.Add(figure);
                    figure.IsFilled = true;
                    figure.IsClosed = true;
                    figure          = null;
                    //System.Diagnostics.Debug.WriteLine("ClosePath");
                    break;
                }
            }

            if (figure != null)
            {
                pathGeometry.Figures.Add(figure);
            }

            path.Data            = pathGeometry;
            path.Fill            = new SolidColorBrush(Windows.UI.Colors.SandyBrown);
            path.Stroke          = new SolidColorBrush(Windows.UI.Colors.Brown);
            path.StrokeThickness = 1;

            //System.Diagnostics.Debug.WriteLine("----Stop  decode----");
            return(path);
        }