Exemple #1
0
        /// <summary>
        /// Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.
        /// </summary>
        /// <param name="pen">A <see cref="PenEx"/> object that determines the color, width, and style of the ellipse.</param>
        /// <param name="x">x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.</param>
        /// <param name="y">y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.</param>
        /// <param name="width">Width of the bounding rectangle that defines the ellipse.</param>
        /// <param name="height">Height of the bounding rectangle that defines the ellipse.</param>
        public void DrawEllipse(PenEx pen, int x, int y, int width, int height)
        {
            IntPtr hOldPen = IntPtr.Zero;

            hOldPen = GDIPlus.SelectObject(hDC, pen.hPen);
            GDIPlus.Ellipse(hDC, x, y, x + width, y + height);
            GDIPlus.DeleteObject(GDIPlus.SelectObject(hDC, hOldPen));
        }
Exemple #2
0
        /// <summary>
        /// Draws an ellipse specified by a bounding <see cref="System.Drawing.Rectangle"/> structure.
        /// </summary>
        /// <param name="pen">A <see cref="PenEx"/> object that determines the color, width, and style of the ellipse.</param>
        /// <param name="rc">A <see cref="System.Drawing.Rectangle"/> structure that represents the rectangle to draw.</param>
        public void DrawEllipse(PenEx pen, Rectangle rc)
        {
            IntPtr hOldPen = IntPtr.Zero;

            hOldPen = GDIPlus.SelectObject(hDC, pen.hPen);
            GDIPlus.Ellipse(hDC, rc.Left, rc.Top, rc.Right, rc.Bottom);
            GDIPlus.DeleteObject(GDIPlus.SelectObject(hDC, hOldPen));
        }
Exemple #3
0
//		public void DrawFrameControl(Rectangle rc, FrameType type, int state)
//		{
//			GDIPlus.DrawFrameControl(hDC, ref rc, (int)type, state);
//
//		}

        /// <summary>
        /// Draws a rectangle with rounded corners.
        /// </summary>
        /// <param name="pen">A <see cref="PenEx"/> object that determines the color, width, and style of the rectangle</param>
        /// <param name="rc">A <see cref="System.Drawing.Rectangle"/> structure that represents the rectangle to draw.</param>
        /// <param name="size">A <see cref="Size"/> structre that defines the corner radius.</param>
        public void DrawRoundRectangle(PenEx pen, Rectangle rc, Size size)
        {
            IntPtr hOldPen = IntPtr.Zero;

            hOldPen = GDIPlus.SelectObject(hDC, pen.hPen);
            GDIPlus.RoundRect(hDC, rc.Left, rc.Top, rc.Right, rc.Bottom, size.Height, size.Width);
            GDIPlus.DeleteObject(GDIPlus.SelectObject(hDC, hOldPen));
        }
Exemple #4
0
        /// <summary>
        /// Draws a line connecting the two points specified by coordinate pairs.
        /// </summary>
        /// <param name="pen">PenEx object that determines the color, width, and style of the line.</param>
        /// <param name="xStart">x-coordinate of the first point.</param>
        /// <param name="yStart">y-coordinate of the first point.</param>
        /// <param name="xEnd">x-coordinate of the second point.</param>
        /// <param name="yEnd">x-coordinate of the seconf point.</param>
        public void DrawLine(PenEx pen, int xStart, int yStart, int xEnd, int yEnd)
        {
            IntPtr hOldPen = IntPtr.Zero;

            hOldPen = GDIPlus.SelectObject(hDC, pen.hPen);
            //Set start position
            GDIPlus.POINT pt = new GDIPlus.POINT();
            GDIPlus.MoveToEx(hDC, xStart, yStart, ref pt);
            //Drawe line
            GDIPlus.LineTo(hDC, xEnd, yEnd);
            //Restore the initial position
            GDIPlus.MoveToEx(hDC, pt.x, pt.y, ref pt);
            //Clean up
            GDIPlus.DeleteObject(GDIPlus.SelectObject(hDC, hOldPen));
        }
Exemple #5
0
        /// <summary>
        /// Draws a rectangle specified by a <see cref="Rectangle"/> structure.
        /// </summary>
        /// <param name="pen">A <see cref="PenEx"/> object that determines the color, width, and style of the rectangle. </param>
        /// <param name="rc">A <see cref="Rectangle"/> structure that represents the rectangle to draw. </param>
        public void DrawRectangle(PenEx pen, Rectangle rc)
        {
            IntPtr hOldPen = IntPtr.Zero;

            hOldPen = GDIPlus.SelectObject(hDC, pen.hPen);
            int[] pt = new int[10];

            pt[0] = rc.Left;
            pt[1] = rc.Top;
            pt[2] = rc.Right - 1;
            pt[3] = rc.Top;
            pt[4] = rc.Right - 1;
            pt[5] = rc.Bottom - 1;

            pt[6] = rc.Left;
            pt[7] = rc.Bottom - 1;
            pt[8] = rc.Left;
            pt[9] = rc.Top;

            GDIPlus.Polyline(hDC, pt, 5);
            GDIPlus.DeleteObject(GDIPlus.SelectObject(hDC, hOldPen));
        }
Exemple #6
0
 /// <summary>
 /// Draws a rectangle.
 /// </summary>
 /// <param name="pen">A <see cref="PenEx"/> object that determines the color, width, and style of the rectangle. </param>
 /// <param name="x">x: x-coordinate of the upper-left corner of the rectangle to draw. </param>
 /// <param name="y"> y: y-coordinate of the upper-left corner of the rectangle to draw.  </param>
 /// <param name="cx">width: width of the rectangle to draw. </param>
 /// <param name="cy">height: Height of the rectangle to draw. </param>
 public void DrawRectangle(PenEx pen, int x, int y, int cx, int cy)
 {
     DrawRectangle(pen, new Rectangle(x, y, cx, cy));
 }