Reverse() public method

public Reverse ( ) : void
return void
        private static void ArcRenderRange(this Graphics Graphics, Rectangle ClientRectangle, Point Center, Int32 ArcStart, Int32 ArcSweep, Single MinimumValue, Single MaximumValue, ArcRangeDef Range)
        {
            Graphics.SetClip(ClientRectangle);
            Graphics.SmoothingMode = SmoothingMode.HighQuality;
            Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

            using (var graphicsPath = new GraphicsPath()) {
                if (Range.EndValue > Range.StartValue && Range.Enabled) {
                    var rangeStartAngle = ArcStart + (Range.StartValue - MinimumValue) * ArcSweep / (MaximumValue - MinimumValue);
                    var rangeSweepAngle = (Range.EndValue - Range.StartValue) * ArcSweep / (MaximumValue - MinimumValue);
                    graphicsPath.Reset();
                    graphicsPath.AddPie(new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
                    graphicsPath.Reverse();
                    graphicsPath.AddPie(new Rectangle(Center.X - Range.InnerRadius, Center.Y - Range.InnerRadius, 2 * Range.InnerRadius, 2 * Range.InnerRadius), rangeStartAngle, rangeSweepAngle);
                    graphicsPath.Reverse();
                    Graphics.SetClip(graphicsPath);
                    using (var solidBrush = new SolidBrush(Range.ForeColor)) {
                        Graphics.FillPie(solidBrush, new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
                    }
                }
            }
        }
Exemplo n.º 2
0
		public void Reverse_Subpath_Marker_2 ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLine (0, 1, 2, 3);
				gp.SetMarkers ();
				gp.StartFigure ();
				gp.AddLine (20, 21, 22, 23);
				gp.AddBezier (5, 6, 7, 8, 9, 10, 11, 12);
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 3, 3, 3, 1, 33, 0, 1 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 3
0
		public void Reverse_Marker ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddRectangle (new Rectangle (200, 201, 60, 61));
				gp.SetMarkers ();
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 1, 1, 129 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 4
0
		[Category ("NotWorking")] // the output differs from GDI+ and libgdiplus
		public void Reverse_String ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				FontFamily ff = GetFontFamily ();
				gp.AddString ("Mono::", ff, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,129,0,3,3,3,
					3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,
					3,3,3,3,3,3,3,129,0,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,161,0,3,3,3,3,3,
					3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,131,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
					163,0,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,
					1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,
					3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,161,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,131,
					0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,163,0,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,
					3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,
					1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,129 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 5
0
		public void Reverse_Path ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				GraphicsPath path = new GraphicsPath ();
				path.AddArc (1f, 1f, 2f, 2f, Pi4, Pi4);
				path.AddLine (1, 2, 3, 4);
				gp.AddPath (path, true);
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 1, 1, 3, 3, 3 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 6
0
        private GraphicsPath GetRoundedPath1(Rectangle rect, Rectangle rectPrev, Rectangle rectNext, ref GraphicsPath path4Fill, int charW)
        {
            int r = RoundedCornersRadius; int d = r * 2;
            Rectangle arc = new Rectangle(rect.Location, new Size(d, d));
            GraphicsPath path4Bord = new GraphicsPath();
            if (d > rect.Height) {
                d = rect.Height; r = rect.Height / 2;
                arc.Width  = d;
                arc.Height = d;
            }

            if (rectNext.Width >0 && rect.Left > rectNext.Left) {
                arc.X = rect.Left - d;
                arc.Y = rect.Bottom - d;
                var p = new GraphicsPath();
                p.AddArc(arc, 0, 90);
                p.Reverse();
                path4Bord.AddPath(p, true);
                var p2 = new GraphicsPath();
                p2.AddArc(arc, 0, 90);
                p2.Reverse();
                path4Fill.AddPath(p2, true);
            }

            Point pLeftBottom = new Point(rect.Left, rect.Bottom - r);
            Point pLeftTop    = new Point(rect.Left, rect.Top    + r);

            if (rectNext.Width!=0 && rectNext.Left == rect.Left)
                pLeftBottom = new Point(rect.Left, rect.Bottom);

            if (rectPrev.Width!=0 && rectPrev.Left == rect.Left)
                pLeftTop    = new Point(rect.Left, rect.Top   );

            path4Bord.AddLine(pLeftBottom, pLeftTop);
            path4Fill.AddLine(new Point(pLeftBottom.X, pLeftBottom.Y), pLeftTop);
            if (rectPrev.IsEmpty) {
                // This is first line
                arc.X = rect.Left;
                arc.Y = rect.Top;
                path4Bord.AddArc(arc, 180, 90);
                path4Fill.AddArc(arc, 180, 90);
                arc.X = rect.Right - d;
                path4Bord.AddArc(arc, 270, 90);
                path4Fill.AddArc(arc, 270, 90);
                NextLinePath(ref path4Bord, ref path4Fill, rect, rectNext, arc, d, charW);
            } else {
                // This is no first line
                if (rect.Left < rectPrev.Left) {
                    path4Bord.AddArc(arc, 180, 90);
                    path4Fill.AddArc(arc, 180, 90);
                    path4Bord.StartFigure();
                    path4Bord.AddLine(rect.Left + r, rect.Top, rectPrev.Left - r, rect.Top);
                    path4Fill.AddLine(rect.Left + r, rect.Top, rectPrev.Left - r, rect.Top);
                }
                if (rect.Right > rectPrev.Right) {
                    int a = 0;
                    if (d > (rect.Right - rectPrev.Right)) {
                        a = d;
                        d = charW; r = charW / 2;
                        arc.Width  = d;
                        arc.Height = d;
                    }
                    path4Bord.StartFigure();
                    path4Bord.AddLine(rectPrev.Right + r, rect.Top, rect.Right - r, rect.Top);
                    path4Fill.AddLine(rectPrev.Right + r, rect.Top, rect.Right - r, rect.Top);
                    arc.X = rect.Right - d;
                    arc.Y = rect.Top;
                    path4Bord.AddArc(arc, 270, 90);
                    path4Fill.AddArc(arc, 270, 90);
                    if (a > 0) {
                        d = a; r = d / 2;
                        arc.Width  = d;
                        arc.Height = d;
                        arc.X = rect.Right - d;
                        arc.Y = rect.Top;
                    }
                    NextLinePath(ref path4Bord, ref path4Fill, rect, rectNext, arc, d, charW);
                } else if (rect.Right < rectPrev.Right) {
                    int a = 0;
                    if (d > (rectPrev.Right - rect.Right)) {
                        a = d;
                        d = charW; r = charW / 2;
                        arc.Width  = d;
                        arc.Height = d;
                    }
                    path4Bord.StartFigure();
                    arc.Y = rect.Top;
                    arc.X = rect.Right;
                    var p = new GraphicsPath();
                    p.AddArc(arc, 180, 90);
                    p.Reverse();
                    path4Bord.AddPath(p, false);
                    path4Fill.AddPath(p, true);
                    if (a > 0) {
                        d = a; r = d / 2;
                        arc.Width  = d;
                        arc.Height = d;
                    }
                    path4Bord.AddLine(rect.Right, rect.Top + r, rect.Right, rect.Bottom - r);
                    path4Fill.AddLine(rect.Right, rect.Top + r, rect.Right, rect.Bottom - r);
                    arc.X = rect.Right - d;
                    arc.Y = rect.Bottom;
                    NextLinePath(ref path4Bord, ref path4Fill, rect, rectNext, arc, d, charW);
                } else {
                    path4Bord.StartFigure();
                    path4Bord.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom - d);
                    path4Fill.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom - d);
                    arc.X = rect.Right - d;
                    arc.Y = rect.Bottom;
                    NextLinePath(ref path4Bord, ref path4Fill, rect, rectNext, arc, d, charW);
                }
            }
            return path4Bord;
        }
Exemplo n.º 7
0
 public void RenderLines(RequestedTileInformation ti, Graphics g, Way way, RenderInfo ri)
 {
     if (way.WayDataBlocks != null && way.WayDataBlocks.Count > 0)
     {
         bool nDone = false;
         float f = getPaintZoomLevel(ti.Zoom);
         foreach (Way.WayData wd in way.WayDataBlocks)
         {
             System.Drawing.PointF[] pa = (from p in wd.DataBlock[0].CoordBlock select new System.Drawing.PointF((float)toRelTileX(p.Longitude, ti.X, ti.Zoom), (float)toRelTileY(p.Latitude, ti.Y, ti.Zoom))).ToArray();
             using (GraphicsPath gp = new GraphicsPath())
             {
                 for (int i = 0; i < pa.Length - 1; i++)
                 {
                     gp.AddLine(pa[i], pa[i + 1]);
                 }
                 Pen p = ri.Pen ?? new Pen(Color.Black);
                 p.Width = ri.fstroke_width * f;
                 g.DrawPath(p, gp);
                 if (ri.FillPen != null)
                 {
                     ri.FillPen.Width = ri.fstroke_width * f * 0.8f;
                     g.DrawPath(ri.FillPen, gp);
                 }
                 if (!string.IsNullOrEmpty(way.Name) && p.Width > 6.0f && !nDone)
                 {
                     nDone = true; //only once per tile is enough I think
                     using (Font fnt = new Font(FontFamily.GenericSerif, p.Width))
                     {
                         //determine angle of polyline (use start and endpoint?)
                         //if wrong (text upside down), then reverse polyline
                         PointF p1 = pa[0];
                         PointF p2 = pa[pa.Length - 1];
                         if (p1.X > p2.X)
                         {
                             gp.Reverse();
                         }
                         g.DrawString(way.Name, fnt, _fixedTextBrush, TextPathAlign.Center, TextPathPosition.CenterPath, 100, 0, gp);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
            //画刻度
            private void ImageBack1(GraphicsPath gp, Graphics ggr, ImagePaint imgp)
            {
                for (var counter = 0; counter < mRangeEndValue.Length; counter++)
                {
                    if (!(mRangeEndValue[counter] > mRangeStartValue[counter]) || !mRangeEnabled[counter])
                    {
                        continue;
                    }

                    var rangeStartAngle = mBaseArcStart +(mRangeStartValue[counter] - mMinValue) * mBaseArcSweep /(mMaxValue - mMinValue);
                    var rangeSweepAngle = (mRangeEndValue[counter] - mRangeStartValue[counter]) * mBaseArcSweep / (mMaxValue - mMinValue);
                    gp.Reset();
                    gp.AddPie(
                        new Rectangle(mCenter.X - mRangeOuterRadius[counter],
                                      mCenter.Y - mRangeOuterRadius[counter], 2 * mRangeOuterRadius[counter],
                                      2 * mRangeOuterRadius[counter]), rangeStartAngle, rangeSweepAngle);
                    gp.Reverse();
                    gp.AddPie(
                        new Rectangle(mCenter.X - mRangeInnerRadius[counter],
                                      mCenter.Y - mRangeInnerRadius[counter], 2 * mRangeInnerRadius[counter],
                                      2 * mRangeInnerRadius[counter]), rangeStartAngle, rangeSweepAngle);
                    gp.Reverse();
                    ggr.SetClip(gp);
                    //填充
                    ggr.FillPie(new SolidBrush(mRangeColor[counter]),
                                new Rectangle(mCenter.X - mRangeOuterRadius[counter],
                                              mCenter.Y - mRangeOuterRadius[counter],
                                              2 * mRangeOuterRadius[counter], 2 * mRangeOuterRadius[counter]),
                                rangeStartAngle, rangeSweepAngle);
                }
                ggr.SetClip(imgp.ClientRectangle);

                if (mBaseArcRadius > 0)
                {
                    ggr.DrawArc(new Pen(mBaseArcColor, mBaseArcWidth),
                                new Rectangle(mCenter.X - mBaseArcRadius, mCenter.Y - mBaseArcRadius,
                                              2 * mBaseArcRadius, 2 * mBaseArcRadius), mBaseArcStart, mBaseArcSweep);
                }
            }
Exemplo n.º 9
0
        public virtual void Enumerate() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));

			path.StartFigure ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));

			path.StartFigure ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			path.Reverse ();

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);
			PointF [] actualPoints = new PointF [14];
			byte [] actualTypes = new byte [14];
			iterator.Enumerate (ref actualPoints, ref actualTypes);

			PointF [] expectedPoints = new PointF [] {	new PointF(400f, 10f), 
														new PointF(400f, 400f), 
														new PointF(10f, 420f), 
														new PointF(310f, 420f), 
														new PointF(310f, 20f), 
														new PointF(10f, 20f), 
														new PointF(200f, 280f), 
														new PointF(100f, 5f), 
														new PointF(50f, 250f), 
														new PointF(10f, 10f), 
														new PointF(10f, 100f), 
														new PointF(400f, 200f), 
														new PointF(400f, 100f), 
														new PointF(100f, 100f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}	
        }
Exemplo n.º 10
0
        private void SetMarkers2(Graphics g)
        {
            // Create a path and set two markers.
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddLine(new Point(0, 0), new Point(50, 50));
            myPath.SetMarkers();
            Rectangle rect = new Rectangle(50, 50, 50, 50);
            myPath.AddRectangle(rect);
            myPath.SetMarkers();
            myPath.AddEllipse(100, 100, 100, 50);

            var pathPoints = myPath.PathPoints;
            var pathTypes = myPath.PathTypes;

            Console.WriteLine("SetMarkers Before reverse");
            for (int i = 0; i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine("{0} - {1},{2}", (PathPointType)pathTypes[i], pathPoints[i].X, pathPoints[i].Y);
            }

            // Draw the path to screen.
            g.FillPath(Brushes.Red, myPath);
            g.DrawPath(new Pen(Color.Black, 2), myPath);

            // Draw the first set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 20);

            // Call GraphicsPath.Reverse.
            myPath.Reverse();

            pathPoints = myPath.PathPoints;
            pathTypes = myPath.PathTypes;

            Console.WriteLine("SetMarkers After reverse");
            for (int i = 0; i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine("{0} - {1},{2}", (PathPointType)pathTypes[i], pathPoints[i].X, pathPoints[i].Y);
            }

            // Draw the path to screen.
            g.FillPath(Brushes.CornflowerBlue, myPath);
            g.DrawPath(new Pen(Color.Black, 2), myPath);

            // Draw the reversed set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 150);
        }
Exemplo n.º 11
0
        // End DrawPoints
        public void Reverse1(Graphics g)
        {
            // Create a path and add a line, ellipse, and arc.
            GraphicsPath myPath = new GraphicsPath(FillMode.Winding);
            myPath.AddLine(new Point(0, 0), new Point(100, 100));
            myPath.AddEllipse(100, 100, 200, 250);
            myPath.AddArc(300, 250, 100, 100, 0, 90);

            g.DrawPath (Pens.Red, myPath);
            g.FillPath (Brushes.Red, myPath);

            var pathPoints = myPath.PathPoints;
            var pathTypes = myPath.PathTypes;

            Console.WriteLine ("Before reverse");
            for(int i=0;i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine ("{0} - {1},{2}", (PathPointType)pathTypes [i], pathPoints[i].X,pathPoints[i].Y);
            }

            // Draw the first set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 20);

            // Call GraphicsPath.Reverse.
            myPath.Reverse();

            g.DrawPath (Pens.Blue, myPath);
            g.FillPath (Brushes.Blue, myPath);

            pathPoints = myPath.PathPoints;
            pathTypes = myPath.PathTypes;

            Console.WriteLine ("After reverse");
            for(int i=0;i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine ("{0} - {1},{2}", (PathPointType)pathTypes [i], pathPoints[i].X,pathPoints[i].Y);
            }

            // Draw the reversed set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 150);
        }
Exemplo n.º 12
0
        public void EvaluateParameters()
        {
            Rectangle outerRectangle = new Rectangle(
                (int)(_owner.Center.X - _owner.OuterRadius * _outerFactor),
                (int)(_owner.Center.Y - _owner.OuterRadius * _outerFactor),
                (int)(2 * _owner.OuterRadius * _outerFactor),
                (int)(2 * _owner.OuterRadius * _outerFactor)
                );

            Rectangle innerRectangle = new Rectangle(
                (int)(_owner.Center.X - _owner.InnerRadius * _innerFactor),
                (int)(_owner.Center.Y - _owner.InnerRadius * _innerFactor),
                (int)(2 * _owner.InnerRadius * _innerFactor),
                (int)(2 * _owner.InnerRadius * _innerFactor)
                );

            // Внешняя дуга.
            GraphicsPath outerArc = new GraphicsPath();
            outerArc.AddArc(outerRectangle, _startAngle, _sweepAngle);

            // Внутренняя дуга сектора.
            GraphicsPath innerArc = new GraphicsPath();
            innerArc.AddArc(innerRectangle, _startAngle, _sweepAngle);

            // Вычисляем границу сектора.
            _diagSectorPath.Dispose();
            _diagSectorPath = new GraphicsPath();
            _diagSectorPath.AddPath(outerArc, true);
            _diagSectorPath.AddLine(
                outerArc.GetLastPoint(),
                innerArc.GetLastPoint()
                );
            innerArc.Reverse();
            _diagSectorPath.AddPath(innerArc, true);
            outerArc.Reverse();
            _diagSectorPath.AddLine(
                outerArc.GetLastPoint(),
                innerArc.GetLastPoint()
                );

            _region.Dispose();
            _region = new Region(_diagSectorPath);

            _owner.Invalidate();
        }
Exemplo n.º 13
0
		public void Reverse2()
		{
			path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.SetMarkers ();
			path.AddLine (new Point (400, 200), new Point (10, 100));

			path.SetMarkers ();
			path.StartFigure ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.SetMarkers ();
			path.StartFigure ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));

			path.StartFigure ();
			path.AddLine (new Point (400, 400), new Point (400, 10));
			path.AddBezier( 100, 100, 500, 250, 150, 500, 250, 300);
			path.SetMarkers ();
			path.AddLine (new Point (400, 450), new Point (500, 510));
			path.SetMarkers ();
			path.CloseFigure ();

			path.Reverse ();

			PointF [] expectedPoints = new PointF [] {	new PointF(500f, 510f), 
														new PointF(400f, 450f), 
														new PointF(250f, 300f), 
														new PointF(150f, 500f), 
														new PointF(500f, 250f), 
														new PointF(100f, 100f), 
														new PointF(400f, 10f), 
														new PointF(400f, 400f), 
														new PointF(10f, 420f), 
														new PointF(310f, 420f), 
														new PointF(310f, 20f), 
														new PointF(10f, 20f), 
														new PointF(200f, 280f), 
														new PointF(100f, 5f), 
														new PointF(50f, 250f), 
														new PointF(10f, 10f), 
														new PointF(10f, 100f), 
														new PointF(400f, 200f), 
														new PointF(400f, 100f), 
														new PointF(100f, 100f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) (PathPointType.Line | PathPointType.PathMarker), 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) (PathPointType.Bezier3 | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) (PathPointType.Line | PathPointType.PathMarker),
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	
			
			//t.AssertCompare ();
		}
Exemplo n.º 14
0
 private void NextLinePath(ref GraphicsPath path4Bord, ref GraphicsPath path4Fill, Rectangle rect, 
                           Rectangle rectNext, Rectangle arc, int d, int charW)
 {
     if (rectNext.Width == 0) {
         arc.X = rect.Right  - d;
         arc.Y = rect.Bottom - d;
         path4Bord.AddArc(arc, 0, 90);
         path4Fill.AddArc(arc, 0, 90);
         arc.X = rect.Left;
         path4Bord.AddArc(arc, 90, 90);
         path4Fill.AddArc(arc, 90, 90);
     } else if (rectNext.Right > rect.Right) {
         if (d > (rectNext.Right - rect.Right)) {
             d = charW;
             arc.Width  = d;
             arc.Height = d;
         }
         arc.X = rect.Right;
         arc.Y = rect.Bottom - d;
         var p1 = new GraphicsPath();
         p1.AddArc(arc, 90, 90);
         p1.Reverse();
         path4Bord.AddPath(p1, true);
         path4Fill.AddPath(p1, true);
     } else if (rectNext.Right < rect.Right) {
         if (d > (rect.Right - rectNext.Right)) {
             d = charW;
             arc.Width  = d;
             arc.Height = d;
         }
         arc.X = rect.Right  - d;
         arc.Y = rect.Bottom - d;
         path4Bord.AddArc(arc, 0, 90);
         path4Fill.AddArc(arc, 0, 90);
         path4Bord.AddLines(new Point[] { new Point(rectNext.Right + d / 2, rect.Bottom) });
         path4Fill.AddLines(new Point[] { new Point(rectNext.Right + d / 2, rect.Bottom) });
     } else {
         path4Bord.AddLines(new Point[] { new Point(rect.Right, rect.Bottom  ) });
         path4Fill.AddLines(new Point[] { new Point(rect.Right, rect.Bottom+1) });
     }
 }
        public static void RenderArcScaleLines(
                                                    this Graphics Graphics, Rectangle ClientRectangle, Point Center,
                                                    Int32 MinorTickOuterRadius, Int32 MinorTickInnerRadius, Int32 MinorTickWidth, Color MinorTickForeColor, Int32 MinorNumOfTicks,
                                                    Int32 IntermediateTickOuterRadius, Int32 IntermediateTickInnerRadius, Int32 IntermediateTickWidth, Color IntermediateTickForeColor,
                                                    Int32 MajorTickOuterRadius, Int32 MajorTickInnerRadius, Int32 MajorTickWidth, Color MajorTickForeColor, Single MajorStepValue,
                                                    Single MinimumValue, Single MaximumValue,
                                                    Int32 ArcStart, Int32 ArcSweep
            )
        {
            using (var graphicsPath = new GraphicsPath()) {
                var renderMajorScale = true;
                var renderIntermediateScale = true;
                var renderMinorScale = true;

                Graphics.SetClip(ClientRectangle);
                Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

                Single countValue = 0;
                Int32 counter1 = 0;
                while (countValue <= (MaximumValue - MinimumValue)) {

                    graphicsPath.Reset();
                    if (renderMajorScale) {
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MajorTickOuterRadius, Center.Y - MajorTickOuterRadius, 2 * MajorTickOuterRadius, 2 * MajorTickOuterRadius));
                        graphicsPath.Reverse();
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MajorTickInnerRadius, Center.Y - MajorTickInnerRadius, 2 * MajorTickInnerRadius, 2 * MajorTickInnerRadius));
                        graphicsPath.Reverse();
                    }
                    Graphics.SetClip(graphicsPath);

                    using (var pen = new Pen(MajorTickForeColor, MajorTickWidth)) {
                        Graphics.DrawLine(
                                            pen,
                                            (Single)(Center.X),
                                            (Single)(Center.Y),
                                            (Single)(Center.X + 2 * MajorTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0)),
                                            (Single)(Center.Y + 2 * MajorTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0))
                                         );
                    }

                    graphicsPath.Reset();
                    if (renderMinorScale) {
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickOuterRadius, Center.Y - MinorTickOuterRadius, 2 * MinorTickOuterRadius, 2 * MinorTickOuterRadius));
                        graphicsPath.Reverse();
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickInnerRadius, Center.Y - MinorTickInnerRadius, 2 * MinorTickInnerRadius, 2 * MinorTickInnerRadius));
                        graphicsPath.Reverse();
                    }
                    Graphics.SetClip(graphicsPath);

                    if (countValue < (MaximumValue - MinimumValue)) {
                        for (var index = 1; index <= MinorNumOfTicks; index++) {
                            if (((MinorNumOfTicks % 2) == 1) && ((Int32)(MinorNumOfTicks / 2) + 1 == index)) {

                                graphicsPath.Reset();
                                if (renderIntermediateScale) {
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - IntermediateTickOuterRadius, Center.Y - IntermediateTickOuterRadius, 2 * IntermediateTickOuterRadius, 2 * IntermediateTickOuterRadius));
                                    graphicsPath.Reverse();
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - IntermediateTickInnerRadius, Center.Y - IntermediateTickInnerRadius, 2 * IntermediateTickInnerRadius, 2 * IntermediateTickInnerRadius));
                                    graphicsPath.Reverse();
                                }
                                Graphics.SetClip(graphicsPath);

                                using (var pen = new Pen(IntermediateTickForeColor, IntermediateTickWidth)) {
                                    Graphics.DrawLine(
                                                        pen,
                                                        (Single)(Center.X),
                                                        (Single)(Center.Y),
                                                        (Single)(Center.X + 2 * IntermediateTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0)),
                                                        (Single)(Center.Y + 2 * IntermediateTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0))
                                                      );
                                }

                                graphicsPath.Reset();
                                if (renderMinorScale) {
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickOuterRadius, Center.Y - MinorTickOuterRadius, 2 * MinorTickOuterRadius, 2 * MinorTickOuterRadius));
                                    graphicsPath.Reverse();
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickInnerRadius, Center.Y - MinorTickInnerRadius, 2 * MinorTickInnerRadius, 2 * MinorTickInnerRadius));
                                    graphicsPath.Reverse();
                                }
                                Graphics.SetClip(graphicsPath);

                            } else {
                                using (var pen = new Pen(MinorTickForeColor, MinorTickWidth)) {
                                    Graphics.DrawLine(
                                                        pen,
                                                        (Single)(Center.X),
                                                        (Single)(Center.Y),
                                                        (Single)(Center.X + 2 * MinorTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0)),
                                                        (Single)(Center.Y + 2 * MinorTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0))
                                                     );
                                }
                            }
                        }
                    }

                    countValue += MajorStepValue;
                    counter1++;
                }
            }
            Graphics.ResetTransform();
        }
Exemplo n.º 16
0
		public void GraphicsPath_Empty ()
		{
			GraphicsPath gp = new GraphicsPath ();
			Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Empty.FillMode");
			CheckEmpty ("Empty.", gp);

			GraphicsPath clone = (GraphicsPath) gp.Clone ();
			Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Clone.FillMode");
			CheckEmpty ("Clone.", gp);

			gp.Reverse ();
			CheckEmpty ("Reverse.", gp);
		}
Exemplo n.º 17
0
            public void ImageBack3(Single countValue, GraphicsPath gp, Graphics ggr, ImagePaint imgp)
            {
                if (countValue < (mMaxValue - mMinValue))
                {
                    for (var counter2 = 1; counter2 <= mScaleLinesMinorNumOf; counter2++)
                    {
                        if (((mScaleLinesMinorNumOf % 2) == 1) &&
                            ((mScaleLinesMinorNumOf / 2) + 1 == counter2))
                        {
                            gp.Reset();
                            gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesInterOuterRadius,
                                                        mCenter.Y - mScaleLinesInterOuterRadius,
                                                        2 * mScaleLinesInterOuterRadius,
                                                        2 * mScaleLinesInterOuterRadius));
                            gp.Reverse();
                            gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesInterInnerRadius,
                                                        mCenter.Y - mScaleLinesInterInnerRadius,
                                                        2 * mScaleLinesInterInnerRadius,
                                                        2 * mScaleLinesInterInnerRadius));
                            gp.Reverse();
                            ggr.SetClip(gp);

                            ggr.DrawLine(new Pen(mScaleLinesInterColor, mScaleLinesInterWidth),
                                         (Center.X),
                                         (Center.Y),
                                         (Single)
                                         (Center.X +
                                          2 * mScaleLinesInterOuterRadius *
                                          Math.Cos((mBaseArcStart +
                                                    countValue * mBaseArcSweep / (mMaxValue - mMinValue) +
                                                    counter2 * mBaseArcSweep /
                                                    ((
                                                         ((mMaxValue - mMinValue) / mScaleLinesMajorStepValue)) *
                                                     (mScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)),
                                         (Single)
                                         (Center.Y +
                                          2 * mScaleLinesInterOuterRadius *
                                          Math.Sin((mBaseArcStart +
                                                    countValue * mBaseArcSweep / (mMaxValue - mMinValue) +
                                                    counter2 * mBaseArcSweep /
                                                    ((
                                                         ((mMaxValue - mMinValue) / mScaleLinesMajorStepValue)) *
                                                     (mScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)));

                            gp.Reset();
                            gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMinorOuterRadius,
                                                        mCenter.Y - mScaleLinesMinorOuterRadius,
                                                        2 * mScaleLinesMinorOuterRadius,
                                                        2 * mScaleLinesMinorOuterRadius));
                            gp.Reverse();
                            gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMinorInnerRadius,
                                                        mCenter.Y - mScaleLinesMinorInnerRadius,
                                                        2 * mScaleLinesMinorInnerRadius,
                                                        2 * mScaleLinesMinorInnerRadius));
                            gp.Reverse();
                            ggr.SetClip(gp);
                        }
                        else
                        {
                            ggr.DrawLine(new Pen(mScaleLinesMinorColor, mScaleLinesMinorWidth),
                                         (Center.X),
                                         (Center.Y),
                                         (Single)
                                         (Center.X +
                                          2 * mScaleLinesMinorOuterRadius *
                                          Math.Cos((mBaseArcStart +
                                                    countValue * mBaseArcSweep / (mMaxValue - mMinValue) +
                                                    counter2 * mBaseArcSweep /
                                                    ((
                                                         ((mMaxValue - mMinValue) / mScaleLinesMajorStepValue)) *
                                                     (mScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)),
                                         (Single)
                                         (Center.Y +
                                          2 * mScaleLinesMinorOuterRadius *
                                          Math.Sin((mBaseArcStart +
                                                    countValue * mBaseArcSweep / (mMaxValue - mMinValue) +
                                                    counter2 * mBaseArcSweep /
                                                    ((
                                                         ((mMaxValue - mMinValue) / mScaleLinesMajorStepValue)) *
                                                     (mScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)));
                        }
                    }
                }
                ggr.SetClip(imgp.ClientRectangle);
            }
Exemplo n.º 18
0
		// Reverse simple test cases

		private void Reverse (GraphicsPath gp)
		{
			PointF[] bp = gp.PathPoints;
			byte[] bt = gp.PathTypes;

			gp.Reverse ();
			PointF[] ap = gp.PathPoints;
			byte[] at = gp.PathTypes;

			int count = gp.PointCount;
			Assert.AreEqual (bp.Length, count, "PointCount");
			for (int i = 0; i < count; i++) {
				Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
				Assert.AreEqual (bt[i], at[i], "Type" + i.ToString ());
			}
		}
Exemplo n.º 19
0
            private void ImageBack2(GraphicsPath gp, Graphics ggr, ImagePaint imgp)
            {
                float countValue = 0;
                var counter1 = 0;
                while (countValue <= (mMaxValue - mMinValue))
                {
                    var valueText = (mMinValue + countValue).ToString(mScaleNumbersFormat);
                    ggr.ResetTransform();
                    var boundingBox = ggr.MeasureString(valueText, imgp.Font, -1, StringFormat.GenericTypographic);

                    gp.Reset();
                    gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMajorOuterRadius,
                                                mCenter.Y - mScaleLinesMajorOuterRadius,
                                                2 * mScaleLinesMajorOuterRadius, 2 * mScaleLinesMajorOuterRadius));
                    gp.Reverse();
                    gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMajorInnerRadius,
                                                mCenter.Y - mScaleLinesMajorInnerRadius,
                                                2 * mScaleLinesMajorInnerRadius, 2 * mScaleLinesMajorInnerRadius));
                    gp.Reverse();
                    ggr.SetClip(gp);

                    ggr.DrawLine(new Pen(mScaleLinesMajorColor, mScaleLinesMajorWidth),
                                 (Center.X), (Center.Y),
                                 (Single)
                                 (Center.X +
                                  2 * mScaleLinesMajorOuterRadius *
                                  Math.Cos((mBaseArcStart + countValue * mBaseArcSweep / (mMaxValue - mMinValue)) * Math.PI /
                                           180.0)),
                                 (Single)
                                 (Center.Y +
                                  2 * mScaleLinesMajorOuterRadius *
                                  Math.Sin((mBaseArcStart + countValue * mBaseArcSweep / (mMaxValue - mMinValue)) * Math.PI /
                                           180.0)));

                    gp.Reset();
                    gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMinorOuterRadius,
                                                mCenter.Y - mScaleLinesMinorOuterRadius,
                                                2 * mScaleLinesMinorOuterRadius, 2 * mScaleLinesMinorOuterRadius));
                    gp.Reverse();
                    gp.AddEllipse(new Rectangle(mCenter.X - mScaleLinesMinorInnerRadius,
                                                mCenter.Y - mScaleLinesMinorInnerRadius,
                                                2 * mScaleLinesMinorInnerRadius, 2 * mScaleLinesMinorInnerRadius));
                    gp.Reverse();
                    ggr.SetClip(gp);

                    ImageBack3(countValue, gp, ggr, imgp);

                    if (mScaleNumbersRotation != 0)
                    {
                        ggr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        ggr.RotateTransform(90.0F + mBaseArcStart + countValue * mBaseArcSweep / (mMaxValue - mMinValue));
                    }
                    ggr.TranslateTransform(
                        (Single)
                        (Center.X +
                         mScaleNumbersRadius *
                         Math.Cos((mBaseArcStart + countValue * mBaseArcSweep / (mMaxValue - mMinValue)) * Math.PI / 180.0f)),
                        (Single)
                        (Center.Y +
                         mScaleNumbersRadius *
                         Math.Sin((mBaseArcStart + countValue * mBaseArcSweep / (mMaxValue - mMinValue)) * Math.PI / 180.0f)),
                        MatrixOrder.Append);

                    if (counter1 >= ScaleNumbersStartScaleLine - 1)
                    {
                        ggr.DrawString(valueText, imgp.Font, new SolidBrush(mScaleNumbersColor), -boundingBox.Width / 2,
                                       -fontBoundY1 - (fontBoundY2 - fontBoundY1 + 1) / 2,
                                       StringFormat.GenericTypographic);
                    }

                    countValue += mScaleLinesMajorStepValue;
                    counter1++;
                }
                ggr.ResetTransform();
                ggr.SetClip(imgp.ClientRectangle);
            }
Exemplo n.º 20
0
		[Category ("NotWorking")] // the output differs from GDI+ and libgdiplus
		public void Reverse_Pie ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddPie (1, 2, 3, 4, 10, 20);
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 3, 3, 3, 129 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;
				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 21
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            if ((Width < 10) || (Height < 10))
            {
                return;
            }

            if (drawGaugeBackground)
            {
                drawGaugeBackground = false;

                FindFontBounds();

                gaugeBitmap = new Bitmap(Width, Height, pe.Graphics);
                Graphics ggr = Graphics.FromImage(gaugeBitmap);
                ggr.FillRectangle(new SolidBrush(BackColor), ClientRectangle);

                if (BackgroundImage!=null)
                {
                    switch (BackgroundImageLayout)
                    {
                        case ImageLayout.Center:
                            ggr.DrawImageUnscaled(BackgroundImage, Width / 2 - BackgroundImage.Width / 2, Height / 2 - BackgroundImage.Height / 2);
                            break;
                        case ImageLayout.None:
                            ggr.DrawImageUnscaled(BackgroundImage, 0, 0);
                            break;
                        case ImageLayout.Stretch:
                            ggr.DrawImage(BackgroundImage, 0, 0, Width, Height);
                            break;
                        case ImageLayout.Tile:
                            Int32 pixelOffsetX = 0;
                            Int32 pixelOffsetY = 0;
                            while (pixelOffsetX < Width)
                            {
                                pixelOffsetY = 0;
                                while (pixelOffsetY < Height)
                                {
                                    ggr.DrawImageUnscaled(BackgroundImage, pixelOffsetX, pixelOffsetY);
                                    pixelOffsetY += BackgroundImage.Height;
                                }
                                pixelOffsetX += BackgroundImage.Width;
                            }
                            break;
                        case ImageLayout.Zoom:
                            if ((Single)(BackgroundImage.Width / Width) < (Single)(BackgroundImage.Height / Height))
                            {
                                ggr.DrawImage(BackgroundImage, 0, 0, Height, Height);
                            }
                            else
                            {
                                ggr.DrawImage(BackgroundImage, 0, 0, Width, Width);
                            }
                            break;
                    }
                }

                ggr.SmoothingMode = SmoothingMode.HighQuality;
                ggr.PixelOffsetMode = PixelOffsetMode.HighQuality;

                GraphicsPath gp = new GraphicsPath();
                Single rangeStartAngle;
                Single rangeSweepAngle;
                for (Int32 counter= 0; counter<NUMOFRANGES; counter++)
                {
                    if (m_RangeEndValue[counter] > m_RangeStartValue[counter]
                    && m_RangeEnabled[counter])
                    {
                        rangeStartAngle = m_BaseArcStart + (m_RangeStartValue[counter] - m_MinValue) * m_BaseArcSweep / (m_MaxValue - m_MinValue);
                        rangeSweepAngle = (m_RangeEndValue[counter] - m_RangeStartValue[counter]) * m_BaseArcSweep / (m_MaxValue - m_MinValue);
                        gp.Reset();
                        gp.AddPie(new Rectangle(m_Center.X - m_RangeOuterRadius[counter], m_Center.Y - m_RangeOuterRadius[counter], 2 * m_RangeOuterRadius[counter], 2 * m_RangeOuterRadius[counter]), rangeStartAngle, rangeSweepAngle);
                        gp.Reverse();
                        gp.AddPie(new Rectangle(m_Center.X - m_RangeInnerRadius[counter], m_Center.Y - m_RangeInnerRadius[counter], 2 * m_RangeInnerRadius[counter], 2 * m_RangeInnerRadius[counter]), rangeStartAngle, rangeSweepAngle);
                        gp.Reverse();
                        ggr.SetClip(gp);
                        ggr.FillPie(new SolidBrush(m_RangeColor[counter]), new Rectangle(m_Center.X - m_RangeOuterRadius[counter], m_Center.Y - m_RangeOuterRadius[counter], 2 * m_RangeOuterRadius[counter], 2 * m_RangeOuterRadius[counter]), rangeStartAngle, rangeSweepAngle);
                    }
                }

                ggr.SetClip(ClientRectangle);
                if (m_BaseArcRadius > 0)
                {
                    ggr.DrawArc(new Pen(m_BaseArcColor, m_BaseArcWidth), new Rectangle(m_Center.X - m_BaseArcRadius, m_Center.Y - m_BaseArcRadius, 2 * m_BaseArcRadius, 2 * m_BaseArcRadius), m_BaseArcStart, m_BaseArcSweep);
                }

                String valueText = "";
                SizeF boundingBox;
                Single  countValue= 0;
                Int32 counter1  = 0;
                while (countValue <= (m_MaxValue - m_MinValue))
                {
                    valueText = (m_MinValue + countValue).ToString(m_ScaleNumbersFormat);
                    ggr.ResetTransform();
                    boundingBox = ggr.MeasureString(valueText, Font, -1, StringFormat.GenericTypographic);

                    gp.Reset();
                    gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMajorOuterRadius, m_Center.Y - m_ScaleLinesMajorOuterRadius, 2 * m_ScaleLinesMajorOuterRadius, 2 * m_ScaleLinesMajorOuterRadius));
                    gp.Reverse();
                    gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMajorInnerRadius, m_Center.Y - m_ScaleLinesMajorInnerRadius, 2 * m_ScaleLinesMajorInnerRadius, 2 * m_ScaleLinesMajorInnerRadius));
                    gp.Reverse();
                    ggr.SetClip(gp);

                    ggr.DrawLine(new Pen(m_ScaleLinesMajorColor, m_ScaleLinesMajorWidth),
                    (Single)(Center.X),
                    (Single)(Center.Y),
                    (Single)(Center.X + 2 * m_ScaleLinesMajorOuterRadius * Math.Cos((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue)) * Math.PI / 180.0)),
                    (Single)(Center.Y + 2 * m_ScaleLinesMajorOuterRadius * Math.Sin((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue)) * Math.PI / 180.0)));

                    gp.Reset();
                    gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMinorOuterRadius, m_Center.Y - m_ScaleLinesMinorOuterRadius, 2 * m_ScaleLinesMinorOuterRadius, 2 * m_ScaleLinesMinorOuterRadius));
                    gp.Reverse();
                    gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMinorInnerRadius, m_Center.Y - m_ScaleLinesMinorInnerRadius, 2 * m_ScaleLinesMinorInnerRadius, 2 * m_ScaleLinesMinorInnerRadius));
                    gp.Reverse();
                    ggr.SetClip(gp);

                    if (countValue < (m_MaxValue - m_MinValue))
                    {
                        for (Int32 counter2= 1; counter2<=m_ScaleLinesMinorNumOf; counter2++)
                        {
                            if (((m_ScaleLinesMinorNumOf % 2) == 1) && ((Int32)(m_ScaleLinesMinorNumOf / 2) + 1 == counter2))
                            {
                                gp.Reset();
                                gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesInterOuterRadius, m_Center.Y - m_ScaleLinesInterOuterRadius, 2 * m_ScaleLinesInterOuterRadius, 2 * m_ScaleLinesInterOuterRadius));
                                gp.Reverse();
                                gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesInterInnerRadius, m_Center.Y - m_ScaleLinesInterInnerRadius, 2 * m_ScaleLinesInterInnerRadius, 2 * m_ScaleLinesInterInnerRadius));
                                gp.Reverse();
                                ggr.SetClip(gp);

                                ggr.DrawLine(new Pen(m_ScaleLinesInterColor, m_ScaleLinesInterWidth),
                                (Single)(Center.X),
                                (Single)(Center.Y),
                                (Single)(Center.X + 2 * m_ScaleLinesInterOuterRadius * Math.Cos((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue) + counter2 * m_BaseArcSweep / (((Single)((m_MaxValue - m_MinValue) / m_ScaleLinesMajorStepValue)) * (m_ScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)),
                                (Single)(Center.Y + 2 * m_ScaleLinesInterOuterRadius * Math.Sin((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue) + counter2 * m_BaseArcSweep / (((Single)((m_MaxValue - m_MinValue) / m_ScaleLinesMajorStepValue)) * (m_ScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)));

                                gp.Reset();
                                gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMinorOuterRadius, m_Center.Y - m_ScaleLinesMinorOuterRadius, 2 * m_ScaleLinesMinorOuterRadius, 2 * m_ScaleLinesMinorOuterRadius));
                                gp.Reverse();
                                gp.AddEllipse(new Rectangle(m_Center.X - m_ScaleLinesMinorInnerRadius, m_Center.Y - m_ScaleLinesMinorInnerRadius, 2 * m_ScaleLinesMinorInnerRadius, 2 * m_ScaleLinesMinorInnerRadius));
                                gp.Reverse();
                                ggr.SetClip(gp);
                            }
                            else
                            {
                                ggr.DrawLine(new Pen(m_ScaleLinesMinorColor, m_ScaleLinesMinorWidth),
                                (Single)(Center.X),
                                (Single)(Center.Y),
                                (Single)(Center.X + 2 * m_ScaleLinesMinorOuterRadius * Math.Cos((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue) + counter2 * m_BaseArcSweep / (((Single)((m_MaxValue - m_MinValue) / m_ScaleLinesMajorStepValue)) * (m_ScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)),
                                (Single)(Center.Y + 2 * m_ScaleLinesMinorOuterRadius * Math.Sin((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue) + counter2 * m_BaseArcSweep / (((Single)((m_MaxValue - m_MinValue) / m_ScaleLinesMajorStepValue)) * (m_ScaleLinesMinorNumOf + 1))) * Math.PI / 180.0)));
                            }
                        }
                    }

                    ggr.SetClip(ClientRectangle);

                    if (m_ScaleNumbersRotation != 0)
                    {
                        ggr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        ggr.RotateTransform(90.0F + m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue));
                    }

                    ggr.TranslateTransform((Single)(Center.X + m_ScaleNumbersRadius * Math.Cos((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue)) * Math.PI / 180.0f)),
                                           (Single)(Center.Y + m_ScaleNumbersRadius * Math.Sin((m_BaseArcStart + countValue * m_BaseArcSweep / (m_MaxValue - m_MinValue)) * Math.PI / 180.0f)),
                                           System.Drawing.Drawing2D.MatrixOrder.Append);

                    if (counter1 >= ScaleNumbersStartScaleLine - 1)
                    {
                        ggr.DrawString(valueText, Font, new SolidBrush(m_ScaleNumbersColor), -boundingBox.Width / 2, -fontBoundY1 - (fontBoundY2 - fontBoundY1 + 1) / 2, StringFormat.GenericTypographic);
                    }

                    countValue += m_ScaleLinesMajorStepValue;
                    counter1 ++;
                }

                ggr.ResetTransform();
                ggr.SetClip(ClientRectangle);

                if (m_ScaleNumbersRotation != 0)
                {
                   ggr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                }

                for (Int32 counter= 0; counter<NUMOFCAPS; counter++)
                {
                    if (m_CapText[counter] != "")
                    {
                       ggr.DrawString(m_CapText[counter], Font, new SolidBrush(m_CapColor[counter]), m_CapPosition[counter].X, m_CapPosition[counter].Y, StringFormat.GenericTypographic);
                    }
                }
            }

            pe.Graphics.DrawImageUnscaled(gaugeBitmap, 0, 0);
            pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            pe.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

            Single brushAngle = (Int32)(m_BaseArcStart + (m_value - m_MinValue) * m_BaseArcSweep / (m_MaxValue - m_MinValue)) % 360;
            Double needleAngle= brushAngle * Math.PI / 180;

            switch(m_NeedleType)
            {
                case 0:
                    PointF[] points=new PointF[3];
                    Brush brush1 = Brushes.White;
                    Brush brush2 = Brushes.White;
                    Brush brush3 = Brushes.White;
                    Brush brush4 = Brushes.White;

                    Brush brushBucket = Brushes.White;
                    Int32 subcol = (Int32)(((brushAngle + 225) % 180) * 100 / 180);
                    Int32 subcol2 = (Int32)(((brushAngle + 135) % 180) * 100 / 180);

                    pe.Graphics.FillEllipse(new SolidBrush(m_NeedleColor2), Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                    switch(m_NeedleColor1)
                    {
                        case NeedleColorEnum.Gray:
                            brush1 = new SolidBrush(Color.FromArgb(80 + subcol, 80 + subcol, 80 + subcol));
                            brush2 = new SolidBrush(Color.FromArgb(180 - subcol, 180 - subcol, 180 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(80 + subcol2, 80 + subcol2, 80 + subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(180 - subcol2, 180 - subcol2, 180 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Gray, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Red:
                            brush1 = new SolidBrush(Color.FromArgb(145 + subcol, subcol, subcol));
                            brush2 = new SolidBrush(Color.FromArgb(245 - subcol, 100 - subcol, 100 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(145 + subcol2, subcol2, subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(245 - subcol2, 100 - subcol2, 100 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Red, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Green:
                            brush1 = new SolidBrush(Color.FromArgb(subcol, 145 + subcol, subcol));
                            brush2 = new SolidBrush(Color.FromArgb(100 - subcol, 245 - subcol, 100 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(subcol2, 145 + subcol2, subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(100 - subcol2, 245 - subcol2, 100 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Green, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Blue:
                            brush1 = new SolidBrush(Color.FromArgb(subcol, subcol, 145 + subcol));
                            brush2 = new SolidBrush(Color.FromArgb(100 - subcol, 100 - subcol, 245 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(subcol2, subcol2, 145 + subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(100 - subcol2, 100 - subcol2, 245 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Blue, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Magenta:
                            brush1 = new SolidBrush(Color.FromArgb(subcol, 145 + subcol, 145 + subcol));
                            brush2 = new SolidBrush(Color.FromArgb(100 - subcol, 245 - subcol, 245 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(subcol2, 145 + subcol2, 145 + subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(100 - subcol2, 245 - subcol2, 245 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Magenta, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Violet:
                            brush1 = new SolidBrush(Color.FromArgb(145 + subcol, subcol, 145 + subcol));
                            brush2 = new SolidBrush(Color.FromArgb(245 - subcol, 100 - subcol, 245 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(145 + subcol2, subcol2, 145 + subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(245 - subcol2, 100 - subcol2, 245 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Violet, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                        case NeedleColorEnum.Yellow:
                            brush1 = new SolidBrush(Color.FromArgb(145 + subcol, 145 + subcol, subcol));
                            brush2 = new SolidBrush(Color.FromArgb(245 - subcol, 245 - subcol, 100 - subcol));
                            brush3 = new SolidBrush(Color.FromArgb(145 + subcol2, 145 + subcol2, subcol2));
                            brush4 = new SolidBrush(Color.FromArgb(245 - subcol2, 245 - subcol2, 100 - subcol2));
                            pe.Graphics.DrawEllipse(Pens.Violet, Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);
                            break;
                    }

                    if (Math.Floor((Single)(((brushAngle + 225) % 360) / 180.0)) == 0)
                    {
                        brushBucket = brush1;
                        brush1 = brush2;
                        brush2 = brushBucket;
                    }

                    if (Math.Floor((Single)(((brushAngle + 135) % 360) / 180.0)) == 0)
                    {
                        brush4 = brush3;
                    }

                    points[0].X = (Single)(Center.X + m_NeedleRadius * Math.Cos(needleAngle));
                    points[0].Y =(Single)( Center.Y + m_NeedleRadius * Math.Sin(needleAngle));
                    points[1].X = (Single)(Center.X - m_NeedleRadius / 20 * Math.Cos(needleAngle));
                    points[1].Y = (Single)(Center.Y - m_NeedleRadius / 20 * Math.Sin(needleAngle));
                    points[2].X = (Single)(Center.X - m_NeedleRadius / 5 * Math.Cos(needleAngle) + m_NeedleWidth * 2 * Math.Cos(needleAngle + Math.PI / 2));
                    points[2].Y = (Single)(Center.Y - m_NeedleRadius / 5 * Math.Sin(needleAngle) + m_NeedleWidth * 2 * Math.Sin(needleAngle + Math.PI / 2));
                    pe.Graphics.FillPolygon(brush1, points);

                    points[2].X = (Single)(Center.X - m_NeedleRadius / 5 * Math.Cos(needleAngle) + m_NeedleWidth * 2 * Math.Cos(needleAngle - Math.PI / 2));
                    points[2].Y = (Single)(Center.Y - m_NeedleRadius / 5 * Math.Sin(needleAngle) + m_NeedleWidth * 2 * Math.Sin(needleAngle - Math.PI / 2));
                    pe.Graphics.FillPolygon(brush2, points);

                    points[0].X = (Single)(Center.X - (m_NeedleRadius / 20 - 1) * Math.Cos(needleAngle));
                    points[0].Y = (Single)(Center.Y - (m_NeedleRadius / 20 - 1) * Math.Sin(needleAngle));
                    points[1].X = (Single)(Center.X - m_NeedleRadius / 5 * Math.Cos(needleAngle) + m_NeedleWidth * 2 * Math.Cos(needleAngle + Math.PI / 2));
                    points[1].Y = (Single)(Center.Y - m_NeedleRadius / 5 * Math.Sin(needleAngle) + m_NeedleWidth * 2 * Math.Sin(needleAngle + Math.PI / 2));
                    points[2].X = (Single)(Center.X - m_NeedleRadius / 5 * Math.Cos(needleAngle) + m_NeedleWidth * 2 * Math.Cos(needleAngle - Math.PI / 2));
                    points[2].Y = (Single)(Center.Y - m_NeedleRadius / 5 * Math.Sin(needleAngle) + m_NeedleWidth * 2 * Math.Sin(needleAngle - Math.PI / 2));
                    pe.Graphics.FillPolygon(brush4, points);

                    points[0].X = (Single)(Center.X - m_NeedleRadius / 20 * Math.Cos(needleAngle));
                    points[0].Y = (Single)(Center.Y - m_NeedleRadius / 20 * Math.Sin(needleAngle));
                    points[1].X = (Single)(Center.X + m_NeedleRadius * Math.Cos(needleAngle));
                    points[1].Y = (Single)(Center.Y + m_NeedleRadius * Math.Sin(needleAngle));

                    pe.Graphics.DrawLine(new Pen(m_NeedleColor2), Center.X, Center.Y, points[0].X, points[0].Y);
                    pe.Graphics.DrawLine(new Pen(m_NeedleColor2), Center.X, Center.Y, points[1].X, points[1].Y);
                    break;
                case 1:
                    Point startPoint=new Point((Int32)(Center.X - m_NeedleRadius / 8 * Math.Cos(needleAngle)),
                                               (Int32)(Center.Y - m_NeedleRadius / 8 * Math.Sin(needleAngle)));
                    Point endPoint=new Point((Int32)(Center.X + m_NeedleRadius * Math.Cos(needleAngle)),
                                             (Int32)(Center.Y + m_NeedleRadius * Math.Sin(needleAngle)));

                    pe.Graphics.FillEllipse(new SolidBrush(m_NeedleColor2), Center.X - m_NeedleWidth * 3, Center.Y - m_NeedleWidth * 3, m_NeedleWidth * 6, m_NeedleWidth * 6);

                    switch(m_NeedleColor1)
                    {
                        case NeedleColorEnum.Gray:
                            pe.Graphics.DrawLine(new Pen(Color.DarkGray, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.DarkGray, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Red:
                            pe.Graphics.DrawLine(new Pen(Color.Red, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Red, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Green:
                            pe.Graphics.DrawLine(new Pen(Color.Green, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Green, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Blue:
                            pe.Graphics.DrawLine(new Pen(Color.Blue, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Blue, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Magenta:
                            pe.Graphics.DrawLine(new Pen(Color.Magenta, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Magenta, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Violet:
                            pe.Graphics.DrawLine(new Pen(Color.Violet, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Violet, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                        case NeedleColorEnum.Yellow:
                            pe.Graphics.DrawLine(new Pen(Color.Yellow, m_NeedleWidth), Center.X, Center.Y, endPoint.X, endPoint.Y);
                            pe.Graphics.DrawLine(new Pen(Color.Yellow, m_NeedleWidth), Center.X, Center.Y, startPoint.X, startPoint.Y);
                            break;
                    }
                    break;
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();
            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel = zoomLevel;
            _mapCenterPt.X = drawBoundary.GetCenterX();
            _mapCenterPt.Y = drawBoundary.GetCenterY();
            bool pointFound = false;
            Point[] plinePoints=null;
            switch (mapObject.GetMapObjectType())
            {
                case MapObject.NONE:
                    break;
                case MapObject.POINT:
                    {
                        MapPoint mapPoint = (MapPoint)mapObject;
                        DrawPoint(mapPoint);
                        drawPt.X = mapPoint.Point.X;
                        drawPt.Y = mapPoint.Point.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIPOINT:
                    {
                        MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            MapPoint mapPoint = new MapPoint
                            {
                                SymbolType = mapMultiPoint.SymbolType,
                                Point = new GeoLatLng(mapMultiPoint.Points[i])
                            };
                            DrawPoint(mapPoint);
                        }
                        for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                        {
                            if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                            {
                                drawPt.X = mapMultiPoint.Points[i].X;
                                drawPt.Y = mapMultiPoint.Points[i].Y;
                                pointFound = true;
                                break;
                            }
                        }

                    }
                    break;
                case MapObject.PLINE:
                    {
                        MapPline mapPline = (MapPline)mapObject;
                        plinePoints=DrawPline(mapPline.PenStyle, mapPline.Pline);
                        for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                        {
                            if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                            {
                                drawPt.X = mapPline.Pline.GetVertex(i).X;
                                drawPt.Y = mapPline.Pline.GetVertex(i).Y;
                                pointFound = true;
                                break;
                            }
                        }
                    }
                    break;
                case MapObject.MULTIPLINE:
                    {
                        MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                        for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                        {
                            DrawPline(mapMultiPline.PenStyle,
                                    mapMultiPline.Plines[i]);
                            for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                            {
                                if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                                {
                                    drawPt.X = mapMultiPline.Plines[i].GetVertex(j).X;
                                    drawPt.Y = mapMultiPline.Plines[i].GetVertex(j).Y;
                                    pointFound = true;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case MapObject.REGION:
                    {
                        MapRegion mapRegion = (MapRegion)mapObject;
                        DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                                mapRegion.Region);
                        drawPt.X = mapRegion.CenterPt.X;
                        drawPt.Y = mapRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.MULTIREGION:
                    {
                        MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                        for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                        {
                            DrawRegion(mapMultiRegion.PenStyle,
                                    mapMultiRegion.BrushStyle,
                                    mapMultiRegion.Regions[i]);

                        }
                        drawPt.X = mapMultiRegion.CenterPt.X;
                        drawPt.Y = mapMultiRegion.CenterPt.Y;
                        pointFound = true;
                    }
                    break;
                case MapObject.COLLECTION:
                    {
                        MapCollection mapCollection = (MapCollection)mapObject;
                        if (mapCollection.MultiRegion != null)
                        {
                            MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                            for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                            {
                                DrawRegion(mapMultiRegion.PenStyle,
                                        mapMultiRegion.BrushStyle,
                                        mapMultiRegion.Regions[i]);
                            }
                        }
                        if (mapCollection.MultiPline != null)
                        {
                            MapMultiPline mapMultiPline = mapCollection.MultiPline;
                            for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                            {
                                DrawPline(mapMultiPline.PenStyle,
                                        mapMultiPline.Plines[i]);
                            }
                        }
                        if (mapCollection.MultiPoint != null)
                        {
                            MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                            for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                            {
                                MapPoint mapPoint = new MapPoint
                                {
                                    SymbolType = mapMultiPoint.SymbolType,
                                    Point = new GeoLatLng(mapMultiPoint.Points[i])
                                };
                                DrawPoint(mapPoint);
                            }
                        }
                        pointFound = true;
                        drawPt.X = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                        drawPt.Y = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;

                    }
                    break;
                case MapObject.TEXT:
                    {
                        MapText mapText = (MapText)mapObject;
                        drawPt.X = mapText.Point.X;
                        drawPt.Y = mapText.Point.Y;
                        pointFound = true;
                    }
                    break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length==0) && pointFound)
            {
                MapText mapName = new MapText { Font = _font };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X = screenPt.X;
                mapName.Point.Y = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {

                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width = sizeF.Width;

                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if(mapObject.GetMapObjectType()==MapObject.PLINE)
                {
                    if(plinePoints!=null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF []rectangleF;
                        double angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                                new SolidBrush(
                                                                                    Color.FromArgb(_fontColor)),
                                                                                TextPathAlign.Center,
                                                                                TextPathPosition.CenterPath, 100, rotateAngle,
                                                                                graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles = rectangleF;

                        if (rectangleF.Length == mapName.TextString.Length)
                        {

                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}

                           AddMapName(textPosInfo);
                        }

                    }
                }else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles = new[]{new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                           (float)textPosInfo._mapText.Bounds.Width,
                                                           (float)textPosInfo._mapText.Bounds.Height)};
                    AddMapName(textPosInfo);
                }

            }
        }