Ejemplo n.º 1
0
 public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
 {
     graphicsPath.CloseFigure();
 }
Ejemplo n.º 2
0
	/*******************************/
	/// <summary>
	/// Adds the X and Y coordinates to the current graphics path.
	/// </summary>
	/// <param name="graphPath"> The current Graphics path</param>
	/// <param name="xCoordinate">The x coordinate to be added</param>
	/// <param name="yCoordinate">The y coordinate to be added</param>
	public static void AddPointToGraphicsPath(System.Drawing.Drawing2D.GraphicsPath graphPath, int x, int y)
	{
		System.Drawing.PointF[] tempPointArray = new System.Drawing.PointF[graphPath.PointCount + 1];
		byte[] tempPointTypeArray = new byte[graphPath.PointCount + 1];

		if (graphPath.PointCount == 0)
		{
			tempPointArray[0] = new System.Drawing.PointF(x, y);		
			System.Drawing.Drawing2D.GraphicsPath tempGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(tempPointArray, new byte[]{(byte)System.Drawing.Drawing2D.PathPointType.Start});
			graphPath.AddPath(tempGraphicsPath, false);
		}
		else
		{
			graphPath.PathPoints.CopyTo(tempPointArray, 0);
			tempPointArray[graphPath.PointCount] = new System.Drawing.Point(x, y);
			
			graphPath.PathTypes.CopyTo(tempPointTypeArray, 0);
			tempPointTypeArray[graphPath.PointCount] = (byte) System.Drawing.Drawing2D.PathPointType.Line;

			System.Drawing.Drawing2D.GraphicsPath tempGraphics = new System.Drawing.Drawing2D.GraphicsPath(tempPointArray, tempPointTypeArray);
			graphPath.Reset();
			graphPath.AddPath(tempGraphics, false);
			graphPath.CloseFigure();
		}
	}
Ejemplo n.º 3
0
		/// <summary>
		/// Resets the specified GraphicsPath object and adds an arc to it with the speficied values.
		/// </summary>
		/// <param name="arc2DPath">The GraphicsPath object to reset.</param>
		/// <param name="x">The x coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
		/// <param name="y">The y coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
		/// <param name="height">The height of the rectangular region that defines the ellipse from which the arc is drawn.</param>
		/// <param name="width">The width of the rectangular region that defines the ellipse from which the arc is drawn.</param>
		/// <param name="start">The starting angle of the arc measured in degrees.</param>
		/// <param name="extent">The angular extent of the arc measured in degrees.</param>
		/// <param name="arcType">The closure type for the arc.</param>
		public static void SetArc(System.Drawing.Drawing2D.GraphicsPath arc2DPath, float x, float y, float height, float width, float start, float extent, int arcType)
		{
			arc2DPath.Reset();
			switch (arcType)
			{
				case OPEN:
					arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
					break;
				case CLOSED:
					arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
					arc2DPath.CloseFigure();
					break;
				case PIE:
					arc2DPath.AddPie(x, y, height, width, start * -1, extent * -1);
					break;
				default:
					break;
			}
		}
Ejemplo n.º 4
0
        public static void PolyDraw(
            System.Drawing.Drawing2D.GraphicsPath pPath,
            POINT[] lppt,
            byte[] lpbTypes,
            int cCount)
        {
            int nIndex;
            POINT pptLastMoveTo = new POINT();
            POINT pptPrev = new POINT();

            bool bLastMoveToNull = true;

            // for each of the points we have...
            for (nIndex = 0; nIndex < cCount; nIndex++)
            {
            switch (lpbTypes[nIndex])
            {
                case PT_MOVETO:
                    if (bLastMoveToNull == false && nIndex > 0)
                    {
                        pPath.CloseFigure();
                    }
                    pptLastMoveTo = lppt[nIndex];
                    bLastMoveToNull = false;
                    pptPrev = lppt[nIndex];
                    break;

                case PT_LINETO | PT_CLOSEFIGURE:
                    pPath.AddLine(pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y);
                    pptPrev = lppt[nIndex];
                    if (bLastMoveToNull == false)
                    {
                        pPath.CloseFigure();
                        pptPrev = pptLastMoveTo;
                    }
                    bLastMoveToNull = true;
                    break;

                case PT_LINETO:
                    pPath.AddLine(pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y);
                    pptPrev = lppt[nIndex];
                    break;

                case PT_BEZIERTO | PT_CLOSEFIGURE:
                    //ASSERT(nIndex + 2 <= cCount);
                    pPath.AddBezier(
                        pptPrev.X, pptPrev.Y,
                        lppt[nIndex].X, lppt[nIndex].Y,
                        lppt[nIndex + 1].X, lppt[nIndex + 1].Y,
                        lppt[nIndex + 2].X, lppt[nIndex + 2].Y);
                    nIndex += 2;
                    pptPrev = lppt[nIndex];
                    if (bLastMoveToNull == false)
                    {
                        pPath.CloseFigure();
                        pptPrev = pptLastMoveTo;
                    }
                    bLastMoveToNull = true;
                    break;

                case PT_BEZIERTO:
                    //ASSERT(nIndex + 2 <= cCount);
                    pPath.AddBezier(
                        pptPrev.X, pptPrev.Y,
                        lppt[nIndex].X, lppt[nIndex].Y,
                        lppt[nIndex + 1].X, lppt[nIndex + 1].Y,
                        lppt[nIndex + 2].X, lppt[nIndex + 2].Y);
                    nIndex += 2;
                    pptPrev = lppt[nIndex];
                    break;
            }
            }

            // If the figure was never closed and should be,
            // close it now.
            if (bLastMoveToNull == false && nIndex > 1)
            {
            pPath.AddLine(pptPrev.X, pptPrev.Y, pptLastMoveTo.X, pptLastMoveTo.Y);
            //pPath->CloseFigure();
            }
        }