/// <include file='doc\Font.uex' path='docs/doc[@for="Font.GetHeight1"]/*' /> /// <devdoc> /// </devdoc> public float GetHeight() { IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef); float height = 0.0f; try { using (Graphics graphics = Graphics.FromHdcInternal(screenDC)) { height = GetHeight(graphics); } } finally { UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC)); } return(height); }
public void ToLogFont(object logFont) { IntPtr dC = System.Drawing.UnsafeNativeMethods.GetDC(System.Drawing.NativeMethods.NullHandleRef); try { using (Graphics graphics = Graphics.FromHdcInternal(dC)) { this.ToLogFont(logFont, graphics); } } finally { System.Drawing.UnsafeNativeMethods.ReleaseDC(System.Drawing.NativeMethods.NullHandleRef, new HandleRef(null, dC)); } }
// Operations /// <include file='doc\Font.uex' path='docs/doc[@for="Font.ToLogFont"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void ToLogFont(object logFont) { IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef); try { Graphics graphics = Graphics.FromHdcInternal(screenDC); try { this.ToLogFont(logFont, graphics); } finally { graphics.Dispose(); } } finally { UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC)); } }
public float GetHeight() { IntPtr dC = System.Drawing.UnsafeNativeMethods.GetDC(System.Drawing.NativeMethods.NullHandleRef); float height = 0f; try { using (Graphics graphics = Graphics.FromHdcInternal(dC)) { height = this.GetHeight(graphics); } } finally { System.Drawing.UnsafeNativeMethods.ReleaseDC(System.Drawing.NativeMethods.NullHandleRef, new HandleRef(null, dC)); } return(height); }
private Graphics CreateBuffer(IntPtr src, int offsetX, int offsetY, int width, int height) { this.busy = 2; this.DisposeDC(); this.busy = 1; this.compatDC = System.Drawing.UnsafeNativeMethods.CreateCompatibleDC(new HandleRef(null, src)); if ((width > this.bufferSize.Width) || (height > this.bufferSize.Height)) { int ulWidth = Math.Max(width, this.bufferSize.Width); int ulHeight = Math.Max(height, this.bufferSize.Height); this.busy = 2; this.DisposeBitmap(); this.busy = 1; IntPtr zero = IntPtr.Zero; this.dib = this.CreateCompatibleDIB(src, IntPtr.Zero, ulWidth, ulHeight, ref zero); this.bufferSize = new Size(ulWidth, ulHeight); } this.oldBitmap = SafeNativeMethods.SelectObject(new HandleRef(this, this.compatDC), new HandleRef(this, this.dib)); this.compatGraphics = Graphics.FromHdcInternal(this.compatDC); this.compatGraphics.TranslateTransform((float)-this.targetLoc.X, (float)-this.targetLoc.Y); this.virtualSize = new Size(width, height); return(this.compatGraphics); }
private Graphics CreateBuffer(IntPtr src, int offsetX, int offsetY, int width, int height) { //create the compat DC busy = BUFFER_BUSY_DISPOSING; DisposeDC(); busy = BUFFER_BUSY_PAINTING; compatDC = UnsafeNativeMethods.CreateCompatibleDC(new HandleRef(null, src)); //recreate the bitmap if necessary if (width > bufferSize.Width || height > bufferSize.Height) { Debug.WriteLineIf(DoubleBuffering.TraceInfo, "allocating new bitmap: " + width + " x " + height); int optWidth = Math.Max(width, bufferSize.Width); int optHeight = Math.Max(height, bufferSize.Height); busy = BUFFER_BUSY_DISPOSING; DisposeBitmap(); busy = BUFFER_BUSY_PAINTING; Debug.WriteLineIf(DoubleBuffering.TraceInfo, " new size : " + optWidth + " x " + optHeight); IntPtr pvbits = IntPtr.Zero; dib = CreateCompatibleDIB(src, IntPtr.Zero, optWidth, optHeight, ref pvbits); bufferSize = new Size(optWidth, optHeight); } //select the bitmap oldBitmap = SafeNativeMethods.SelectObject(new HandleRef(this, compatDC), new HandleRef(this, dib)); //create compat graphics Debug.WriteLineIf(DoubleBuffering.TraceInfo, " Create compatGraphics"); compatGraphics = Graphics.FromHdcInternal(compatDC); compatGraphics.TranslateTransform(-targetLoc.X, -targetLoc.Y); virtualSize = new Size(width, height); return(compatGraphics); }