Esempio n. 1
0
        // use for shape (path)
        private CanvasPathBuilder DrawPath(CanvasPathBuilder p, List <DrawablePoint> left, List <DrawablePoint> right)
        {
            int count = left.Count;

            for (int i = 0; i < count - 1; ++i)
            {
                p.BeginFigure(left[i].X, left[i].Y);
                p.AddCubicBezier(
                    new Vector2(left[i].OutX, left[i].OutY),
                    new Vector2(left[i + 1].InX, left[i + 1].InY),
                    new Vector2(left[i + 1].X, left[i + 1].Y));

                p.AddLine(right[i + 1].X, right[i + 1].Y);
                p.AddCubicBezier(
                    new Vector2(right[i + 1].InX, right[i + 1].InY),
                    new Vector2(right[i].OutX, right[i].OutY),
                    new Vector2(right[i].X, right[i].Y));

                p.AddLine(left[i].X, left[i].Y);
                p.EndFigure(CanvasFigureLoop.Open);
            }

            float r = left[0].GetDistance(right[0]);

            AddArc(p, (left[0].X + right[0].X) / 2 - r / 2, (left[0].Y + right[0].Y) / 2 - r / 2, r, r);

            r = left[count - 1].GetDistance(right[count - 1]);
            AddArc(p, (left[count - 1].X + right[count - 1].X) / 2 - r / 2, (left[count - 1].Y + right[count - 1].Y) / 2 - r / 2, r, r);

            return(p);
        }
Esempio n. 2
0
        private static CanvasGeometry CreateCapsuleCore(ICanvasResourceCreator resourceCreator,
                                                        float verticalLength,
                                                        Vector2 horizontalUnit,

                                                        Vector2 centerTop,
                                                        Vector2 centerLeft,
                                                        Vector2 centerRight,
                                                        Vector2 centerBottom,

                                                        Vector2 leftTop,
                                                        Vector2 rightTop,
                                                        Vector2 rightBottom,
                                                        Vector2 leftBottom)
        {
            // Horizontal
            Vector2 horizontal2   = 0.5f * verticalLength * horizontalUnit;
            Vector2 horizontal448 = horizontal2 * 0.448f;              // vector / (1 - 0.552f)
            // Vertical
            Vector2 vertical276 = (centerBottom - centerTop) * 0.276f; // vector / 2 * 0.552f

            // Control
            Vector2 left2        = centerLeft - vertical276;
            Vector2 leftTop_Top  = leftTop + horizontal2;
            Vector2 leftTop_Top1 = leftTop + horizontal448;

            Vector2 rightTop_Top  = rightTop - horizontal2;
            Vector2 rightTop_Top2 = rightTop - horizontal448;
            Vector2 right1        = centerRight - vertical276;

            Vector2 right2              = centerRight + vertical276;
            Vector2 rightBottom_Bottom  = rightBottom - horizontal2;
            Vector2 rightBottom_Bottom1 = rightBottom - horizontal448;

            Vector2 leftBottom_Bottom  = leftBottom + horizontal2;
            Vector2 leftBottom_Bottom2 = leftBottom + horizontal448;
            Vector2 left1 = centerLeft + vertical276;


            // Path
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(resourceCreator);

            {
                pathBuilder.BeginFigure(centerLeft);

                pathBuilder.AddCubicBezier(left2, leftTop_Top1, leftTop_Top);
                pathBuilder.AddLine(rightTop_Top);

                pathBuilder.AddCubicBezier(rightTop_Top2, right1, centerRight);

                pathBuilder.AddCubicBezier(right2, rightBottom_Bottom1, rightBottom_Bottom);
                pathBuilder.AddLine(leftBottom_Bottom);

                pathBuilder.AddCubicBezier(leftBottom_Bottom2, left1, centerLeft);

                pathBuilder.EndFigure(CanvasFigureLoop.Closed);
            }

            // Geometry
            return(CanvasGeometry.CreatePath(pathBuilder));
        }
Esempio n. 3
0
            // - - - - Shape tree root for layer: icon
            // - - - ShapeGroup: Group 2
            // - - Path 1
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(-80F, -44.9970016F));
                    builder.AddCubicBezier(new Vector2(-80.0019989F, -58.8050003F), new Vector2(-68.8079987F, -70F), new Vector2(-55F, -70F));
                    builder.AddLine(new Vector2(-28.3600006F, -70F));
                    builder.AddCubicBezier(new Vector2(-25.1149998F, -70F), new Vector2(-21.9570007F, -68.947998F), new Vector2(-19.3610001F, -67.0009995F));
                    builder.AddLine(new Vector2(-3.35800004F, -55F));
                    builder.AddLine(new Vector2(44.9560013F, -55F));
                    builder.AddCubicBezier(new Vector2(58.7630005F, -55F), new Vector2(69.9560013F, -43.9070015F), new Vector2(69.9560013F, -30.1000004F));
                    builder.AddLine(new Vector2(70F, -30F));
                    builder.AddLine(new Vector2(-41.7639999F, -29.9790001F));
                    builder.AddCubicBezier(new Vector2(-48.9420013F, -29.9790001F), new Vector2(-55F, -25.3400002F), new Vector2(-56.4869995F, -17.8490009F));
                    builder.AddLine(new Vector2(-72.2580032F, 63.0509987F));
                    builder.AddCubicBezier(new Vector2(-77.0199966F, 58.5F), new Vector2(-79.9869995F, 52.0849991F), new Vector2(-79.987999F, 44.9780006F));
                    builder.AddLine(new Vector2(-80F, -44.9970016F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
        private void CreateAnimatedChart1()
        {
            var shapeVisual = _compositor.CreateShapeVisual();

            shapeVisual.RelativeSizeAdjustment = Vector2.One;
            var viewBox = _compositor.CreateViewBox();

            viewBox.Size        = new Vector2(500, 200);
            viewBox.Stretch     = CompositionStretch.Fill;
            shapeVisual.ViewBox = viewBox;
            ElementCompositionPreview.SetElementChildVisual(ChartArea1, shapeVisual);

            var chart = _compositor.CreateSpriteShape();

            chart.CenterPoint = viewBox.Size / 2;
            chart.FillBrush   = _compositor.CreateColorBrush(Colors.LightBlue);
            var chartGeometry = _compositor.CreatePathGeometry();

            var builder1 = new CanvasPathBuilder(null);

            builder1.BeginFigure(new Vector2(0, 200));
            builder1.AddLine(new Vector2(0, 100));
            builder1.AddCubicBezier(new Vector2(30, 100), new Vector2(60), new Vector2(100, 60));
            builder1.AddCubicBezier(new Vector2(140, 60), new Vector2(200, 120), new Vector2(250, 120));
            builder1.AddCubicBezier(new Vector2(350, 120), new Vector2(340, 40), new Vector2(380, 40));
            builder1.AddCubicBezier(new Vector2(420, 40), new Vector2(400, 120), new Vector2(500, 120));
            builder1.AddLine(new Vector2(500, 200));
            builder1.EndFigure(CanvasFigureLoop.Closed);
            var curvedPath = new CompositionPath(CanvasGeometry.CreatePath(builder1));

            var builder2 = new CanvasPathBuilder(null);

            builder2.BeginFigure(new Vector2(0, 200));
            builder2.AddLine(new Vector2(0, 100));
            builder2.AddCubicBezier(new Vector2(30, 100), new Vector2(60, 100), new Vector2(100, 100));
            builder2.AddCubicBezier(new Vector2(140, 100), new Vector2(200, 100), new Vector2(250, 100));
            builder2.AddCubicBezier(new Vector2(350, 100), new Vector2(340, 100), new Vector2(380, 100));
            builder2.AddCubicBezier(new Vector2(420, 100), new Vector2(400, 100), new Vector2(500, 100));
            builder2.AddLine(new Vector2(500, 200));
            builder2.EndFigure(CanvasFigureLoop.Closed);
            var flatPath = new CompositionPath(CanvasGeometry.CreatePath(builder2));

            chartGeometry.Path = flatPath;
            chart.Geometry     = chartGeometry;
            shapeVisual.Shapes.Add(chart);

            var pathAnimation = _compositor.CreatePathKeyFrameAnimation();

            pathAnimation.InsertKeyFrame(1, curvedPath);
            pathAnimation.Duration  = TimeSpan.FromMilliseconds(800);
            pathAnimation.DelayTime = TimeSpan.FromMilliseconds(2000);
            chartGeometry.StartAnimation("Path", pathAnimation);
        }
Esempio n. 5
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 3 Offset:<116.628, 109.98>
            CanvasGeometry Geometry_0()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-3.35700011F, 37.9889984F));
                    builder.AddCubicBezier(new Vector2(0.995999992F, 26.1539993F), new Vector2(3.37199998F, 13.3649998F), new Vector2(3.37199998F, 0.0199999996F));
                    builder.AddCubicBezier(new Vector2(3.37199998F, -13.3400002F), new Vector2(0.99000001F, -26.1429996F), new Vector2(-3.37199998F, -37.9889984F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 6
0
            // - - - - Shape tree root for layer: icon
            // - - - ShapeGroup: Group 1 Offset:<38.998, 110.019>
            // - Path
            CanvasGeometry Geometry_5()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(34.9980011F, 26.1739998F));
                    builder.AddCubicBezier(new Vector2(38.8450012F, 18.2590008F), new Vector2(41.0019989F, 9.37199974F), new Vector2(41.0019989F, -0.0189999994F));
                    builder.AddCubicBezier(new Vector2(41.0019989F, -9.43200016F), new Vector2(38.8339996F, -18.3390007F), new Vector2(34.9710007F, -26.2679996F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 7
0
            // - - - - Shape tree root for layer: icon
            // - - - ShapeGroup: Group 2 Offset:<76.985, 109.973>
            // - Path
            CanvasGeometry Geometry_3()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(36.2869987F, 37.9959984F));
                    builder.AddCubicBezier(new Vector2(40.6389999F, 26.1609993F), new Vector2(43.0149994F, 13.3719997F), new Vector2(43.0149994F, 0.0270000007F));
                    builder.AddCubicBezier(new Vector2(43.0149994F, -13.3330002F), new Vector2(40.6339989F, -26.1359997F), new Vector2(36.2719994F, -37.9819984F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 8
0
            // - - - - Shape tree root for layer: icon
            // - - - ShapeGroup: Group 3 Offset:<116.628, 109.98>
            // - Path
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(35.5209999F, 49.6629982F));
                    builder.AddCubicBezier(new Vector2(40.6170006F, 34.0349998F), new Vector2(43.3720016F, 17.3490009F), new Vector2(43.3720016F, 0.0199999996F));
                    builder.AddCubicBezier(new Vector2(43.3720016F, -17.3040009F), new Vector2(40.6189995F, -33.9840012F), new Vector2(35.526001F, -49.6080017F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 9
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 1 Offset:<38.998, 110.019>
            CanvasGeometry Geometry_2()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-1.00199997F, 15.4160004F));
                    builder.AddCubicBezier(new Vector2(0.305000007F, 10.4910002F), new Vector2(1.00199997F, 5.31799984F), new Vector2(1.00199997F, -0.0189999994F));
                    builder.AddCubicBezier(new Vector2(1.00199997F, -5.34200001F), new Vector2(0.308999985F, -10.5030003F), new Vector2(-0.991999984F, -15.4160004F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 10
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: lb
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(40F, -40F));
                    builder.AddCubicBezier(new Vector2(51.0460014F, -40F), new Vector2(60F, -31.0459995F), new Vector2(60F, -20F));
                    builder.AddLine(new Vector2(60F, -7.68300009F));
                    builder.AddCubicBezier(new Vector2(56.6940002F, -9.60200024F), new Vector2(53.3779984F, -12.2309999F), new Vector2(50.0569992F, -15.6960001F));
                    builder.AddCubicBezier(new Vector2(44.5629997F, -21.4300003F), new Vector2(35.4679985F, -21.4360008F), new Vector2(29.9659996F, -15.7069998F));
                    builder.AddCubicBezier(new Vector2(21.5690002F, -6.96400023F), new Vector2(13.0600004F, -3.33299994F), new Vector2(4F, -3.33299994F));
                    builder.AddCubicBezier(new Vector2(-4.11299992F, -3.33299994F), new Vector2(-10F, 3.398F), new Vector2(-10F, 10.8330002F));
                    builder.AddLine(new Vector2(-10F, 35.9259987F));
                    builder.AddLine(new Vector2(-9.95400047F, 38.7459984F));
                    builder.AddLine(new Vector2(-9.95100021F, 38.8300018F));
                    builder.AddCubicBezier(new Vector2(-9.56599998F, 50.3720016F), new Vector2(-6.91499996F, 60.8740005F), new Vector2(-1.78199995F, 70F));
                    builder.AddLine(new Vector2(-40F, 70F));
                    builder.AddCubicBezier(new Vector2(-51.0460014F, 70F), new Vector2(-60F, 61.0460014F), new Vector2(-60F, 50F));
                    builder.AddLine(new Vector2(-60F, -20F));
                    builder.AddCubicBezier(new Vector2(-60F, -31.0459995F), new Vector2(-51.0460014F, -40F), new Vector2(-40F, -40F));
                    builder.AddLine(new Vector2(40F, -40F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 11
0
 CanvasGeometry BuildSquareGeometry()
 {
     using (var builder = new CanvasPathBuilder(null))
     {
         builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
         builder.BeginFigure(new Vector2(-90, -146));
         builder.AddCubicBezier(new Vector2(-90, -146), new Vector2(176, -148.555F), new Vector2(176, -148.555F));
         builder.AddCubicBezier(new Vector2(176, -148.555F), new Vector2(174.445F, 121.445F), new Vector2(174.445F, 121.445F));
         builder.AddCubicBezier(new Vector2(174.445F, 121.445F), new Vector2(-91.555F, 120), new Vector2(-91.555F, 120));
         builder.AddCubicBezier(new Vector2(-91.555F, 120), new Vector2(-90, -146), new Vector2(-90, -146));
         builder.EndFigure(CanvasFigureLoop.Closed);
         return(CanvasGeometry.CreatePath(builder));
     }
 }
Esempio n. 12
0
 CanvasGeometry BuildCircleGeometry()
 {
     using (var builder = new CanvasPathBuilder(null))
     {
         builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
         builder.BeginFigure(new Vector2(42.223F, -146));
         builder.AddCubicBezier(new Vector2(115.248F, -146), new Vector2(174.445F, -86.13F), new Vector2(174.445F, -12.277F));
         builder.AddCubicBezier(new Vector2(174.445F, 61.576F), new Vector2(115.248F, 121.445F), new Vector2(42.223F, 121.445F));
         builder.AddCubicBezier(new Vector2(-30.802F, 121.445F), new Vector2(-90, 61.576F), new Vector2(-90, -12.277F));
         builder.AddCubicBezier(new Vector2(-90, -86.13F), new Vector2(-30.802F, -146), new Vector2(42.223F, -146));
         builder.EndFigure(CanvasFigureLoop.Closed);
         return(CanvasGeometry.CreatePath(builder));
     }
 }
Esempio n. 13
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 2 Offset:<76.985, 109.973>
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-2.98900008F, 26.2210007F));
                    builder.AddCubicBezier(new Vector2(0.85799998F, 18.3059998F), new Vector2(3.0150001F, 9.41800022F), new Vector2(3.0150001F, 0.0270000007F));
                    builder.AddCubicBezier(new Vector2(3.0150001F, -9.38599968F), new Vector2(0.84799999F, -18.2919998F), new Vector2(-3.0150001F, -26.2210007F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 14
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 1
            CanvasGeometry Geometry_2()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-20F, -10F));
                    builder.AddCubicBezier(new Vector2(-20F, -21.7789993F), new Vector2(-10.2460003F, -30F), new Vector2(0F, -30F));
                    builder.AddCubicBezier(new Vector2(10.2460003F, -30F), new Vector2(20F, -21.7999992F), new Vector2(20F, -10F));
                    builder.AddCubicBezier(new Vector2(20F, 10F), new Vector2(0.00499999989F, 3.727F), new Vector2(0F, 30F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 15
0
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-112.537003F, 20.6439991F));
                    builder.AddCubicBezier(new Vector2(-102.990997F, 9.03299999F), new Vector2(-86.552002F, -7.33500004F), new Vector2(-62.9199982F, -13.1920004F));
                    builder.AddCubicBezier(new Vector2(-32.8549995F, -20.6439991F), new Vector2(-12.4399996F, -5.80499983F), new Vector2(34.8759995F, 3.91599989F));
                    builder.AddCubicBezier(new Vector2(52.2229996F, 7.48000002F), new Vector2(78.7259979F, 11.4940004F), new Vector2(112.537003F, 10.7589998F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 16
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 2
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-15.0039997F, -8.64900017F));
                    builder.AddCubicBezier(new Vector2(-15.0039997F, -18.4650002F), new Vector2(-7.6960001F, -23.757F), new Vector2(-0.0120000001F, -23.757F));
                    builder.AddCubicBezier(new Vector2(7.67299986F, -23.757F), new Vector2(15.0039997F, -18.4820004F), new Vector2(15.0039997F, -8.64900017F));
                    builder.AddCubicBezier(new Vector2(15.0039997F, 8.01799965F), new Vector2(0F, 5.67799997F), new Vector2(0F, 23.757F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 17
0
            // - - - - Shape tree root for layer: icon
            // - - -  Offset:<-3.8320007, 0>
            // - - Path 2+Path 1.PathGeometry
            CanvasGeometry Geometry_2()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(0F, 50F));
                    builder.AddCubicBezier(new Vector2(16.5690002F, 50F), new Vector2(30F, 27.6140003F), new Vector2(30F, 0F));
                    builder.AddCubicBezier(new Vector2(30F, -27.6140003F), new Vector2(16.5690002F, -50F), new Vector2(0F, -50F));
                    builder.AddCubicBezier(new Vector2(-16.5690002F, -50F), new Vector2(-30F, -27.6140003F), new Vector2(-30F, 0F));
                    builder.AddCubicBezier(new Vector2(-30F, 27.6140003F), new Vector2(-16.5690002F, 50F), new Vector2(0F, 50F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 18
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: lt
            CanvasGeometry Geometry_2()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-20F, 15F));
                    builder.AddLine(new Vector2(-20F, 5F));
                    builder.AddCubicBezier(new Vector2(-20F, -5F), new Vector2(-12.2229996F, -15F), new Vector2(0F, -15F));
                    builder.AddCubicBezier(new Vector2(12.2229996F, -15F), new Vector2(20F, -5F), new Vector2(20F, 5F));
                    builder.AddLine(new Vector2(20F, 15F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 19
0
            CanvasGeometry Geometry_5()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(-19.743F, 15.7650003F));
                    builder.AddCubicBezier(new Vector2(-19.743F, 15.7650003F), new Vector2(-22.8710003F, -3.98900008F), new Vector2(-22.8710003F, -3.98900008F));
                    builder.AddCubicBezier(new Vector2(-24.4349995F, -13.8660002F), new Vector2(-18.3190002F, -24.9589996F), new Vector2(-6.24599981F, -26.8710003F));
                    builder.AddCubicBezier(new Vector2(5.82700014F, -28.7830009F), new Vector2(15.0719995F, -20.1229992F), new Vector2(16.6359997F, -10.2460003F));
                    builder.AddCubicBezier(new Vector2(16.6359997F, -10.2460003F), new Vector2(16.7929993F, -9.25899982F), new Vector2(16.7929993F, -9.25899982F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
        /// <summary>
        /// Adds the Path Element to the Path.
        /// </summary>
        /// <param name="pathBuilder">CanvasPathBuilder object</param>
        /// <param name="currentPoint">The last active location in the Path before adding
        /// the Path Element</param>
        /// <param name="lastElement">The previous PathElement in the Path.</param>
        /// <returns>The latest location in the Path after adding the Path Element</returns>
        public override Vector2 CreatePath(CanvasPathBuilder pathBuilder, Vector2 currentPoint, ref ICanvasPathElement lastElement)
        {
            // Calculate coordinates
            var controlPoint1 = new Vector2(_x1, _y1);
            var controlPoint2 = new Vector2(_x2, _y2);
            var point         = new Vector2(_x, _y);

            if (IsRelative)
            {
                controlPoint1 += currentPoint;
                controlPoint2 += currentPoint;
                point         += currentPoint;
            }

            // Save the second absolute control point so that it can be used by the following
            // SmoothCubicBezierElement (if any)
            _absoluteControlPoint2 = controlPoint2;

            // Execute command
            pathBuilder.AddCubicBezier(controlPoint1, controlPoint2, point);

            // Set Last Element
            lastElement = this;

            // Return current point
            return(point);
        }
        private void OnSizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
        {
            var length  = (float)Math.Min(e.NewSize.Width, e.NewSize.Height) * 0.95;
            var centerX = (float)e.NewSize.Width / 2;
            var centerY = (float)e.NewSize.Height / 2;

            var points   = new List <Vector2>();
            var r        = length / 2;
            var r2       = r * 1.06;
            var r3       = r * 0.951;
            int index    = 0;
            int segments = 100;

            for (int i = 0; i < segments; i += 2)
            {
                var x = r * Math.Cos(i * 2 * Math.PI / segments) + centerX;
                var y = r * Math.Sin(i * 2 * Math.PI / segments) + centerY;

                points.Add(new Vector2((float)x, (float)y));
                var currentR = index++ % 2 == 0 ? r2 : r3;
                x = currentR * Math.Cos((i + 1) * 2 * Math.PI / segments) + centerX;
                y = currentR * Math.Sin((i + 1) * 2 * Math.PI / segments) + centerY;

                points.Add(new Vector2((float)x, (float)y));
            }

            points.Add(points[0]);



            CanvasGeometry result;

            using (var builder = new CanvasPathBuilder(null))
            {
                builder.BeginFigure(points[0]);
                for (int i = 0; i < points.Count - 2; i += 2)
                {
                    var currentPoint = points[i];
                    var centerPoint  = points[i + 1];
                    var nextPoint    = points[i + 2];
                    builder.AddCubicBezier(currentPoint, centerPoint, nextPoint);
                }
                builder.EndFigure(CanvasFigureLoop.Open);

                result = CanvasGeometry.CreatePath(builder);
            }
            var compositor = Window.Current.Compositor;
            var path       = new CompositionPath(result);
            var line3      = compositor.CreatePathGeometry();

            line3.Path = path;
            var shape3 = compositor.CreateSpriteShape(line3);

            shape3.FillBrush = compositor.CreateColorBrush(Colors.Red);
            var visual = compositor.CreateShapeVisual();

            visual.Shapes.Add(shape3);
            visual.Size = e.NewSize.ToVector2();
            ElementCompositionPreview.SetElementChildVisual(this, visual);
        }
            CanvasGeometry Geometry_0()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(0, -34.5F));
                    builder.AddCubicBezier(new Vector2(19.0540009F, -34.5F), new Vector2(34.5F, -19.0540009F), new Vector2(34.5F, 0));
                    builder.AddCubicBezier(new Vector2(34.5F, 19.0540009F), new Vector2(19.0540009F, 34.5F), new Vector2(0, 34.5F));
                    builder.AddCubicBezier(new Vector2(-19.0540009F, 34.5F), new Vector2(-34.5F, 19.0540009F), new Vector2(-34.5F, 0));
                    builder.AddCubicBezier(new Vector2(-34.5F, -19.0540009F), new Vector2(-19.0540009F, -34.5F), new Vector2(0, -34.5F));
                    builder.EndFigure(CanvasFigureLoop.Open);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 23
0
        private void toMask_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (App.Setting.PenVectorList.Count > 1)
            {
                CanvasPathBuilder VirtualBuilder = new CanvasPathBuilder(App.Model.VirtualControl);
                VirtualBuilder.BeginFigure(App.Setting.PenVectorList[0].Vect);

                CanvasPathBuilder AnimatedBuilder = new CanvasPathBuilder(App.Model.AnimatedControl);
                AnimatedBuilder.BeginFigure(App.Setting.PenVectorList[0].Vect);

                for (int i = 0; i < App.Setting.PenVectorList.Count - 1; i++)//0 to 9
                {
                    Vector2 vl  = App.Setting.PenVectorList[i].Left;
                    Vector2 v1r = App.Setting.PenVectorList[i + 1].Right;
                    Vector2 v1  = App.Setting.PenVectorList[i + 1].Vect;

                    VirtualBuilder.AddCubicBezier(vl, v1r, v1);
                    AnimatedBuilder.AddCubicBezier(vl, v1r, v1);
                }
                VirtualBuilder.EndFigure(CanvasFigureLoop.Closed);
                AnimatedBuilder.EndFigure(CanvasFigureLoop.Closed);

                //几何图形
                CanvasGeometry VirtualGeometry  = CanvasGeometry.CreatePath(VirtualBuilder);
                CanvasGeometry AnimatedGeometry = CanvasGeometry.CreatePath(AnimatedBuilder);

                //几何
                App.Mask(VirtualGeometry, AnimatedGeometry, App.Model.MaskMode); //改变选区与套索

                App.Model.isReStroke = true;                                     //重新设置描边
                App.Judge();                                                     //判断选区,改变是否动画与选区矩形
            }

            flyout.Hide();
        }
Esempio n. 24
0
        private void toStroke_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (App.Setting.PenVectorList.Count > 1)
            {
                CanvasPathBuilder VirtualBuilder = new CanvasPathBuilder(App.Model.VirtualControl);
                VirtualBuilder.BeginFigure(App.Setting.PenVectorList[0].Vect);

                for (int i = 0; i < App.Setting.PenVectorList.Count - 1; i++)//0 to 9
                {
                    Vector2 vl  = App.Setting.PenVectorList[i].Left;
                    Vector2 v1r = App.Setting.PenVectorList[i + 1].Right;
                    Vector2 v1  = App.Setting.PenVectorList[i + 1].Vect;

                    VirtualBuilder.AddCubicBezier(vl, v1r, v1);
                }
                VirtualBuilder.EndFigure(CanvasFigureLoop.Closed);

                using (var ds = App.Model.CurrentRenderTarget.CreateDrawingSession())
                {
                    ds.DrawGeometry(CanvasGeometry.CreatePath(VirtualBuilder), App.Model.PenColor, App.Setting.PenWidth, App.Setting.PenStrokeStyle);
                }
                App.Model.Layers[App.Model.Index].SetWriteableBitmap(App.Model.VirtualControl); //刷新缩略图
                App.Model.isReRender = true;                                                    //重新渲染
                App.Model.Refresh++;                                                            //画布刷新
            }

            flyout.Hide();
        }
Esempio n. 25
0
            // - - - Layer aggregator
            // - -  Scale:0.70016,1.05751, Offset:<202, 162>
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(3F, -54F));
                    builder.AddCubicBezier(new Vector2(22.2800007F, -39.7159996F), new Vector2(51F, 26F), new Vector2(0F, 53F));
                    builder.AddCubicBezier(new Vector2(17.1389999F, 58.6279984F), new Vector2(43.5250015F, 26.9519997F), new Vector2(40.9780006F, -6.6079998F));
                    builder.AddCubicBezier(new Vector2(39.7750015F, -22.4619999F), new Vector2(30.8500004F, -43.4980011F), new Vector2(3F, -54F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 26
0
        internal override void Draw(CanvasControl cc, CanvasDrawingSession ds, float scale, Vector2 center, FlipState flip)
        {
            var color  = GetColor(Coloring.Normal);
            var points = GetDrawingPoints(flip, scale, center);

            using (var pb = new CanvasPathBuilder(cc))
            {
                pb.BeginFigure(points[0]);
                var N = DXY.Count;
                for (var i = 0; i < N - 2;)
                {
                    pb.AddCubicBezier(points[i], points[++i], points[++i]);
                }
                pb.EndFigure(CanvasFigureLoop.Open);

                using (var geo = CanvasGeometry.CreatePath(pb))
                {
                    if (FillStroke == Fill_Stroke.Filled)
                    {
                        ds.FillGeometry(geo, color);
                    }
                    else
                    {
                        ds.DrawGeometry(geo, color, StrokeWidth, StrokeStyle());
                    }
                }
            }
        }
Esempio n. 27
0
            // - - - Shape tree root for layer: icon
            // - - ShapeGroup: Group 1
            CanvasGeometry Geometry_1()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);
                    builder.BeginFigure(new Vector2(24.4990005F, 65.0039978F));
                    builder.AddCubicBezier(new Vector2(22.1809998F, 76.413002F), new Vector2(12.0930004F, 85F), new Vector2(0F, 85F));
                    builder.AddCubicBezier(new Vector2(-12.0930004F, 85F), new Vector2(-22.1809998F, 76.413002F), new Vector2(-24.4990005F, 65.0039978F));
                    builder.AddLine(new Vector2(24.4990005F, 65.0039978F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 28
0
        /// <summary>
        /// Adds the Path Element to the Path.
        /// </summary>
        /// <param name="pathBuilder">CanvasPathBuilder object</param>
        /// <param name="currentPoint">The last active location in the Path before adding
        /// the Path Element</param>
        /// <param name="lastElement">The previous PathElement in the Path.</param>
        /// <param name="logger">For logging purpose. To log the set of CanvasPathBuilder
        /// commands, used for creating the CanvasGeometry, in string format.</param>
        /// <returns>The latest location in the Path after adding the Path Element</returns>
        public override Vector2 CreatePath(CanvasPathBuilder pathBuilder, Vector2 currentPoint,
                                           ref ICanvasPathElement lastElement, StringBuilder logger)
        {
            // Calculate coordinates
            var controlPoint1 = new Vector2(_x1, _y1);
            var controlPoint2 = new Vector2(_x2, _y2);
            var point         = new Vector2(_x, _y);

            if (IsRelative)
            {
                controlPoint1 += currentPoint;
                controlPoint2 += currentPoint;
                point         += currentPoint;
            }

            // Save the second absolute control point so that it can be used by the following
            // SmoothCubicBezierElement (if any)
            _absoluteControlPoint2 = controlPoint2;

            // Execute command
            pathBuilder.AddCubicBezier(controlPoint1, controlPoint2, point);

            // Log command
            logger?.Append($"{Indent}pathBuilder.AddCubicBezier(new Vector2({controlPoint1.X}, {controlPoint1.Y})");
            logger?.Append($", new Vector2({controlPoint2.X}, {controlPoint2.Y})");
            logger?.AppendLine($", new Vector2({point.X}, {point.Y}));");

            // Set Last Element
            lastElement = this;
            // Return current point
            return(point);
        }
Esempio n. 29
0
            // - - - - - Shape tree root for layer: icon
            // - - - -  Offset:<-3.8320007, 0>
            // - - - Path 2+Path 1.PathGeometry
            // - - Path
            CanvasGeometry Geometry_08()
            {
                CanvasGeometry result;

                using (var builder = new CanvasPathBuilder(null))
                {
                    builder.BeginFigure(new Vector2(20F, 55F));
                    builder.AddCubicBezier(new Vector2(36.5690002F, 55F), new Vector2(50F, 30.3759995F), new Vector2(50F, 0F));
                    builder.AddCubicBezier(new Vector2(50F, -30.3759995F), new Vector2(36.5690002F, -55F), new Vector2(20F, -55F));
                    builder.AddCubicBezier(new Vector2(3.43099999F, -55F), new Vector2(-10F, -30.3759995F), new Vector2(-10F, 0F));
                    builder.AddCubicBezier(new Vector2(-10F, 30.3759995F), new Vector2(3.43099999F, 55F), new Vector2(20F, 55F));
                    builder.EndFigure(CanvasFigureLoop.Closed);
                    result = CanvasGeometry.CreatePath(builder);
                }
                return(result);
            }
Esempio n. 30
0
        public void VerifySendPathTo()
        {
            //
            // This calls each of the path functions, once, and verfies that it works.
            // Sink behavior is verified in more detail in the geometry unit tests.
            //
            CanvasDevice device = new CanvasDevice();

            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(device);

            pathBuilder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Alternate);
            pathBuilder.BeginFigure(0, 0);
            pathBuilder.AddLine(0, 0);
            pathBuilder.AddQuadraticBezier(new Vector2(), new Vector2());
            pathBuilder.AddCubicBezier(new Vector2(), new Vector2(), new Vector2());

            // D2D tries to be smart about degenerate arcs and redundant set segment options, and may sometimes actually
            // surpress them. Therefore, these calls use non-defaults.
            pathBuilder.AddArc(new Vector2 {
                X = 100, Y = 100
            }, 10, 10, 90, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
            pathBuilder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceUnstroked);

            pathBuilder.EndFigure(CanvasFigureLoop.Closed);

            CanvasGeometry pathGeometry = CanvasGeometry.CreatePath(pathBuilder);

            MyGeometryStreamReader myStreamReader = new MyGeometryStreamReader();

            pathGeometry.SendPathTo(myStreamReader);

            myStreamReader.Verify();
        }
Esempio n. 31
0
        public void Draw(object ds, XBezier bezier, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _ds = ds as CanvasDrawingSession;

            double thickness = bezier.Style.Thickness / _state.Zoom;
            var brush = ToColor(bezier.Style.Fill);
            var pen = ToColor(bezier.Style.Stroke);
            var ss = CreateStrokeStyle(bezier.Style);

            CanvasGeometry g;
            using (var builder = new CanvasPathBuilder(_ds))
            {
                builder.BeginFigure((float)bezier.Point1.X, (float)bezier.Point1.Y);
                builder.AddCubicBezier(
                    new N.Vector2(
                        (float)bezier.Point2.X,
                        (float)bezier.Point2.Y),
                    new N.Vector2(
                        (float)bezier.Point3.X,
                        (float)bezier.Point3.Y),
                    new N.Vector2(
                        (float)bezier.Point4.X,
                        (float)bezier.Point4.Y));
                builder.EndFigure(CanvasFigureLoop.Open);
                g = CanvasGeometry.CreatePath(builder);
            }

            if (bezier.IsFilled)
            {
                _ds.FillGeometry(g, brush);
            }

            if (bezier.IsStroked)
            {
                _ds.DrawGeometry(g, pen, (float)thickness, ss);
            }

            g.Dispose();
            ss.Dispose();
        }
Esempio n. 32
0
        void DrawBezier(CanvasDrawingSession drawingSession, Vector2 start, Vector2 ctrl0, Vector2 ctrl1, Vector2 end)
        {
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(canvasControl);
            pathBuilder.BeginFigure(start);
            pathBuilder.AddCubicBezier(ctrl0, ctrl1, end);
            pathBuilder.EndFigure(CanvasFigureLoop.Open);

            CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);
            drawingSession.DrawGeometry(geometry, Colors.White, 5.0f);            
        }
Esempio n. 33
0
        CanvasGeometry MakeConvexGeometry()
        {
            if (currentPointsInContact.Count == 0)
                return null;

            var hull = ConvexHull.Create(currentPointsInContact.Values.Select(x => x.ToVector2()));

            // Figure out where the center is
            var hullCenter = Vector2.Zero;
            foreach (var p in hull)
            {
                hullCenter += p;
            }
            hullCenter /= hull.Count;

            // Build the geometry, made up of arcs around the hull
            using (var builder = new CanvasPathBuilder(device))
            {
                builder.BeginFigure(hull[0]);

                for (int i = 1; i <= hull.Count; ++i)
                {
                    //
                    // i-2 --- i-1 ---  i  --- i+1
                    //  a  ---  b  ---  c  ---  d
                    //
                    // The bezier is between i-1 and i.  We need to figure out the control points
                    // that make this smooth.

                    var a = hull[(i + hull.Count - 2) % hull.Count];
                    var b = hull[(i + hull.Count - 1) % hull.Count];
                    var c = hull[i % hull.Count];
                    var d = hull[(i + 1) % hull.Count];

                    var ab = Vector2.Normalize(b - a);
                    var bc = Vector2.Normalize(c - b);
                    var cp1 = b + Vector2.Normalize(ab + bc) * (c - b).Length() * 0.5f;

                    var cd = Vector2.Normalize(d - c);
                    var cp2 = c - Vector2.Normalize(bc + cd) * (c - b).Length() * 0.5f;

                    builder.AddCubicBezier(cp1, cp2, c);
                }

                builder.EndFigure(CanvasFigureLoop.Closed);

                return CanvasGeometry.CreatePath(builder);
            }
        }
Esempio n. 34
0
 /// <summary>
 /// Draws a raindrop on canvas at the current position.
 /// </summary>
 public void Draw(RainyDay rainyday, CanvasDrawingSession context)
 {
     float orgR = r;
     r = 0.95f * r;
     if (r < 3)
     {
         clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), r);
     }
     else if (colliding != null || yspeed > 2)
     {
         if (colliding != null)
         {
             var collider = colliding;
             r = 1.001f * (r > collider.r ? r : collider.r);
             x += (collider.x - x);
             colliding = null;
         }
         float yr = 1 + 0.1f * yspeed;
         using (CanvasPathBuilder path = new CanvasPathBuilder(context))
         {
             path.BeginFigure(x - r / yr, y);
             path.AddCubicBezier(new Vector2(x - r, y - r * 2), new Vector2(x + r, y - r * 2), new Vector2(x + r / yr, y));
             path.AddCubicBezier(new Vector2(x + r, y + yr * r), new Vector2(x - r, y + yr * r), new Vector2(x - r / yr, y));
             path.EndFigure(CanvasFigureLoop.Closed);
             clipGeo = CanvasGeometry.CreatePath(path);
         }
     }
     else
     {
         clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), 0.9f * r);
     }
     r = orgR;
     if (rainyday.Reflection != null)
     {
         using (context.CreateLayer(1, clipGeo))
         {
             rainyday.Reflection(context, this);
         }
     }
     if (clipGeo != null)
     {
         clipGeo.Dispose();
     }
 }
        private static CanvasGeometry CreateHeart(ICanvasResourceCreator resourceCreator, float scale, Vector2 center)
        {
            center = center - new Vector2(center.X / 2, center.Y / 2);
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(resourceCreator);
            var begin = new Vector2(0.47f, 0.34f) * scale + center;
            pathBuilder.BeginFigure(begin);
            pathBuilder.AddCubicBezier(new Vector2(0.66f, 0.19f) * scale + center, new Vector2(0.88f, 0.30f) * scale + center, new Vector2(0.88f, 0.48f) * scale + center);
            pathBuilder.AddCubicBezier(new Vector2(0.88f, 0.66f) * scale + center, new Vector2(0.49f, 1) * scale + center, new Vector2(0.49f, 1)* scale + center);
            pathBuilder.AddCubicBezier(new Vector2(0.49f, 1) * scale + center, new Vector2(0, 0.66f) * scale + center, new Vector2(0, 0.48f) * scale + center);
            pathBuilder.AddCubicBezier(new Vector2(0, 0.30f) * scale + center, new Vector2(0.33f, 0.19f) * scale + center, begin);

            pathBuilder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);
            pathBuilder.EndFigure(CanvasFigureLoop.Closed);
            var geometry = CanvasGeometry.CreatePath(pathBuilder);
            return geometry;
        }
        //private static Bitmap _textBMP = new Bitmap(2, 2);
        //private static Graphics _g = Graphics.FromImage(_textBMP);
        //private static Matrix _identityMatrix = new Matrix();
        //private static int _fontSize = RS.getModifierFontSize();
        //private static FontStyle _fontStyle = RS.getModifierFontStyle();
        //private static String _fontName = RS.getModifierFontName();
        //private static int _modifierFontHeight = ShapeUtilities.round(_g.MeasureString("Hj", RS.getLabelFont()).Height);
        //private static Font _modifierFont = RS.getLabelFont();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="symbolID"></param>
        /// <param name="msb"></param>
        /// <param name="modifiers"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        public static ImageInfo ProcessUnitDisplayModifiers(String symbolID, ImageInfo ii, Dictionary<int, String> modifiers, Dictionary<int, String> attributes, Boolean hasTextModifiers, CanvasDevice device)
        {
            ImageInfo newii = null;
            Rect symbolBounds = ShapeUtilities.clone(ii.getSymbolBounds());
            Rect imageBounds = ShapeUtilities.clone(ii.getCanvasRenderTarget().GetBounds(device));
            Point centerPoint = ShapeUtilities.clone(ii.getAnchorPoint());
            TextInfo tiEchelon = null;
            TextInfo tiAM = null;
            Rect echelonBounds = Rect.Empty;
            Rect amBounds = Rect.Empty;
            Color textColor = Colors.Black;
            Color textBackgroundColor = Colors.Transparent;
            int buffer = 0;
            //ctx = null;
            int offsetX = 0;
            int offsetY = 0;
            int symStd = RS.getSymbologyStandard();
            CanvasTextFormat font = RS.getLabelFont();
            /*Pen mobilityPen = new Pen(Colors.Black, 2f);
            mobilityPen.MiterLimit = 2;//*/

            try
            {
                if(device == null)
                {
                    device = CanvasDevice.GetSharedDevice();
                }

                if (attributes.ContainsKey(MilStdAttributes.SymbologyStandard))
                {
                    symStd = Convert.ToInt16(attributes[MilStdAttributes.SymbologyStandard]);
                }
                if (attributes.ContainsKey(MilStdAttributes.TextColor))
                {
                    textColor = SymbolUtilities.getColorFromHexString(attributes[MilStdAttributes.TextColor]);
                }
                if (attributes.ContainsKey(MilStdAttributes.TextBackgroundColor))
                {
                    textBackgroundColor = SymbolUtilities.getColorFromHexString(attributes[MilStdAttributes.TextBackgroundColor]);
                }

                #region Build Mobility Modifiers

                Rect mobilityBounds = Rect.Empty;

                List<CanvasGeometry> shapes = new List<CanvasGeometry>();
                CanvasPathBuilder mobilityPath = null;
                CanvasPathBuilder mobilityPathFill = null;
                CanvasGeometry cgMobilityPath = null;
                CanvasGeometry cgMobilityPathFill = null;
                if (symbolID[10] == ('M') || symbolID[10] == ('N'))
                {

                    //Draw Mobility
                    int fifth = (int)((symbolBounds.Width * 0.2) + 0.5f);
                    mobilityPath = new CanvasPathBuilder(device);
                    int x = 0;
                    int y = 0;
                    int centerX = 0;
                    int bottomY = 0;
                    int height = 0;
                    int width = 0;
                    int middleY = 0;
                    int wheelOffset = 2;
                    int wheelSize = fifth;//10;
                    int rrHeight = fifth;//10;
                    int rrArcWidth = (int)((fifth * 1.5) + 0.5f);//16;

                    String mobility = symbolID.Substring(10, 2);
                    x = (int)symbolBounds.Left;
                    y = (int)symbolBounds.Top;
                    height = (int)(symbolBounds.Height);
                    width = (int)(symbolBounds.Width);
                    bottomY = y + height + 2;

                    if (symbolID[10] == ('M'))
                    {
                        bottomY = y + height + 2;

                        //wheelSize = width / 7;
                        //rrHeight = width / 7;
                        //rrArcWidth = width / 7;
                        if (mobility.Equals("MO"))
                        {
                            //line
                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddLine(x + width, bottomY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(x, bottomY, x + width, bottomY);

                            //left circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device,new Vector2(x, bottomY + wheelOffset),wheelSize,wheelSize));
                            //mobilityPath.AddEllipse(x, bottomY + wheelOffset, wheelSize, wheelSize);


                            //right circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new System.Numerics.Vector2(x + width - wheelSize, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + width - wheelSize, bottomY + wheelOffset, wheelSize, wheelSize);

                        }
                        else if (mobility.Equals("MP"))
                        {
                            //line
                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddLine(x + width, bottomY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //PathUtilties.AddLine(mobilityPath, x, bottomY, x + width, bottomY);

                            //left circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x, bottomY + wheelOffset), wheelSize, wheelSize));

                            //right circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + width - wheelSize, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + width - wheelSize, bottomY + wheelOffset, wheelSize, wheelSize);

                            //center wheel
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + (width / 2) - (wheelSize / 2), bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + (width / 2) - (wheelSize / 2), bottomY + wheelOffset, wheelSize, wheelSize);
                            
                        }
                        else if (mobility.Equals("MQ"))
                        {
                            //round Rect
                            mobilityPath.AddGeometry(CanvasGeometry.CreateRoundedRectangle(device, x, bottomY, width, rrHeight, rrHeight / 2, rrHeight / 2));
                            //mobilityPath.AddPath(ShapeUtilities.createRoundedRect(new Rect(x, bottomY, width, rrHeight), rrHeight / 2), false);

                        }
                        else if (mobility.Equals("MR"))
                        {
                            //round Rect
                            mobilityPath.AddGeometry(CanvasGeometry.CreateRoundedRectangle(device, x, bottomY, width, rrHeight, rrHeight / 2, rrHeight / 2));
                            //mobilityPath.AddPath(ShapeUtilities.createRoundedRect(new Rect(x, bottomY, width, rrHeight), wheelSize / 2), false);

                            //left circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x - wheelSize - wheelSize, bottomY), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x - wheelSize - wheelSize, bottomY, wheelSize, wheelSize);
                            
                        }
                        else if (mobility.Equals("MS"))
                        {
                            //line
                            mobilityPath.BeginFigure(x + wheelSize, bottomY + (wheelSize / 2));
                            mobilityPath.AddLine(x + width - wheelSize, bottomY + (wheelSize / 2));
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            /*mobilityPath.AddLine(x + wheelSize, bottomY + (wheelSize / 2),
                                    x + width - wheelSize, bottomY + (wheelSize / 2));//*/


                            //left circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x, bottomY), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x, bottomY, wheelSize, wheelSize);

                            //right circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + width - wheelSize, bottomY), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + width - wheelSize, bottomY, wheelSize, wheelSize);

                        }
                        else if (mobility.Equals("MT"))
                        {

                            //line
                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddLine(x + width, bottomY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(x, bottomY, x + width, bottomY);

                            //left circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + wheelSize, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + wheelSize, bottomY + wheelOffset, wheelSize, wheelSize);

                            //left circle2
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x, bottomY + wheelOffset, wheelSize, wheelSize);

                            //right circle
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + width - wheelSize, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + width - wheelSize, bottomY + wheelOffset, wheelSize, wheelSize);

                            //right circle2
                            mobilityPath.AddGeometry(CanvasGeometry.CreateEllipse(device, new Vector2(x + width - wheelSize - wheelSize, bottomY + wheelOffset), wheelSize, wheelSize));
                            //mobilityPath.AddEllipse(x + width - wheelSize - wheelSize, bottomY + wheelOffset, wheelSize, wheelSize);

                        }
                        else if (mobility.Equals("MU"))
                        {
                            float halfWidth = (rrArcWidth * 0.5f);
                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddLine(x + halfWidth, bottomY + halfWidth);
                            mobilityPath.AddLine(x + width, bottomY + halfWidth);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                           /* mobilityPath.AddLine(x, bottomY, x + halfWidth, bottomY + halfWidth);
                            mobilityPath.AddLine(x + halfWidth, bottomY + halfWidth, x + width, bottomY + halfWidth);//*/
                        }
                        else if (mobility.Equals("MV"))
                        {
                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddCubicBezier(new Vector2(x, bottomY), new Vector2(x - rrHeight, bottomY + rrHeight / 2), new Vector2(x, bottomY + rrHeight));
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddBezier(x, bottomY, x, bottomY, x - rrHeight, bottomY + rrHeight / 2, x, bottomY + rrHeight);

                            mobilityPath.BeginFigure(x, bottomY + rrHeight);
                            mobilityPath.AddLine(x + width, bottomY + rrHeight);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(x, bottomY + rrHeight, x + width, bottomY + rrHeight);


                            mobilityPath.BeginFigure(x + width, bottomY + rrHeight);
                            mobilityPath.AddCubicBezier(new Vector2(x + width, bottomY + rrHeight), new Vector2(x + width + rrHeight, bottomY + rrHeight / 2), new Vector2(x + width, bottomY));
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddBezier(x + width, bottomY + rrHeight, x + width, bottomY + rrHeight, x + width + rrHeight, bottomY + rrHeight / 2, x + width, bottomY);

                        }
                        else if (mobility.Equals("MW"))
                        {
                            centerX = (int)((symbolBounds.X + (symbolBounds.Width / 2)) + 0.5);
                            int angleWidth = rrHeight / 2;

                            mobilityPath.BeginFigure(centerX, bottomY + rrHeight + 2);
                            mobilityPath.AddLine(centerX - angleWidth, bottomY);
                            mobilityPath.AddLine(centerX - angleWidth * 2, bottomY + rrHeight + 2);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(centerX, bottomY + rrHeight + 2, centerX - angleWidth, bottomY);
                            //mobilityPath.AddLine(centerX - angleWidth, bottomY, centerX - angleWidth * 2, bottomY + rrHeight + 2);

                            mobilityPath.BeginFigure(centerX, bottomY + rrHeight + 2);
                            mobilityPath.AddLine(centerX + angleWidth, bottomY);
                            mobilityPath.AddLine(centerX + angleWidth * 2, bottomY + rrHeight + 2);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.StartFigure();
                            //mobilityPath.AddLine(centerX, bottomY + rrHeight + 2, centerX + angleWidth, bottomY);
                            //mobilityPath.AddLine(centerX + angleWidth, bottomY, centerX + angleWidth * 2, bottomY + rrHeight + 2);

                        }
                        else if (mobility.Equals("MX"))
                        {
                            centerX = (int)((symbolBounds.X + (symbolBounds.Width / 2)) + 0.5);

                            mobilityPath.BeginFigure(x + width, bottomY);
                            mobilityPath.AddLine(x, bottomY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(x + width, bottomY, x, bottomY);


                            float quarterX = (centerX - x) / 2;
                            ////var quarterY = (((bottomY + rrHeight) - bottomY)/2);

                            mobilityPath.BeginFigure(x, bottomY);
                            mobilityPath.AddCubicBezier(new Vector2(x + quarterX, bottomY + rrHeight), new Vector2(centerX + quarterX, bottomY + rrHeight), new Vector2(x + width, bottomY));
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddBezier(x, bottomY, x + quarterX, bottomY + rrHeight, centerX + quarterX, bottomY + rrHeight, x + width, bottomY);

                        }

                        else if (mobility.Equals("MY"))
                        {
                            float incrementX = width / 7f;

                            x = (int)Math.Floor(symbolBounds.X);
                            float r = incrementX;

                            //mobilityPath.arcTo(oval, sAngle, sAngle, moveTo);
                            mobilityPath.AddArc(new Vector2(x, bottomY), r, r, 180, 180);
                            mobilityPath.AddArc(new Vector2(x + incrementX, bottomY), r, r, 180, -180);
                            mobilityPath.AddArc(new Vector2(x + incrementX * 2, bottomY), r, r, 180, 180);
                            mobilityPath.AddArc(new Vector2(x + incrementX * 3, bottomY), r, r, 180, -180);
                            mobilityPath.AddArc(new Vector2(x + incrementX * 4, bottomY), r, r, 180, 180);
                            mobilityPath.AddArc(new Vector2(x + incrementX * 5, bottomY), r, r, 180, -180);
                            mobilityPath.AddArc(new Vector2(x + incrementX * 6, bottomY), r, r, 180, 180);

                        }

                    }
                    //Draw Towed Array Sonar
                    else if (symbolID[10] == ('N'))
                    {

                        int boxHeight = (int)((rrHeight * 0.8f) + 0.5f);
                        bottomY = y + height + (boxHeight / 7);
                        mobilityPathFill = new CanvasPathBuilder(device);
                        offsetY = ShapeUtilities.round(boxHeight / 6);//1;
                        centerX = (int)((symbolBounds.X + (symbolBounds.Width / 2)) + 0.5);
                        int squareOffset = (int)((boxHeight * 0.5f) + 0.5);
                        middleY = ((boxHeight / 2) + bottomY) + offsetY;//+1 for offset from symbol
                        if (symbolID.Substring(10, 2).Equals("NS"))
                        {
                            //subtract 0.5 becase lines 1 pixel thick get aliased into
                            //a line two pixels wide.
                            //line
                            mobilityPath.BeginFigure(centerX - 1, bottomY - 1);
                            mobilityPath.AddLine(centerX - 1, bottomY + boxHeight + offsetY + 2);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(centerX - 1, bottomY - 1, centerX - 1, bottomY + boxHeight + offsetY + 2);


                            //line
                            mobilityPath.BeginFigure(x, middleY);
                            mobilityPath.AddLine(x + width, middleY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.StartFigure();
                            //mobilityPath.AddLine(x, middleY, x + width, middleY);


                            //square
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, x - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(x - squareOffset, bottomY + offsetY, boxHeight, boxHeight));


                            //square
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, centerX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(centerX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                            //square
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, x + width - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(x + width - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                        }
                        else if (symbolID.Substring(10, 2).Equals("NL"))
                        {
                            int leftX = x + (centerX - x) / 2,
                                    rightX = centerX + (x + width - centerX) / 2;

                            //line vertical left
                            mobilityPath.BeginFigure(leftX, bottomY - 1);
                            mobilityPath.AddLine(leftX, bottomY + offsetY + boxHeight + offsetY + 2);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.AddLine(leftX, bottomY - 1, leftX, bottomY + offsetY + boxHeight + offsetY + 2);


                            //line vertical right
                            mobilityPath.BeginFigure(rightX, bottomY - 1);
                            mobilityPath.AddLine(rightX, bottomY + offsetY + boxHeight + offsetY + 2);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.StartFigure();
                            //mobilityPath.AddLine(rightX, bottomY - 1, rightX, bottomY + offsetY + boxHeight + offsetY + 2);


                            //line horizontal
                            mobilityPath.BeginFigure(x, middleY);
                            mobilityPath.AddLine(x + width, middleY);
                            mobilityPath.EndFigure(CanvasFigureLoop.Open);
                            //mobilityPath.StartFigure();
                            //mobilityPath.AddLine(x, middleY, x + width, middleY);
                            

                            //square left
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, x - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(x - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                            //square middle
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, centerX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(centerX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                            //square right
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, x + width - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(x + width - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                            //square middle left
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, leftX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(leftX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));

                            //square middle right
                            mobilityPathFill.AddGeometry(CanvasGeometry.CreateRectangle(device, rightX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));
                            //mobilityPathFill.AddRect(new Rect(rightX - squareOffset, bottomY + offsetY, boxHeight, boxHeight));


                        }
                    }

                    //get mobility bounds
                    if (mobilityPath != null)
                    {

                        //build mobility bounds
                        cgMobilityPath = CanvasGeometry.CreatePath(mobilityPath);
                        mobilityBounds = cgMobilityPath.ComputeBounds();


                        Rect mobilityFillBounds = new Rect();
                        if (mobilityPathFill != null)
                        {
                            cgMobilityPathFill = CanvasGeometry.CreatePath(mobilityPathFill);
                            mobilityFillBounds = cgMobilityPathFill.ComputeBounds();
                        }

                        //grow because we use a line thickness of 2.
                        mobilityBounds = new Rect(mobilityBounds.X - 1, mobilityBounds.Y - 1, mobilityBounds.Width+2, mobilityBounds.Height+2);
                        //mobilityBounds.Inflate(1f, 1f);
                        imageBounds = ShapeUtilities.union(imageBounds, mobilityBounds);
                    }
                }

                #endregion

                #region Build Echelon
                //Draw Echelon
                String strEchelon = SymbolUtilities.getEchelon(symbolID);//symbolID.substring(11, 12);
                if (strEchelon != null)
                {
                    strEchelon = SymbolUtilities.getEchelonText(strEchelon);
                }
                if (strEchelon != null && SymbolUtilities.hasInstallationModifier(symbolID) == false
                        && SymbolUtilities.canUnitHaveModifier(symbolID, ModifiersUnits.B_ECHELON))
                {

                    if (strEchelon != null)
                    {
                        int outlineOffset = RS.getTextOutlineWidth();

                        //tiEchelon = new TextInfo(strEchelon, 0, 0, font, _g);
                        tiEchelon = new TextInfo(device, strEchelon);
                        
                        echelonBounds = tiEchelon.getTextBounds();

                        int y = (int)Math.Round(symbolBounds.Top - echelonBounds.Height);
                        int x = (int)Math.Round(symbolBounds.Left + (symbolBounds.Width / 2) - (echelonBounds.Width / 2));
                        tiEchelon.setLocation(x, y);
                        echelonBounds = tiEchelon.getTextBounds();

                        //There will never be lowercase characters in an echelon so trim that fat.    
                        //Remove the descent from the bounding box.
                        //tiEchelon.getTextOutlineBounds();//.shiftBR(0,ShapeUtilities.round(-(echelonBounds.Height*0.3)));                         

                        //make echelon bounds a little more spacious for things like nearby labels and Task Force.
                        //echelonBounds.Inflate(outlineOffset, outlineOffset);// ShapeUtilities.grow(echelonBounds, outlineOffset);
                        //tiEchelon.getTextOutlineBounds();
                        //                RectUtilities.shift(echelonBounds, x, -outlineOffset);
                        //echelonBounds.shift(0,-outlineOffset);// - ShapeUtilities.round(echelonOffset/2));
                        //tiEchelon.setLocation(x, y - outlineOffset);

                        imageBounds = ShapeUtilities.union(imageBounds, echelonBounds);

                    }
                }
                #endregion

                #region Build Affiliation Modifier
                String affiliationModifier = null;
                if (RS.getDrawAffiliationModifierAsLabel() == false)
                {
                    affiliationModifier = SymbolUtilities.getUnitAffiliationModifier(symbolID, symStd);
                }
                if (affiliationModifier != null)
                {

                    int amOffset = 2;
                    int outlineOffset = RS.getTextOutlineWidth();

                    tiAM = new TextInfo(device,affiliationModifier);
                    amBounds = tiAM.getTextBounds();

                    double x, y;

                    if (echelonBounds != Rect.Empty
                            && ((echelonBounds.Left + echelonBounds.Width > symbolBounds.Left + symbolBounds.Width)))
                    {
                        y = (symbolBounds.Top - amOffset);
                        x = echelonBounds.Left + echelonBounds.Width;
                    }
                    else
                    {
                        y = (symbolBounds.Top - amOffset);
                        x = (symbolBounds.Left + symbolBounds.Width);
                    }
                    tiAM.setLocation(x, y);

                    //adjust for outline.
                    amBounds = tiAM.getTextBoundsWithOutline();
                    tiAM.shift(-outlineOffset, -outlineOffset);

                    imageBounds = ShapeUtilities.union(imageBounds, amBounds);
                }
                #endregion

                #region Build Task Force
                Rect tfBounds = Rect.Empty;
                Rect tfRect = Rect.Empty;
                if (SymbolUtilities.isTaskForce(symbolID))
                {
                    if (echelonBounds != Rect.Empty)
                    {
                        tfRect = new Rect(echelonBounds.X, echelonBounds.Y, echelonBounds.Width, symbolBounds.Y - echelonBounds.Y);
                        tfBounds = ShapeUtilities.clone(tfRect);
                    }
                    else
                    {
                        double height = (symbolBounds.Height / 4);
                        double width = (symbolBounds.Width / 3);

                        tfRect = new Rect(symbolBounds.Left + width,
                                symbolBounds.Top - height,
                                width,
                                height);

                        tfBounds = new Rect(tfRect.Left + -1,
                                tfRect.Top - 1,
                                tfRect.Width + 2,
                                tfRect.Height + 2);

                    }
                    imageBounds = ShapeUtilities.union(imageBounds, tfBounds);
                }
                #endregion

                #region Build Feint Dummy Indicator
                Rect fdiBounds = Rect.Empty;
                Point fdiTop = new Point();// Point.Empty;
                Point fdiLeft = new Point();
                Point fdiRight = new Point();

                if (SymbolUtilities.isFeintDummy(symbolID)
                        || SymbolUtilities.isFeintDummyInstallation(symbolID))
                {
                    //create feint indicator /\
                    fdiLeft = new Point(symbolBounds.Left, symbolBounds.Top);
                    fdiRight = new Point((symbolBounds.Left + symbolBounds.Width), symbolBounds.Top);

                    char affiliation = symbolID[1];
                    if (affiliation == ('F')
                            || affiliation == ('A')
                            || affiliation == ('D')
                            || affiliation == ('M')
                            || affiliation == ('J')
                            || affiliation == ('K'))
                    {
                        fdiTop = new Point((ShapeUtilities.getCenterX(symbolBounds)), ShapeUtilities.round(symbolBounds.Top - (symbolBounds.Height * .75f)));
                    }
                    else
                    {
                        fdiTop = new Point((ShapeUtilities.getCenterX(symbolBounds)), ShapeUtilities.round(symbolBounds.Top - (symbolBounds.Height * .54f)));
                    }

                    fdiBounds = new Rect(fdiLeft.X, fdiLeft.Y, 1, 1);
                    fdiBounds = ShapeUtilities.union(fdiBounds, fdiTop);
                    fdiBounds = ShapeUtilities.union(fdiBounds, fdiRight);

                    if (echelonBounds != null)
                    {
                        double shiftY = (symbolBounds.Top - echelonBounds.Height - 2);
                        fdiLeft.Y = fdiLeft.Y + shiftY;
                        fdiTop.Y = fdiLeft.Y + shiftY;
                        fdiRight.Y = fdiLeft.Y + shiftY;
                        fdiBounds.Y = fdiLeft.Y + shiftY;
                        /*(fdiLeft.Offset(0, shiftY);
                        fdiTop.Offset(0, shiftY);
                        fdiRight.Offset(0, shiftY);
                        fdiBounds.Offset(0, shiftY);//*/
                    }

                    imageBounds = ShapeUtilities.union(imageBounds, fdiBounds);

                }
                #endregion

                #region Build Installation
                Rect instRect = Rect.Empty;
                Rect instBounds = Rect.Empty;
                if (SymbolUtilities.hasInstallationModifier(symbolID))
                {//the actual installation symbols have the modifier
                    //built in.  everything else, we have to draw it.
                    //
                    ////get indicator dimensions////////////////////////////////
                    int width;
                    int height;
                    char affiliation = SymbolUtilities.getAffiliation(symbolID);

                    if (affiliation == 'F'
                            || affiliation == 'A'
                            || affiliation == 'D'
                            || affiliation == 'M'
                            || affiliation == 'J'
                            || affiliation == 'K')
                    {
                        //4th height, 3rd width
                        height = ShapeUtilities.round(symbolBounds.Height / 4);
                        width = ShapeUtilities.round(symbolBounds.Width / 3);
                    }
                    else if (affiliation == 'H' || affiliation == 'S')//hostile,suspect
                    {
                        //6th height, 3rd width
                        height = ShapeUtilities.round(symbolBounds.Height / 6);
                        width = ShapeUtilities.round(symbolBounds.Width / 3);
                    }
                    else if (affiliation == 'N' || affiliation == 'L')//neutral,exercise neutral
                    {
                        //6th height, 3rd width
                        height = ShapeUtilities.round(symbolBounds.Height / 6);
                        width = ShapeUtilities.round(symbolBounds.Width / 3);
                    }
                    else if (affiliation == 'P'
                            || affiliation == 'U'
                            || affiliation == 'G'
                            || affiliation == 'W')
                    {
                        //6th height, 3rd width
                        height = ShapeUtilities.round(symbolBounds.Height / 6);
                        width = ShapeUtilities.round(symbolBounds.Width / 3);
                    }
                    else
                    {
                        //6th height, 3rd width
                        height = ShapeUtilities.round(symbolBounds.Height / 6);
                        width = ShapeUtilities.round(symbolBounds.Width / 3);
                    }

                    //                    if(width * 3 < symbolBounds.Width)
                    //                        width++;
                    //set installation position/////////////////////////////////
                    //set position of indicator
                    if (affiliation == 'F'
                            || affiliation == 'A'
                            || affiliation == 'D'
                            || affiliation == 'M'
                            || affiliation == 'J'
                            || affiliation == 'K'
                            || affiliation == 'N'
                            || affiliation == 'L')
                    {
                        instRect = new Rect((int)(symbolBounds.Left + width),
                                (int)(symbolBounds.Top - height),
                                width,
                                height);
                    }
                    else if (affiliation == 'H' || affiliation == 'S')//hostile,suspect
                    {
                        instRect = new Rect((int)symbolBounds.Left + width,
                                ShapeUtilities.round(symbolBounds.Top - (height * 0.15f)),
                                width,
                                height);
                    }
                    else if (affiliation == 'P'
                            || affiliation == 'U'
                            || affiliation == 'G'
                            || affiliation == 'W')
                    {
                        instRect = new Rect((int)symbolBounds.Left + width,
                                ShapeUtilities.round(symbolBounds.Top - (height * 0.3f)),
                                width,
                                height);
                    }
                    else
                    {
                        instRect = new Rect((int)symbolBounds.Left + width,
                                ShapeUtilities.round(symbolBounds.Top - (height * 0.3f)),
                                width,
                                height);
                    }

                    /*instRect = new SO.Rect(symbolBounds.Left + width,
                     symbolBounds.Top - height,
                     width,
                     height);//*/
                    //generate installation bounds//////////////////////////////
                    instBounds = new Rect(instRect.Left + -1,
                            instRect.Top - 1,
                            instRect.Width + 2,
                            instRect.Height + 2);

                    imageBounds = ShapeUtilities.union(imageBounds, instBounds);

                }
                #endregion

                #region Build HQ Staff
                Point pt1HQ = new Point();
                Point pt2HQ = new Point();
                Rect hqBounds = Rect.Empty;
                //Draw HQ Staff
                if (SymbolUtilities.isHQ(symbolID))
                {

                    char affiliation = symbolID[1];
                    //get points for the HQ staff
                    if (affiliation == ('F')
                            || affiliation == ('A')
                            || affiliation == ('D')
                            || affiliation == ('M')
                            || affiliation == ('J')
                            || affiliation == ('K')
                            || affiliation == ('N')
                            || affiliation == ('L'))
                    {
                        pt1HQ = new Point((int)symbolBounds.Left + 1,
                                (int)(symbolBounds.Top + symbolBounds.Height - 1));
                        pt2HQ = new Point((int)pt1HQ.X, (int)(pt1HQ.Y + symbolBounds.Height));
                    }
                    else
                    {
                        pt1HQ = new Point((int)symbolBounds.Left + 1,
                                (int)(symbolBounds.Top + (symbolBounds.Height / 2)));
                        pt2HQ = new Point((int)pt1HQ.X, (int)(pt1HQ.Y + symbolBounds.Height));
                    }

                    //create bounding Rect for HQ staff.
                    hqBounds = new Rect(pt1HQ.X, pt1HQ.Y, 2, pt2HQ.Y - pt1HQ.Y);
                    //adjust the image bounds accordingly.
                    imageBounds.Height = imageBounds.Height + (pt2HQ.Y - imageBounds.Bottom);
                    imageBounds = ShapeUtilities.union(imageBounds, hqBounds);
                    //adjust symbol center
                    centerPoint.X = pt2HQ.X;
                    centerPoint.Y = pt2HQ.Y;
                }
                #endregion

                #region Build DOM Arrow
                Point[] domPoints = null;
                Rect domBounds = Rect.Empty;
                if (modifiers != null && modifiers.ContainsKey(ModifiersUnits.Q_DIRECTION_OF_MOVEMENT))
                {
                    String strQ = modifiers[ModifiersUnits.Q_DIRECTION_OF_MOVEMENT];

                    if (strQ != null && SymbolUtilities.isNumber(strQ))
                    {
                        float q = (float)Convert.ToDouble(strQ);

                        Boolean isY = (modifiers.ContainsKey(ModifiersUnits.Y_LOCATION));

                        TextInfo tiY = new TextInfo(device, "Y");

                        domPoints = createDOMArrowPoints(symbolID, symbolBounds, centerPoint, q, tiY.getTextBounds().Height);

                        domBounds = new Rect(domPoints[0].X, domPoints[0].Y, 1, 1);

                        Point temp = new Point();
                        for (int i = 1; i < 6; i++)
                        {
                            temp = domPoints[i];
                            if (temp.X != 0 && temp.Y != 0)
                            {
                                domBounds = ShapeUtilities.union(domBounds, temp);
                            }
                        }
                        domBounds = ShapeUtilities.inflate(domBounds,1, 1);
                        imageBounds = ShapeUtilities.union(imageBounds, domBounds);
                    }
                }
                #endregion

                #region Build Operational Condition Indicator
                Rect ociBounds = Rect.Empty;
                int ociOffset = 4;
                if (mobilityBounds != Rect.Empty)
                {
                    ociOffset = ShapeUtilities.round(mobilityBounds.Height);
                }
                Rect ociShape = processOperationalConditionIndicator(symbolID, symbolBounds, ociOffset);
                if (ociShape != Rect.Empty)
                {
                    Rect temp = ShapeUtilities.clone(ociShape);
                    temp = ShapeUtilities.inflate(temp,2, 3);
                    ociBounds = temp;
                    imageBounds = ShapeUtilities.union(imageBounds, ociBounds);
                }
                #endregion

                #region Shift Modifiers
                if (imageBounds.Left < 0 || imageBounds.Top < 0)
                {
                    double shiftX = Math.Abs(imageBounds.Left);
                    double shiftY = Math.Abs(imageBounds.Top);

                    if (hqBounds != Rect.Empty)
                    {
                        pt1HQ = ShapeUtilities.offset(pt1HQ,shiftX, shiftY);
                        pt2HQ = ShapeUtilities.offset(pt2HQ, shiftX, shiftY);
                    }
                    if (echelonBounds != Rect.Empty)
                    {
                        tiEchelon.setLocation(tiEchelon.getLocation().X + shiftX, tiEchelon.getLocation().Y + shiftY);
                    }
                    if (amBounds != Rect.Empty)
                    {
                        tiAM.setLocation(tiAM.getLocation().X + shiftX, tiAM.getLocation().Y + shiftY);
                    }
                    if (tfBounds != Rect.Empty)
                    {
                        tfRect = ShapeUtilities.offset(tfRect, shiftX, shiftY);
                        tfBounds = ShapeUtilities.offset(tfBounds,shiftX, shiftY);
                    }
                    if (instBounds != Rect.Empty)
                    {
                        instRect = ShapeUtilities.offset(instRect,shiftX, shiftY);
                        instBounds = ShapeUtilities.offset(instBounds,shiftX, shiftY);
                    }
                    if (fdiBounds != Rect.Empty)
                    {
                        fdiBounds = ShapeUtilities.offset(fdiBounds,shiftX, shiftY);
                        fdiLeft = ShapeUtilities.offset(fdiLeft, shiftX, shiftY);
                        fdiTop = ShapeUtilities.offset(fdiTop, shiftX, shiftY);
                        fdiRight = ShapeUtilities.offset(fdiRight,shiftX, shiftY);
                    }
                    if (ociBounds != Rect.Empty)
                    {
                        ociBounds = ShapeUtilities.offset(ociBounds,shiftX, shiftY);
                        ociShape = ShapeUtilities.offset(ociShape,shiftX, shiftY);
                    }
                    if (domBounds != Rect.Empty)
                    {
                        for (int i = 0; i < 6; i++)
                        {
                            Point temp = domPoints[i];

                            if (temp.X != 0 && temp.Y != 0)
                                temp = ShapeUtilities.offset(temp,shiftX, shiftY);

                            domPoints[i] = temp;

                        }
                        domBounds = ShapeUtilities.offset(domBounds,shiftX, shiftY);
                    }
                    if (mobilityBounds != Rect.Empty)
                    {
                        Matrix3x2 translation = Matrix3x2.CreateTranslation((float)shiftX, (float)shiftY);

                        //shift mobility points
                        cgMobilityPath.Transform(translation);
                        if(cgMobilityPathFill != null)
                        {
                            cgMobilityPathFill.Transform(translation);
                        }

                        mobilityBounds = ShapeUtilities.offset(mobilityBounds,shiftX, shiftY);
                    }

                    centerPoint = ShapeUtilities.offset(centerPoint,shiftX, shiftY);
                    symbolBounds = ShapeUtilities.offset(symbolBounds, shiftX, shiftY);
                    imageBounds = ShapeUtilities.offset(imageBounds, shiftX, shiftY);
                }
                #endregion

                #region Draw Modifiers
                CanvasRenderTarget bmp = new CanvasRenderTarget(device, (float)imageBounds.Width, (float)imageBounds.Height, 96);
                //Bitmap bmp = new Bitmap(imageBounds.Width, imageBounds.Height);
                //Graphics g = Graphics.FromImage(bmp);


                //render////////////////////////////////////////////////////////
                using (CanvasDrawingSession ds = bmp.CreateDrawingSession())
                {
                    ds.Antialiasing = CanvasAntialiasing.Antialiased;
                    ds.TextAntialiasing = CanvasTextAntialiasing.ClearType;
                    //Pen pen = new Pen(Color.Black, 2f);
                    //g.SmoothingMode = SmoothingMode.AntiAlias;
                    if (hqBounds != Rect.Empty)
                    {
                        ds.DrawLine(pt1HQ.ToVector2(), pt2HQ.ToVector2(), Colors.Black, 2f);
                        //g.DrawLine(pen, pt1HQ.X, pt1HQ.Y, pt2HQ.X, pt2HQ.Y);
                    }

                    if (tfBounds != Rect.Empty)
                    {
                        ds.DrawRectangle(tfRect, Colors.Black,2f);
                        //g.DrawRect(pen, tfRect);
                    }

                    if (instBounds != Rect.Empty)
                    {
                        ds.FillRectangle(tfRect,Colors.Black);
                        //g.FillRect(Brushes.Black, instRect);
                    }

                    if (echelonBounds != Rect.Empty)
                    {
                        /*TextInfo[] aTiEchelon =
                        {
                            tiEchelon
                        };
                        renderText(g, aTiEchelon, textColor, textBackgroundColor);//*/
                        tiEchelon.drawText(ds, textColor);
                        echelonBounds = Rect.Empty;
                        tiEchelon = null;
                    }

                    if (amBounds != Rect.Empty)
                    {
                        /*TextInfo[] aTiAM =
                        {
                            tiAM
                        };
                        renderText(g, aTiAM, textColor, textBackgroundColor);//*/
                        tiAM.drawText(ds, textColor);
                        amBounds = Rect.Empty;
                        tiAM = null;
                    }

                    if (fdiBounds != Rect.Empty)
                    {
                        CanvasStrokeStyle style = new CanvasStrokeStyle();
                        
                        if (symbolBounds.Width > 19)
                        {
                            style.CustomDashStyle = new float[] { 6f, 4f };
                        }
                        else
                        {
                            style.CustomDashStyle = new float[] { 5f, 3f };
                        }

                        style.LineJoin = CanvasLineJoin.Miter;
                        style.MiterLimit = 3;
                        
                        //pen.LineJoin = LineJoin.Miter;
                        //pen.MiterLimit = 3;
                        //pen.Width = 2;
                        
                        //GraphicsPath fdiPath = new GraphicsPath();

                        //fdiPath.AddLine(fdiLeft.X, fdiLeft.Y, fdiTop.X, fdiTop.Y);
                        //fdiPath.AddLine(fdiTop.X, fdiTop.Y, fdiRight.X, fdiRight.Y);

                        ds.DrawLine(fdiLeft.ToVector2(), fdiTop.ToVector2(), Colors.Black, 2f);

                        //g.DrawPath(pen, fdiPath);

                        fdiBounds = Rect.Empty;

                    }

                    if (mobilityBounds != Rect.Empty)
                    {


                        //ctx.lineCap = "butt";
                        //ctx.lineJoin = "miter";
                        if (symbolID[10] == ('N'))
                        {
                            ds.Antialiasing = CanvasAntialiasing.Aliased;
                            //mobilityPaint.setAntiAlias(false);
                            //g.SmoothingMode = SmoothingMode.None;
                        }
                        ds.DrawGeometry(cgMobilityPath, Colors.Black, 2f);
                       // g.DrawPath(mobilityPen, mobilityPath);

                        if (cgMobilityPathFill != null)
                        {
                            ds.FillGeometry(cgMobilityPathFill,Colors.Black);
                            //g.FillPath(Brushes.Black, mobilityPathFill);
                        }

                        mobilityBounds = Rect.Empty;

                    }

                    if (ociBounds != Rect.Empty)
                    {
                        Color statusColor = Colors.Black;
                        char status = symbolID[3];
                        if (status == ('C'))//Fully Capable
                        {
                            statusColor = Colors.Green;
                        }
                        else if (status == ('D'))//Damage
                        {
                            statusColor = Colors.Yellow;
                        }
                        else if (status == ('X'))
                        {
                            statusColor = Colors.Red;
                        }
                        else if (status == ('F'))//full to capacity(hospital)
                        {
                            statusColor = Colors.Blue;
                        };

                        ds.FillRectangle(ociBounds, Colors.Black);
                        //g.FillRect(Brushes.Black, ociBounds);
                        ds.FillRectangle(ociShape, statusColor);
                        //g.FillRect(new SolidBrush(statusColor), ociShape);

                        ociBounds = Rect.Empty;
                        ociShape = Rect.Empty;
                    }

                    //draw original icon.        
                    //ctx.drawBitmap(ii.getImage(), null, symbolBounds, null);
                    ds.DrawImage(ii.getCanvasRenderTarget(), (float)symbolBounds.X, (float)symbolBounds.Y);
                    //g.DrawImageUnscaled(ii.getBitmap(), symbolBounds.X, symbolBounds.Y);

                    if (domBounds != Rect.Empty)
                    {
                        drawDOMArrow(device, ds, domPoints);

                        domBounds = Rect.Empty;
                        domPoints = null; ;
                    }

                    #endregion
                }
                
               
                /*GraphicsUnit pixel = GraphicsUnit.Pixel;
                Rect outline = ShapeUtilities.cloneToRect(bmp.GetBounds(ref pixel));
                outline.Width = outline.Width - 1;
                outline.Height = outline.Height - 1;
                g.DrawRect(Pens.Red, outline);//*/

                newii = new ImageInfo(bmp, centerPoint, symbolBounds,bmp.GetBounds(device));

                #region Cleanup
                if (newii != null)
                {
                    return newii;
                }
                else
                {
                    return null;
                }
                #endregion
            }
            catch (Exception exc)
            {
                ErrorLogger.LogException("SinglePointRenderer", "ProcessUnitDisplayModifiers", exc);
                return null;
            }
        }
        /*public override object Clone()
        {
            SVGPath clone = new SVGPath();
            clone._gp = (GraphicsPath)_gp.Clone();
            clone._ID = _ID;
            clone._strPath = (String)_strPath.Clone();
            return clone;
        }*/

        private void parsePath(CanvasPathBuilder pb, String path)
        {
            char[] delimiter = { ' ' };
            string[] commands = Regex.Split(path, _regex1);
            string[] values = null;
            float[] points = new float[7];
            Vector2[] Vector2s = new Vector2[4];
            Vector2 lastPoint = new Vector2(0, 0);
            Vector2 lastControlPoint = new Vector2(0, 0);
            //Vector2 firstPoint = new Vector2(0, 0);
            //Vector2 firstPoint = new Vector2(0, 0);

            try
            {

                for (int i = 0; i < commands.Length; i++)
                {

                    String strCommand = commands[i];
                    char action = (strCommand != null && strCommand.Length > 0) ? strCommand[0] : ' ';
                    values = strCommand.Split(delimiter);

                    if (action == 'M')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);
                        lastPoint = new Vector2(points[0], points[1]);
                        //firstPoint = new Vector2(points[0], points[1]);
                        
                        pb.BeginFigure(lastPoint);
                    }
                    else if (action == 'm')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;

                        pb.BeginFigure(points[0], points[1]);
                        lastPoint.X = points[0];
                        lastPoint.Y = points[1];
                        pb.BeginFigure(lastPoint);
                    }
                    else if (action == 'L')//capital letter is absolute location
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);
                        
                        pb.AddLine(points[0], points[1]);

                        lastPoint.X = points[0];
                        lastPoint.Y = points[1];
                        

                    }
                    else if (action == 'l')//lowercase letter is relative location
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;

                        pb.AddLine(points[0], points[1]);

                        lastPoint.X = points[0];
                        lastPoint.Y = points[1];
                    }
                    else if (action == 'H')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));

                        pb.AddLine(points[0], lastPoint.Y);

                        lastPoint.X = points[0];

                    }
                    else if (action == 'h')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;

                        pb.AddLine(points[0], lastPoint.Y);

                        lastPoint.X = points[0];
                    }
                    else if (action == 'V')
                    {
                        points[0] = -(float)Convert.ToDouble(values[0].Substring(1));

                        pb.AddLine(lastPoint.X, points[0]);

                        lastPoint.Y = points[0]; 

                    }
                    else if (action == 'v')
                    {
                        points[0] = -(float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.Y;

                        pb.AddLine(lastPoint.X, points[0]);

                        lastPoint.Y = points[0];
                    }
                    else if (action == 'C')//cubic bezier, 2 control points
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);
                        points[2] = (float)Convert.ToDouble(values[2]);
                        points[3] = -(float)Convert.ToDouble(values[3]);
                        points[4] = (float)Convert.ToDouble(values[4]);
                        points[5] = -(float)Convert.ToDouble(values[5]);

                        Vector2s[0] = lastPoint;
                        Vector2s[1] = new Vector2(points[0], points[1]);
                        Vector2s[2] = new Vector2(points[2], points[3]);
                        Vector2s[3] = new Vector2(points[4], points[5]);
                        
                        //_gp.AddBezier(Vector2s[0], Vector2s[1], Vector2s[2], Vector2s[3]);
                        pb.AddCubicBezier(Vector2s[1], Vector2s[2], Vector2s[3]);

                        lastPoint = Vector2s[3];
                        lastControlPoint = Vector2s[2];
                    }
                    else if (action == 'c')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;
                        points[2] = (float)Convert.ToDouble(values[2]) + lastPoint.X;
                        points[3] = -(float)Convert.ToDouble(values[3]) + lastPoint.Y;
                        points[4] = (float)Convert.ToDouble(values[4]) + lastPoint.X;
                        points[5] = -(float)Convert.ToDouble(values[5]) + lastPoint.Y;

                        Vector2s[0] = lastPoint;
                        Vector2s[1] = new Vector2(points[0], points[1]);
                        Vector2s[2] = new Vector2(points[2], points[3]);
                        Vector2s[3] = new Vector2(points[4], points[5]);
                        
                        //_gp.AddBezier(Vector2s[0], Vector2s[1], Vector2s[2], Vector2s[3]);
                        pb.AddCubicBezier(Vector2s[1], Vector2s[2], Vector2s[3]);

                        lastPoint = Vector2s[3];
                        lastControlPoint = Vector2s[2];
                    }
                    else if (action == 'S')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);
                        points[2] = (float)Convert.ToDouble(values[2]);
                        points[3] = -(float)Convert.ToDouble(values[3]);

                        Vector2s[0] = lastPoint;
                        Vector2s[1] = mirrorControlPoint(lastControlPoint, lastPoint);
                        Vector2s[2] = new Vector2(points[0], points[1]);
                        Vector2s[3] = new Vector2(points[2], points[3]);

                        //_gp.AddBezier(Vector2s[0], Vector2s[1], Vector2s[2], Vector2s[3]);
                        pb.AddCubicBezier(Vector2s[1], Vector2s[2], Vector2s[3]);

                        lastPoint = Vector2s[3];
                        lastControlPoint = Vector2s[2];
                    }
                    else if (action == 's')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;
                        points[2] = (float)Convert.ToDouble(values[2]) + lastPoint.X;
                        points[3] = -(float)Convert.ToDouble(values[3]) + lastPoint.Y;

                        Vector2s[0] = lastPoint;
                        Vector2s[1] = mirrorControlPoint(lastControlPoint, lastPoint);
                        Vector2s[2] = new Vector2(points[0], points[1]);
                        Vector2s[3] = new Vector2(points[2], points[3]);

                        //_gp.AddBezier(Vector2s[0], Vector2s[1], Vector2s[2], Vector2s[3]);
                        pb.AddCubicBezier(Vector2s[1], Vector2s[2], Vector2s[3]);

                        lastPoint = Vector2s[3];
                        lastControlPoint = Vector2s[2];
                    }
                    else if (action == 'Q')//quadratic bezier, 1 control point
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);
                        points[2] = (float)Convert.ToDouble(values[2]);
                        points[3] = -(float)Convert.ToDouble(values[3]);


                        //convert quadratic to cubic bezier
                        Vector2 QP0 = lastPoint;
                        Vector2 QP1 = new Vector2(points[0], points[1]);
                        Vector2 QP2 = new Vector2(points[2], points[3]);

                        Vector2 CP0 = QP0;
                        Vector2 CP3 = QP2;

                        //old
                        //Vector2 CP1 = new Vector2((QP0.X + 2.0f * QP1.X) / 3.0f, (QP0.Y + 2.0f * QP1.Y) / 3.0f);
                        //Vector2 CP2 = new Vector2((QP2.X + 2.0f * QP1.X) / 3.0f, (QP2.Y + 2.0f * QP1.Y) / 3.0f);

                        //new
                        Vector2 CP1 = new Vector2(QP0.X + 2.0f / 3.0f * (QP1.X - QP0.X), QP0.Y + 2.0f / 3.0f * (QP1.Y - QP0.Y));
                        Vector2 CP2 = new Vector2(QP2.X + 2.0f / 3.0f * (QP1.X - QP2.X), QP2.Y + 2.0f / 3.0f * (QP1.Y - QP2.Y));

                        //_gp.AddBezier(CP0, CP1, CP2, CP3);
                        //pb.AddCubicBezier(CP1, CP2, QP2);
                        pb.AddQuadraticBezier(QP1, QP2);

                        lastPoint = QP2;

                        lastControlPoint = QP1;
                    }
                    else if (action == 'q')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;
                        points[2] = (float)Convert.ToDouble(values[2]) + lastPoint.X;
                        points[3] = -(float)Convert.ToDouble(values[3]) + lastPoint.Y;


                        //convert quadratic to cubic bezier
                        Vector2 QP0 = lastPoint;
                        Vector2 QP1 = new Vector2(points[0], points[1]);
                        Vector2 QP2 = new Vector2(points[2], points[3]);

                        Vector2 CP0 = QP0;
                        Vector2 CP3 = QP2;

                        //old
                        //Vector2 CP1 = new Vector2((QP0.X + 2.0f * QP1.X) / 3.0f, (QP0.Y + 2.0f * QP1.Y) / 3.0f);
                        //Vector2 CP2 = new Vector2((QP2.X + 2.0f * QP1.X) / 3.0f, (QP2.Y + 2.0f * QP1.Y) / 3.0f);
                        //new
                        //Vector2 CP1 = new Vector2(QP0.X + 2.0f / 3.0f * (QP1.X - QP0.X), QP0.Y + 2.0f / 3.0f * (QP1.Y - QP0.Y));
                        //Vector2 CP2 = new Vector2(QP2.X + 2.0f / 3.0f * (QP1.X - QP2.X), QP2.Y + 2.0f / 3.0f * (QP1.Y - QP2.Y));

                        //_gp.AddBezier(CP0, CP1, CP2, CP3);
                        //pb.AddCubicBezier(CP1, CP2, QP2);
                        pb.AddQuadraticBezier(QP1, QP2);


                        lastPoint = QP2;

                        lastControlPoint = QP1;
                    }
                    else if (action == 'T')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = -(float)Convert.ToDouble(values[1]);

                        //convert quadratic to bezier
                        Vector2 QP0 = lastPoint;
                        Vector2 QP1 = mirrorControlPoint(lastControlPoint, QP0);
                        Vector2 QP2 = new Vector2(points[0], points[1]);

                        Vector2 CP0 = QP0;
                        Vector2 CP3 = QP2;

                        //Vector2 CP1 = new Vector2((QP0.X + 2.0f * QP1.X) / 3.0f, (QP0.Y + 2.0f * QP1.Y) / 3.0f);
                        //Vector2 CP2 = new Vector2((QP2.X + 2.0f * QP1.X) / 3.0f, (QP2.Y + 2.0f * QP1.Y) / 3.0f);

                        //Vector2 CP1 = new Vector2(QP0.X + 2.0f / 3.0f * (QP1.X - QP0.X), QP0.Y + 2.0f / 3.0f * (QP1.Y - QP0.Y));
                        //Vector2 CP2 = new Vector2(QP2.X + 2.0f / 3.0f * (QP1.X - QP2.X), QP2.Y + 2.0f / 3.0f * (QP1.Y - QP2.Y));


                        //_gp.AddBezier(CP0, CP1, CP2, CP3);
                        //pb.AddCubicBezier(CP1, CP2, QP2);
                        pb.AddQuadraticBezier(QP1, QP2);

                       
                        lastPoint = QP2;

                        lastControlPoint = QP1;
                    }
                    else if (action == 't')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1)) + lastPoint.X;
                        points[1] = -(float)Convert.ToDouble(values[1]) + lastPoint.Y;

                        //convert quadratic to bezier
                        Vector2 QP0 = lastPoint;
                        Vector2 QP1 = mirrorControlPoint(lastControlPoint, QP0);
                        Vector2 QP2 = new Vector2(points[0], points[1]);

                        Vector2 CP0 = QP0;
                        Vector2 CP3 = QP2;

                        //Vector2 CP1 = new Vector2((QP0.X + 2.0f * QP1.X) / 3.0f, (QP0.Y + 2.0f * QP1.Y) / 3.0f);
                        //Vector2 CP2 = new Vector2((QP2.X + 2.0f * QP1.X) / 3.0f, (QP2.Y + 2.0f * QP1.Y) / 3.0f);

                        //Vector2 CP1 = new Vector2(QP0.X + 2.0f / 3.0f * (QP1.X - QP0.X), QP0.Y + 2.0f / 3.0f * (QP1.Y - QP0.Y));
                        //Vector2 CP2 = new Vector2(QP2.X + 2.0f / 3.0f * (QP1.X - QP2.X), QP2.Y + 2.0f / 3.0f * (QP1.Y - QP2.Y));


                        //_gp.AddBezier(CP0, CP1, CP2, CP3);
                        //pb.AddCubicBezier(CP1, CP2, QP2);
                        pb.AddQuadraticBezier(QP1, QP2);


                        lastPoint = QP2;

                        lastControlPoint = QP1;
                    }
                    else if (action == 'A')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));//radiusX
                        points[1] = (float)Convert.ToDouble(values[1]);//radiusY
                        points[2] = (float)Convert.ToDouble(values[2]);//angle
                        points[3] = (float)Convert.ToDouble(values[3]);//size
                        points[4] = (float)Convert.ToDouble(values[4]);//sweep
                        points[5] = (float)Convert.ToDouble(values[5]);//endX
                        points[6] = -(float)Convert.ToDouble(values[6]);//endY

                        //SvgArcSize sas = points[3] == 0 ? SvgArcSize.Small : SvgArcSize.Large;
                        //SvgArcSweep sasw = points[4] == 0 ? SvgArcSweep.Negative : SvgArcSweep.Positive;
                        Vector2 endPoint = new Vector2(points[5], points[6]);

                        //SvgArcSegment arc = new SvgArcSegment(lastPoint, points[0], points[1], points[2], sas, sasw, endPoint);
                        //arc.AddToPath(_gp);

                        CanvasArcSize arcSize = CanvasArcSize.Large;//if size = 1, size is large.  0 for small
                        CanvasSweepDirection sweep = CanvasSweepDirection.Clockwise;//if sweep == 1, sweep is clockwise or positive

                        if(points[3]==0.0f)
                            arcSize = CanvasArcSize.Small;
                        if (points[4] == 0.0f)
                            sweep = CanvasSweepDirection.CounterClockwise;

                        pb.AddArc(new Vector2(points[5], points[6]), points[0], points[1], points[2], sweep, arcSize);


                        //AddArcToPath(_gp, lastPoint, points[0], points[1], points[2], (int)points[3], (int)points[4], endPoint);

                        lastPoint.X = points[5];
                        lastPoint.Y = points[6];
                    }
                    else if (action == 'a')
                    {
                        points[0] = (float)Convert.ToDouble(values[0].Substring(1));
                        points[1] = (float)Convert.ToDouble(values[1]);
                        points[2] = (float)Convert.ToDouble(values[2]);
                        points[3] = (float)Convert.ToDouble(values[3]);
                        points[4] = (float)Convert.ToDouble(values[4]);
                        points[5] = (float)Convert.ToDouble(values[5] + lastPoint.X);
                        points[6] = -(float)Convert.ToDouble(values[6] + lastPoint.Y);

                        //SvgArcSize sas = points[3] == 0 ? SvgArcSize.Small : SvgArcSize.Large;
                        //SvgArcSweep sasw = points[4] == 0 ? SvgArcSweep.Negative : SvgArcSweep.Positive;
                        Vector2 endPoint = new Vector2(points[5], points[6]);

                        //SvgArcSegment arc = new SvgArcSegment(lastPoint, points[0], points[1], points[2], sas, sasw, endPoint);
                        //arc.AddToPath(_gp);

                        CanvasArcSize arcSize = CanvasArcSize.Large;//if size = 1, size is large.  0 for small
                        CanvasSweepDirection sweep = CanvasSweepDirection.Clockwise;//if sweep == 1, sweep is clockwise or positive

                        if (points[3] == 0.0f)
                            arcSize = CanvasArcSize.Small;
                        if (points[4] == 0.0f)
                            sweep = CanvasSweepDirection.CounterClockwise;

                        pb.AddArc(new Vector2(points[5], points[6]), points[0], points[1], points[2], sweep, arcSize);

                        //AddArcToPath(_gp, lastPoint, points[0], points[1], points[2], (int)points[3], (int)points[4], endPoint);

                        lastPoint.X = points[5];
                        lastPoint.Y = points[6];
                    }
                    else if (action == 'Z' || action == 'z')
                    {
                        pb.EndFigure(CanvasFigureLoop.Closed);
                    }
                }
                _cg = CanvasGeometry.CreatePath(pb);
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.WriteLine(exc.StackTrace);
                
                ErrorLogger.LogException("SVGPath", "parsePath", exc);
            }



        }
Esempio n. 38
0
        public static CanvasGeometry ToCanvasGeometry(this XPathGeometry pg, CanvasDrawingSession ds)
        {
            CanvasGeometry g;

            using (var builder = new CanvasPathBuilder(ds))
            {
                if (pg.FillRule == XFillRule.EvenOdd)
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Alternate);
                else
                    builder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Winding);

                foreach (var pf in pg.Figures)
                {
                    builder.BeginFigure(
                        (float)pf.StartPoint.X,
                        (float)pf.StartPoint.Y,
                        pf.IsFilled ? CanvasFigureFill.Default : CanvasFigureFill.DoesNotAffectFills);

                    foreach (var segment in pf.Segments)
                    {
                        var options = CanvasFigureSegmentOptions.None;
                        if (!segment.IsStroked)
                            options |= CanvasFigureSegmentOptions.ForceUnstroked;

                        if (segment.IsSmoothJoin)
                            options |= CanvasFigureSegmentOptions.ForceRoundLineJoin;

                        builder.SetSegmentOptions(options);

                        if (segment is XArcSegment)
                        {
                            var arcSegment = segment as XArcSegment;
                            builder.AddArc(
                                new N.Vector2(
                                    (float)arcSegment.Point.X,
                                    (float)arcSegment.Point.Y),
                                (float)(arcSegment.Size.Width / 2.0),
                                (float)(arcSegment.Size.Height / 2.0),
                                (float)arcSegment.RotationAngle,
                                arcSegment.SweepDirection == XSweepDirection.Clockwise ? CanvasSweepDirection.Clockwise : CanvasSweepDirection.CounterClockwise,
                                arcSegment.IsLargeArc ? CanvasArcSize.Large : CanvasArcSize.Small);
                        }
                        else if (segment is XBezierSegment)
                        {
                            var bezierSegment = segment as XBezierSegment;
                            builder.AddCubicBezier(
                                new N.Vector2(
                                    (float)bezierSegment.Point1.X,
                                    (float)bezierSegment.Point1.Y),
                                new N.Vector2(
                                    (float)bezierSegment.Point2.X,
                                    (float)bezierSegment.Point2.Y),
                                new N.Vector2(
                                    (float)bezierSegment.Point3.X,
                                    (float)bezierSegment.Point3.Y));
                        }
                        else if (segment is XLineSegment)
                        {
                            var lineSegment = segment as XLineSegment;
                            builder.AddLine(
                                new N.Vector2(
                                    (float)lineSegment.Point.X,
                                    (float)lineSegment.Point.Y));
                        }
                        else if (segment is XPolyBezierSegment)
                        {
                            var polyBezierSegment = segment as XPolyBezierSegment;
                            if (polyBezierSegment.Points.Count >= 3)
                            {
                                builder.AddCubicBezier(
                                    new N.Vector2(
                                        (float)polyBezierSegment.Points[0].X,
                                        (float)polyBezierSegment.Points[0].Y),
                                    new N.Vector2(
                                        (float)polyBezierSegment.Points[1].X,
                                        (float)polyBezierSegment.Points[1].Y),
                                    new N.Vector2(
                                        (float)polyBezierSegment.Points[2].X,
                                        (float)polyBezierSegment.Points[2].Y));
                            }

                            if (polyBezierSegment.Points.Count > 3
                                && polyBezierSegment.Points.Count % 3 == 0)
                            {
                                for (int i = 3; i < polyBezierSegment.Points.Count; i += 3)
                                {
                                    builder.AddCubicBezier(
                                        new N.Vector2(
                                            (float)polyBezierSegment.Points[i].X,
                                            (float)polyBezierSegment.Points[i].Y),
                                        new N.Vector2(
                                            (float)polyBezierSegment.Points[i + 1].X,
                                            (float)polyBezierSegment.Points[i + 1].Y),
                                        new N.Vector2(
                                            (float)polyBezierSegment.Points[i + 2].X,
                                            (float)polyBezierSegment.Points[i + 2].Y));
                                }
                            }
                        }
                        else if (segment is XPolyLineSegment)
                        {
                            var polyLineSegment = segment as XPolyLineSegment;

                            if (polyLineSegment.Points.Count >= 1)
                            {
                                builder.AddLine(
                                    new N.Vector2(
                                        (float)polyLineSegment.Points[0].X,
                                        (float)polyLineSegment.Points[0].Y));
                            }

                            if (polyLineSegment.Points.Count > 1)
                            {
                                for (int i = 1; i < polyLineSegment.Points.Count; i++)
                                {
                                    builder.AddLine(
                                        new N.Vector2(
                                            (float)polyLineSegment.Points[i].X,
                                            (float)polyLineSegment.Points[i].Y));
                                }
                            }
                        }
                        else if (segment is XPolyQuadraticBezierSegment)
                        {
                            var polyQuadraticSegment = segment as XPolyQuadraticBezierSegment;
                            if (polyQuadraticSegment.Points.Count >= 2)
                            {
                                builder.AddQuadraticBezier(
                                    new N.Vector2(
                                        (float)polyQuadraticSegment.Points[0].X,
                                        (float)polyQuadraticSegment.Points[0].Y),
                                    new N.Vector2(
                                        (float)polyQuadraticSegment.Points[1].X,
                                        (float)polyQuadraticSegment.Points[1].Y));
                            }

                            if (polyQuadraticSegment.Points.Count > 2
                                && polyQuadraticSegment.Points.Count % 2 == 0)
                            {
                                for (int i = 3; i < polyQuadraticSegment.Points.Count; i += 3)
                                {
                                    builder.AddQuadraticBezier(
                                        new N.Vector2(
                                            (float)polyQuadraticSegment.Points[i].X,
                                            (float)polyQuadraticSegment.Points[i].Y),
                                        new N.Vector2(
                                            (float)polyQuadraticSegment.Points[i + 1].X,
                                            (float)polyQuadraticSegment.Points[i + 1].Y));
                                }
                            }
                        }
                        else if (segment is XQuadraticBezierSegment)
                        {
                            var qbezierSegment = segment as XQuadraticBezierSegment;
                            builder.AddQuadraticBezier(
                                new N.Vector2(
                                    (float)qbezierSegment.Point1.X,
                                    (float)qbezierSegment.Point1.Y),
                                new N.Vector2(
                                    (float)qbezierSegment.Point2.X,
                                    (float)qbezierSegment.Point2.Y));
                        }
                        else
                        {
                            throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                        }
                    }

                    builder.EndFigure(pf.IsClosed ? CanvasFigureLoop.Closed : CanvasFigureLoop.Open);
                }

                g = CanvasGeometry.CreatePath(builder);
            }

            return g;
        }
Esempio n. 39
0
        public void VerifySendPathTo()
        {
            //
            // This calls each of the path functions, once, and verfies that it works.
            // Sink behavior is verified in more detail in the geometry unit tests.
            //
            CanvasDevice device = new CanvasDevice();

            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(device);
            pathBuilder.SetFilledRegionDetermination(CanvasFilledRegionDetermination.Alternate);
            pathBuilder.BeginFigure(0, 0);
            pathBuilder.AddLine(0, 0);
            pathBuilder.AddQuadraticBezier(new Vector2(), new Vector2());
            pathBuilder.AddCubicBezier(new Vector2(), new Vector2(), new Vector2());

            // D2D tries to be smart about degenerate arcs and redundant set segment options, and may sometimes actually
            // surpress them. Therefore, these calls use non-defaults.
            pathBuilder.AddArc(new Vector2 { X = 100, Y = 100 }, 10, 10, 90, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
            pathBuilder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceUnstroked);

            pathBuilder.EndFigure(CanvasFigureLoop.Closed);

            CanvasGeometry pathGeometry = CanvasGeometry.CreatePath(pathBuilder);

            MyGeometryStreamReader myStreamReader = new MyGeometryStreamReader();
            pathGeometry.SendPathTo(myStreamReader);

            myStreamReader.Verify();
        }