Exemplo n.º 1
0
        /// <summary>
        /// Given the points on this line decoration, this will cycle through and handle
        /// the drawing as dictated by this decoration.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="path"></param>
        /// <param name="scaleWidth">The double scale width for controling markers</param>
        public void Draw(Graphics g, GraphicsPath path, double scaleWidth)
        {
            if (NumSymbols == 0) return;
            GraphicsPathIterator myIterator = new GraphicsPathIterator(path);
            myIterator.Rewind();
            int start, end;
            bool isClosed;
            Size2D symbolSize = _symbol.GetSize();
            Bitmap symbol = new Bitmap((int)symbolSize.Width, (int)symbolSize.Height);
            Graphics sg = Graphics.FromImage(symbol);
            _symbol.Draw(sg, new Rectangle(0, 0, (int)symbolSize.Width, (int)symbolSize.Height));
            sg.Dispose();

            Matrix oldMat = g.Transform;
            PointF[] points;
            if (path.PointCount == 0) return;
            try
            {
                points = path.PathPoints;
            }
            catch
            {
                return;
            }


            while (myIterator.NextSubpath(out start, out end, out isClosed) > 0)
            {
                if (NumSymbols == 1) //single decoration spot
                {
                    if (_percentualPosition == 0) // at start of the line
                    {
                        DrawImage(g, points[start], points[start + 1], points[start], (FlipFirst ^ FlipAll), symbol, oldMat);
                    }
                    else if (_percentualPosition == 100) // at end of the line
                    {
                        DrawImage(g, points[end - 1], points[end], points[end], (FlipFirst ^ FlipAll), symbol, oldMat);
                    }
                    else  //somewhere in between start and end
                    {
                        double totalLength = GetLength(points, start, end);
                        double span = totalLength * (double)_percentualPosition / 100;
                        List<DecorationSpot> spot = GetPosition(points, span, start, end);
                        if (spot.Count > 1)
                            DrawImage(g, spot[1].Before, spot[1].After, spot[1].Position, (FlipFirst ^ FlipAll), symbol, oldMat);
                    }
                }
                else // more than one decoration spot
                {
                    double totalLength = GetLength(points, start, end);
                    double span = Math.Round(totalLength / (NumSymbols - 1), 4);
                    List<DecorationSpot> spots = GetPosition(points, span, start, end);
                    spots.Add(new DecorationSpot(points[end - 1], points[end], points[end])); //add the missing end point
                    for (int i = 0; i < spots.Count; i++)
                        DrawImage(g, spots[i].Before, spots[i].After, spots[i].Position, i == 0 ? (FlipFirst ^ FlipAll) : FlipAll, symbol, oldMat);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void CopyData() 
		{
            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.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();
			PointF [] actualPoints = new PointF [10];
			byte [] actualTypes = new byte [10];
			pathIterator.CopyData (ref actualPoints, ref actualTypes, 0, 9);

			PointF [] expectedPoints = new PointF [] {	new PointF(100f, 100f), 
														new PointF(400f, 100f), 
														new PointF(400f, 200f), 
														new PointF(10f, 100f), 
														new PointF(10f, 20f), 
														new PointF(310f, 20f), 
														new PointF(310f, 420f), 
														new PointF(10f, 420f), 
														new PointF(400f, 400f), 
														new PointF(400f, 10f)};
			
			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.Line, 
													(byte) (PathPointType.Line | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}	
        }
Exemplo n.º 3
0
        public virtual void Rewind() 
		{
            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.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int i;
			int j;
			iterator.NextMarker (out i, out j);
			iterator.NextMarker (out i, out j);

			iterator.Rewind ();
			iterator.NextMarker (out i, out j);

			Assert.AreEqual (0, i);
			Assert.AreEqual (3, j);
        }
Exemplo n.º 4
0
        public void PathIterator7(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up primitives to add to myPath.
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,

            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing all of the path's

            // points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the values of all the path points and types to the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator for myPath.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);

            // Rewind the iterator.
            myPathIterator.Rewind();

            // Create the GraphicsPath section.
            GraphicsPath myPathSection = new GraphicsPath();

            // Iterate to the 3rd subpath and list the number of points therein

            // to the screen.
            int subpathPoints;
            bool IsClosed2;

            // Iterate to the third subpath.
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);

            // Write the number of subpath points to the screen.
            g.DrawString("Subpath: 3"  +
                                  "   Num Points: " +
                                  subpathPoints.ToString(),
                                  myFont,
                                  myBrush,
                                  200,
                                  20);
        }
Exemplo n.º 5
0
        public void PathIterator5(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up primitives to add to myPath.
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,
            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing all the values of the path's
            // points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the values for all of path points and types to
            // the left side of the screen.
            for(i=0; i < myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),  myFont, myBrush,
                                      20, j);

                j+=20;

            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);

            // Rewind the iterator.
            myPathIterator.Rewind();

            // Create a GraphicsPath to receive a section of myPath.
            GraphicsPath myPathSection = new GraphicsPath();

            // Retrieve and list the number of points contained in

            // the first marker to the right side of the screen.
            int markerPoints;
            markerPoints = myPathIterator.NextMarker(myPathSection);
            g.DrawString("Marker: 1" + "  Num Points: " +
                                  markerPoints.ToString(),  myFont, myBrush, 200, 20);
        }
Exemplo n.º 6
0
        public void PathIterator3(Graphics g)
        {
            // Create the GraphicsPath.
            GraphicsPath myPath = new GraphicsPath();

            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, and an ellipse.
            myPath.AddLines(myPoints);
            myPath.AddRectangle(myRect);
            myPath.AddEllipse(220, 220, 100, 100);

            // List all of the path points to the screen.
            ListPathPoints(g, myPath, null, 20, 1);

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);

            // Rewind the Iterator.
            myPathIterator.Rewind();

            // Iterate the subpaths and types, and list the results to

            // the screen.
            int i, j = 20;
            int mySubPaths, subPathStartIndex, subPathEndIndex;
            Boolean IsClosed;
            byte subPathPointType;
            int pointTypeStartIndex,  pointTypeEndIndex, numPointsFound;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);
            j = 20;
            for(i = 0;i < 3; i++)
            {
                mySubPaths = myPathIterator.NextSubpath(
                    out subPathStartIndex,
                    out subPathEndIndex,
                    out IsClosed);
                numPointsFound = myPathIterator.NextPathType(
                    out subPathPointType,
                    out pointTypeStartIndex,
                    out pointTypeEndIndex);
                g.DrawString(
                    "SubPath: " + i +
                    "  Points Found: " + numPointsFound.ToString() +
                    "  Type of Points: " + subPathPointType.ToString(),
                    myFont,
                    myBrush,
                    200,
                    j);
                j+=20;
            }

            // List the total number of path points to the screen.
            ListPathPoints(g, myPath, myPathIterator, 200, 2);
        }
Exemplo n.º 7
0
        public void PathIterator2(Graphics g)
        {
            GraphicsPath myPath = new GraphicsPath();
            Point[] myPoints =
            {
                new Point(20, 20),
                new Point(120, 120),
                new Point(20, 120),
                new Point(20, 20)
            };
            Rectangle myRect = new Rectangle(120, 120, 100, 100);
            myPath.AddLines(myPoints);
            myPath.AddRectangle(myRect);
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path, and arrays of
            // the  points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing the array of points on the left
            // side of the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the set of points and types and types to the left side
            // of the screen.
            g.DrawString("Original Data",
                                  myFont,
                                  myBrush,
                                  20,
                                  j);
            j += 20;
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator for myPath.
            GraphicsPathIterator myPathIterator =
                new GraphicsPathIterator(myPath);
            myPathIterator.Rewind();
            PointF[] points = new PointF[myPathIterator.Count];
            byte[] types = new byte[myPathIterator.Count];
            int numPoints = myPathIterator.Enumerate(ref points, ref types);

            // Draw the set of copied points and types to the screen.
            j = 20;
            g.DrawString("Copied Data",
                                  myFont,
                                  myBrush,
                                  200,
                                  j);
            j += 20;
            for(i=0; i<points.Length; i++)
            {
                g.DrawString("Point: " + i +
                                      ", " + "Value: " + points[i].ToString() + ", " +
                                      "Type: " + types[i].ToString(),
                                      myFont,
                                      myBrush,
                                      200,
                                      j);
                j+=20;
            }
        }
Exemplo n.º 8
0
        public void PathIterator1(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath ();

            // Set up a points array.
            Point[] myPoints = {
                new Point(20, 20),
                new Point(120, 120),
                new Point(20, 120),
                new Point(20, 20)
            };

            // Create a rectangle.
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add the points, rectangle, and an ellipse to the path.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path, and arrays of
            // the  points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing the array of points on the left
            // side of the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the set of points and types and types to the left side
            // of the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator for myPath and rewind it.
            GraphicsPathIterator myPathIterator =
                new GraphicsPathIterator(myPath);
            myPathIterator.Rewind();

            // Set up the arrays to receive the copied data.
            PointF[] points = new PointF[myPathIterator.Count];
            byte[] types = new byte[myPathIterator.Count];
            int myStartIndex;
            int myEndIndex;

            // Increment the starting index to the second marker in the
            // path.
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);

            // Copy all the points and types from the starting index to the
            // ending index to the points array and the types array
            // respectively.
            int numPointsCopied = myPathIterator.CopyData(
                ref points,
                ref types,
                myStartIndex,
                myEndIndex);

            // List the copied points to the right side of the screen.
            j = 20;
            int copiedStartIndex = 0;
            for(i=0; i<numPointsCopied; i++)
            {
                copiedStartIndex = myStartIndex + i;
                g.DrawString(
                    "Point: " + copiedStartIndex.ToString() +
                    ", Value: " + points[i].ToString() +
                    ", Type: " + types[i].ToString(),
                    myFont,
                    myBrush,
                    200,
                    j);
                j+=20;
            }
        }
Exemplo n.º 9
0
        private void PathIterator6(Graphics g)
        {
            // Create the GraphicsPath.
            GraphicsPath myPath = new GraphicsPath();
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,

            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for drawing the array

            // of points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // Draw the set of path points and types to the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);
            int myStartIndex;
            int myEndIndex;

            // Rewind the Iterator.
            myPathIterator.Rewind();

            // Draw the Markers and their start and end points

            // to the screen.
            j=20;
            for(i=0;i<3;i++)
            {
                myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
                g.DrawString("Marker " + i.ToString() +
                                      ":  Start: " + myStartIndex.ToString()+
                                      "  End: " + myEndIndex.ToString(),
                                      myFont,
                                      myBrush,
                                      200,
                                      j);
                j += 20;
            }

            // Draw the total number of points to the screen.
            j += 20;
            int myPathTotalPoints = myPathIterator.Count;
            g.DrawString("Total Points = " +
                                  myPathTotalPoints.ToString(),
                                  myFont,
                                  myBrush,
                                  200,
                                  j);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Given the points on this line decoration, this will cycle through and handle
        /// the drawing as dictated by this decoration.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="path"></param>
        /// <param name="scaleWidth">The double scale width for controling markers</param>
        public void Draw(Graphics g, GraphicsPath path, double scaleWidth)
        {
            if (NumSymbols == 0) return;
            GraphicsPathIterator myIterator = new GraphicsPathIterator(path);
            myIterator.Rewind();
            int start, end;
            bool isClosed;
            Size2D symbolSize = _symbol.GetSize();
            Bitmap symbol = new Bitmap((int)symbolSize.Width, (int)symbolSize.Height);
            Graphics sg = Graphics.FromImage(symbol);
            _symbol.Draw(sg, new Rectangle(0, 0, (int)symbolSize.Width, (int)symbolSize.Height));
            sg.Dispose();

            Matrix oldMat = g.Transform;
            PointF[] points;
            if (path.PointCount == 0) return;
            try
            {
                points = path.PathPoints;
            }
            catch
            {
                return;
            }
            PointF offset;

            int count = 0;
            while (myIterator.NextSubpath(out start, out end, out isClosed) > 0)
            {
                count = count + 1;
                // First marker
                PointF startPoint = points[start];
                PointF stopPoint = points[start + 1];
                float angle = 0F;
                if (_rotateWithLine) angle = GetAngle(startPoint, stopPoint);
                if (FlipFirst && !FlipAll) FlipAngle(ref angle);
                offset = GetOffset(startPoint, stopPoint);
                startPoint = new PointF(startPoint.X + offset.X, startPoint.Y + offset.Y);
                Matrix rotated = g.Transform;
                rotated.RotateAt(angle, startPoint);
                g.Transform = rotated;
                DrawImage(g, startPoint, symbol);
                g.Transform = oldMat;

                // Second marker
                if (NumSymbols > 1)
                {
                    angle = 0F;
                    if (_rotateWithLine) angle = GetAngle(points[end - 1], points[end]);
                    if (FlipAll) FlipAngle(ref angle);
                    offset = GetOffset(points[end - 1], points[end]);
                    PointF endPoint = new PointF(points[end].X + offset.X, points[end].Y + offset.Y);
                    rotated = g.Transform;
                    rotated.RotateAt(angle, endPoint);
                    g.Transform = rotated;
                    DrawImage(g, endPoint, symbol);
                    g.Transform = oldMat;
                }
                if (NumSymbols > 2)
                {
                    double totalLength = GetLength(points, start, end);
                    double span = totalLength / (NumSymbols - 1);
                    for (int i = 1; i < NumSymbols - 1; i++)
                    {
                        DecorationSpot spot = GetPosition(points, span * i, start, end);
                        angle = 0F;
                        if (_rotateWithLine) angle = GetAngle(spot.Before, spot.After);
                        offset = GetOffset(spot.Before, spot.After);
                        PointF location = new PointF(spot.Position.X + offset.X, spot.Position.Y + offset.Y);
                        if (FlipAll) FlipAngle(ref angle);
                        rotated = g.Transform;
                        rotated.RotateAt(angle, location);
                        g.Transform = rotated;
                        DrawImage(g, location, symbol);
                        g.Transform = oldMat;
                    }
                }
            }
        }
Exemplo n.º 11
0
		public void Clone()
		{
			path = new GraphicsPath ();
			path.AddEllipse (0, 0, 100, 200);
			path.SetMarkers ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			Rectangle rect = new Rectangle (200, 0, 100, 200);
			path.AddRectangle (rect);
			path.SetMarkers ();
			path.AddLine (new Point (250, 200), new Point (250, 300));
			path.SetMarkers ();

			GraphicsPath cloned = (GraphicsPath) path.Clone ();

			Assert.AreEqual (path.PointCount, cloned.PointCount);

			for ( int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(path.PathPoints [i], cloned.PathPoints [i]);
				Assert.AreEqual (path.PathTypes [i], cloned.PathTypes [i]);
			}

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();

			GraphicsPathIterator clonedIterator = new GraphicsPathIterator(cloned);
			clonedIterator.Rewind ();

			for (int i=0; i < 4; i ++) {
				Assert.AreEqual (pathIterator.NextMarker (path), clonedIterator.NextMarker (cloned));
			}
			//t.AssertCompare ();
		}
Exemplo n.º 12
0
		public void ClearMarkers()
		{
			path = new GraphicsPath ();
			path.AddEllipse (0, 0, 100, 200);
			path.SetMarkers ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			Rectangle rect = new Rectangle (200, 0, 100, 200);
			path.AddRectangle (rect);
			path.SetMarkers ();
			path.AddLine (new Point (250, 200), new Point (250, 300));
			path.SetMarkers ();

			path.ClearMarkers();

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();
			int [] pointsNumber = new int [] {21, 0, 0, 0};
			for (int i=0; i < 4; i ++) {
				Assert.AreEqual (pointsNumber [i], pathIterator.NextMarker (path));
			}
			//t.AssertCompare ();
		}
Exemplo n.º 13
0
        /// <summary>
        /// This is used to get the image area at the specified point (if any)
        /// </summary>
        /// <returns>The image area index if the point is in an image area or negative one (-1) if it is not in
        /// any of the image areas.</returns>
		private int ImageAreaAtPoint(Point pt)
		{
            int idx;

            if(pt.X > this.ImageMapWidth || pt.Y > this.ImageMapHeight)
                return -1;

            // Set the image area paths if they need recalculating
            if(pathData.PointCount == 0)
                this.SetImageAreaPaths();

			using(GraphicsPath p = new GraphicsPath())
			    using(GraphicsPathIterator i = new GraphicsPathIterator(pathData))
                {
			        i.Rewind();

			        for(idx = 0; idx < i.SubpathCount; idx++)
			        {
				        i.NextMarker(p);

				        if(p.IsVisible(pt, gPanel) && this.Areas[idx].Enabled)
				            break;
			        }

                    return (idx < i.SubpathCount) ? idx : -1;
                }
		}