Example #1
0
        static CanvasGeometry MakeGeometry(IEnumerable <Data.Path> paths, CanvasFilledRegionDetermination fillRule = CanvasFilledRegionDetermination.Winding)
        {
            var device = CanvasDevice.GetSharedDevice();

            using var builder = new CanvasPathBuilder(device);

            if (paths != null)
            {
                foreach (var path in paths)
                {
                    builder.AddGeometry(path.CanvasPath);
                }
            }
            builder.SetFilledRegionDetermination(fillRule);

            return(CanvasGeometry.CreatePath(builder));
        }
        private void Canvas1_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
        {
            CanvasDrawingSession ds = args.DrawingSession;

            if (!ListBoxItem1.IsSelected)
            {
                //Drawing 1

                //Sun
                ds.FillEllipse(0, 0, 150, 100, Colors.Yellow);
                //Grass
                ds.FillRectangle(new Rect(0, 700, 5000, 200), Colors.Green);

                //Tree
                ds.FillRectangle(new Rect(200, 325, 80, 400), Colors.SaddleBrown);
                ds.FillEllipse(240, 325, 100, 100, Colors.Green);
                ds.FillEllipse(200, 350, 100, 100, Colors.Green);
                ds.FillEllipse(260, 350, 100, 100, Colors.Green);

                //House
                ds.FillRectangle(new Rect(800, 475, 350, 300), Colors.DarkRed);
                ds.DrawLine(new Vector2(800, 475), new Vector2(1150, 775), Colors.White, 10);
                ds.DrawLine(new Vector2(800, 775), new Vector2(1150, 475), Colors.White, 10);

                Vector2[]         roof        = { new Vector2(800, 475), new Vector2(975, 375), new Vector2(1150, 475) };
                CanvasPathBuilder pathBuilder = new CanvasPathBuilder(Canvas1);
                pathBuilder.AddGeometry(CanvasGeometry.CreatePolygon(Canvas1, roof));
                ds.FillGeometry(CanvasGeometry.CreatePath(pathBuilder), Colors.SaddleBrown);
            }
            else
            {
                Color[] rainbow = { Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Colors.Indigo, Colors.Violet };

                //Drawing 2
                Vector2 startingPoint = new Vector2((float)(ActualWidth / 2), (float)(ActualHeight / 2));

                int angleIncrement = 3;

                int sideLength = 60;
                int angle      = 0;

                hexagonsDrawn++;

                if (hexagonsDrawn == 1000)
                {
                    //Draw hexagons
                    for (int i = 0; i < hexagonsDrawn; i++)
                    {
                        for (int j = 0; j < 6; j++)
                        {
                            startingPoint = DrawLine(ds, startingPoint, angle, sideLength, rainbow[i % rainbow.Length]);
                            angle        += 60;
                        }

                        angle += angleIncrement;
                        sideLength++;
                    }

                    hexagonsDrawn = 0;
                }
                else
                {
                    //Draw hexagons
                    for (int i = 0; i < hexagonsDrawn; i++)
                    {
                        for (int j = 0; j < 6; j++)
                        {
                            startingPoint = DrawLine(ds, startingPoint, angle, sideLength, rainbow[i % rainbow.Length]);
                            angle        += 60;
                        }

                        angle += angleIncrement;
                        sideLength++;
                    }

                    Task.Delay(10).Wait();
                    Canvas1.Invalidate();
                }
            }
        }
Example #3
0
        private void Draw(string text, Color foreground, bool fadeIn)
        {
            if (string.IsNullOrEmpty(text))
            {
                ElementCompositionPreview.SetElementChildVisual(this, null);
                return;
            }

            var data        = QrBuffer.FromString(text);
            var replaceFrom = data.ReplaceFrom;
            var replaceTill = data.ReplaceTill;

            var size  = 259;
            var pixel = size / data.Size;

            bool value(int row, int column)
            {
                return((row >= 0) &&
                       (row < data.Size) &&
                       (column >= 0) &&
                       (column < data.Size) &&
                       (row < replaceFrom ||
                        row >= replaceTill ||
                        column < replaceFrom ||
                        column >= replaceTill) &&
                       data.Values[row * data.Size + column]);
            };
            bool blackFull(int row, int column)
            {
                return((value(row - 1, column) && value(row + 1, column)) ||
                       (value(row, column - 1) && value(row, column + 1)));
            };
            bool whiteCorner(int row, int column, int dx, int dy)
            {
                return(!value(row + dy, column) ||
                       !value(row, column + dx) ||
                       !value(row + dy, column + dx));
            };
            bool whiteFull(int row, int column)
            {
                return(whiteCorner(row, column, -1, -1) &&
                       whiteCorner(row, column, 1, -1) &&
                       whiteCorner(row, column, 1, 1) &&
                       whiteCorner(row, column, -1, 1));
            };

            var skip = pixel - pixel / 2;

            var geometries = new CanvasGeometry[6];
            var geometry   = 0;

            using var builder = new CanvasPathBuilder(null);

            void large(float x, float y)
            {
                var rect1 = CanvasGeometry.CreateRoundedRectangle(null, x, y, pixel * 7 + 2, pixel * 7 + 2, 15, 15);
                var rect2 = CanvasGeometry.CreateRoundedRectangle(null, x + pixel, y + pixel, pixel * 5 + 2, pixel * 5 + 2, 9, 9);
                var rect3 = CanvasGeometry.CreateRoundedRectangle(null, x + pixel * 2, y + pixel * 2, pixel * 3 + 2, pixel * 3 + 2, pixel, pixel);

                geometries[geometry++] = rect1.CombineWith(rect2, Matrix3x2.Identity, CanvasGeometryCombine.Exclude);
                geometries[geometry++] = rect3;
            };
            void brect(float x, float y, float width, float height)
            {
                builder.AddGeometry(CanvasGeometry.CreateRectangle(null, x, y, width, height));
            };
            void barch(float x, float y, bool topLeft, bool topRight, bool bottomRight, bool bottomLeft)
            {
                var width  = pixel / 2.0f;
                var height = pixel / 2.0f;

                builder.BeginFigure(x, y + width);

                if (topLeft)
                {
                    builder.AddArc(new Vector2(x + width, y), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                }
                else
                {
                    builder.AddLine(x, y);
                    builder.AddLine(x + width, y);
                }

                if (topRight)
                {
                    builder.AddArc(new Vector2(x + pixel, y + height), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                }
                else
                {
                    builder.AddLine(x + pixel, y);
                    builder.AddLine(x + pixel, y + height);
                }

                if (bottomRight)
                {
                    builder.AddArc(new Vector2(x + width, y + pixel), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                }
                else
                {
                    builder.AddLine(x + pixel, y + pixel);
                    builder.AddLine(x + width, y + pixel);
                }

                if (bottomLeft)
                {
                    builder.AddArc(new Vector2(x, y + height), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                }
                else
                {
                    builder.AddLine(x, y + pixel);
                }

                builder.EndFigure(CanvasFigureLoop.Closed);
            };
            void warch(float x, float y, float width, float height, int direction)
            {
                if (direction == 0)
                {
                    builder.BeginFigure(x, y + height);
                    builder.AddArc(new Vector2(x + width, y), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                    builder.AddLine(x, y);
                }
                else if (direction == 1)
                {
                    builder.BeginFigure(x, y);
                    builder.AddArc(new Vector2(x + width, y + height), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                    builder.AddLine(x + width, y);
                }
                else if (direction == 2)
                {
                    builder.BeginFigure(x + width, y);
                    builder.AddArc(new Vector2(x, y + height), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                    builder.AddLine(x + width, y + width);
                }
                else if (direction == 3)
                {
                    builder.BeginFigure(x + width, y + height);
                    builder.AddArc(new Vector2(x, y), width, height, 0, CanvasSweepDirection.Clockwise, CanvasArcSize.Small);
                    builder.AddLine(x, y + height);
                }

                builder.EndFigure(CanvasFigureLoop.Closed);
            }

            for (int row = 0; row != data.Size; ++row)
            {
                for (int column = 0; column != data.Size; ++column)
                {
                    if ((row < 7 && (column < 7 || column >= data.Size - 7)) ||
                        (column < 7 && (row < 7 || row >= data.Size - 7)))
                    {
                        continue;
                    }

                    var x = column * pixel;
                    var y = row * pixel;

                    if (value(row, column))
                    {
                        if (blackFull(row, column))
                        {
                            brect(x, y, pixel, pixel);
                        }
                        else
                        {
                            var top    = value(row - 1, column);
                            var bottom = !top && value(row + 1, column);
                            var left   = value(row, column - 1);
                            var right  = !left && value(row, column + 1);

                            barch(x, y, !top && !left, !top && !right, !bottom && !right, !bottom && !left);
                        }
                    }
                    else if (!whiteFull(row, column))
                    {
                        if (!whiteCorner(row, column, -1, -1))
                        {
                            warch(x, y, pixel / 2, pixel / 2, 0);
                        }
                        if (!whiteCorner(row, column, 1, -1))
                        {
                            warch(x + skip, y, pixel / 2, pixel / 2, 1);
                        }
                        if (!whiteCorner(row, column, 1, 1))
                        {
                            warch(x + skip, y + skip, pixel / 2, pixel / 2, 2);
                        }
                        if (!whiteCorner(row, column, -1, 1))
                        {
                            warch(x, y + skip, pixel / 2, pixel / 2, 3);
                        }
                    }
                }
            }

            large(0, 0);
            large((data.Size - 7) * pixel - 2, 0);
            large(0, (data.Size - 7) * pixel - 2);

            var compositor = Window.Current.Compositor;
            var blackBrush = compositor.CreateColorBrush(foreground);

            var path1 = compositor.CreatePathGeometry(new CompositionPath(CanvasGeometry.CreateGroup(null, geometries, CanvasFilledRegionDetermination.Winding)));
            var path2 = compositor.CreatePathGeometry(new CompositionPath(CanvasGeometry.CreatePath(builder)));

            var shape1 = compositor.CreateSpriteShape(path1);

            shape1.FillBrush = blackBrush;

            var shape2 = compositor.CreateSpriteShape(path2);

            shape2.FillBrush = blackBrush;

            var visual1 = compositor.CreateShapeVisual();

            visual1.Size = new Vector2(259, 259);
            visual1.Shapes.Add(shape1);

            var visual2 = compositor.CreateShapeVisual();

            visual2.Size = new Vector2(259, 259);
            visual2.Shapes.Add(shape2);

            var container = compositor.CreateContainerVisual();

            container.Size = new Vector2(259, 259);
            container.Children.InsertAtTop(visual1);
            container.Children.InsertAtTop(visual2);

            ElementCompositionPreview.SetElementChildVisual(this, container);

            if (fadeIn)
            {
                var opacity = compositor.CreateScalarKeyFrameAnimation();
                opacity.InsertKeyFrame(0, 0);
                opacity.InsertKeyFrame(1, 1);

                visual2.StartAnimation("Opacity", opacity);
            }
        }
        //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;
            }
        }