コード例 #1
0
        /// <summary>
        /// Creates a new <see cref="GraphicsEx"/> object from the specified <see cref="Control"/> object.
        /// </summary>
        /// <param name="ctl"><see cref="Control"/> object</param>
        /// <returns>This method returns a new OpenNETCF.Drawing.GraphicsEx object for the specified specified Control object.</returns>
        public static GraphicsEx FromControl(Control ctl)
        {
            IntPtr     hwnd = GetControlHandle(ctl);
            GraphicsEx gx   = FromHwnd(hwnd);

            GDIPlus.GetWindowRect(hwnd, ref gx.rect);
            return(gx);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new copy of <see cref="GraphicsEx"/> object from the specified Control object.
        /// </summary>
        /// <param name="ctl"><see cref="Control"/> object.</param>
        /// <returns>This method returns a new <see cref="GraphicsEx"/> object for the specified specified Control object.</returns>
        public static GraphicsEx CompatibleGraphics(Control ctl)
        {
            IntPtr     hwnd    = GetControlHandle(ctl);
            IntPtr     hdc     = GDIPlus.GetDC(hwnd);
            IntPtr     hDCCopy = GDIPlus.CreateCompatibleDC(hdc);
            GraphicsEx gx      = FromHdc(hDCCopy);

            GDIPlus.ReleaseDC(hwnd, hdc);
            gx.bCopy = true;
            return(gx);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new copy of <see cref="GraphicsEx"/> object from the existing <see cref="GraphicsEx"/> objec.
        /// </summary>
        /// <returns></returns>
        public GraphicsEx CompatibleGraphics()
        {
            IntPtr hDCCopy = GDIPlus.CreateCompatibleDC(this.hDC);
            IntPtr hBmpMem = GDIPlus.CreateCompatibleBitmap(this.hDC, this.rect.right - this.rect.left, this.rect.bottom - this.rect.top);

            GDIPlus.SelectObject(hDCCopy, hBmpMem);
            GraphicsEx gx = FromHdc(hDCCopy);

            gx.bCopy = true;
            return(gx);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new <see cref="GraphicsEx"/> object from the specified handle to a window.
        /// </summary>
        /// <param name="hwnd">Handle to a window.</param>
        /// <returns>This method returns a new <see cref="GraphicsEx"/> object for the specified window handle.  </returns>
        public static GraphicsEx FromHwnd(IntPtr hwnd)
        {
            //GraphicsEx gx = null;

            IntPtr hdc = GDIPlus.GetDC(hwnd);

            GraphicsEx gx = FromHdc(hdc);

            gx.hwnd = hwnd;

            return(gx);
        }
コード例 #5
0
        /// <summary>
        /// Creates a new <see cref="GraphicsEx"/> object from the specified native graphics handle.
        /// </summary>
        /// <param name="nativeGraphics">native graphics handle.</param>
        public static GraphicsEx FromHdc(IntPtr nativeGraphics)
        {
            GraphicsEx gx = null;

            if (nativeGraphics != IntPtr.Zero)
            {
                gx = new GraphicsEx(nativeGraphics);
            }
            else
            {
                return(null);
            }

            return(gx);
        }
コード例 #6
0
 /// <summary>
 /// Copies the graphics.
 /// </summary>
 /// <param name="gx"></param>
 /// <param name="rc"></param>
 public void CopyGraphics(GraphicsEx gx, Rectangle rc)
 {
     int ret = GDIPlus.BitBlt(hDC, rc.Left, rc.Top, rc.Width, rc.Height, gx.hDC, 0, 0, GDIPlus.SRCCOPY);
 }