/// <summary> /// Creates a WindowsGraphics from a memory DeviceContext object compatible with the primary screen device. /// This object is suitable for performing text measuring but not for drawing into it because it does /// not have a backup bitmap. /// </summary> public static WindowsGraphics CreateMeasurementWindowsGraphics() { DeviceContext dc = DeviceContext.FromCompatibleDC(IntPtr.Zero); return(new WindowsGraphics(dc) { _disposeDc = true // we create it, we dispose it. }); }
/// <summary> /// Creates a WindowsGraphics from a memory DeviceContext object compatible with the a screen device. /// This object is suitable for performing text measuring but not for drawing into it because it does /// not have a backup bitmap. /// </summary> public static WindowsGraphics CreateMeasurementWindowsGraphics(IntPtr screenDC) { DeviceContext dc = DeviceContext.FromCompatibleDC(screenDC); WindowsGraphics wg = new WindowsGraphics(dc) { _disposeDc = true // we create it, we dispose it. }; return(wg); }
/// <summary> /// Creates a WindowsGraphics from a memory DeviceContext object compatible with the primary screen device. /// This object is suitable for performing text measuring but not for drawing into it because it does /// not have a backup bitmap. /// </summary> public static WindowsGraphics CreateMeasurementWindowsGraphics() { DeviceContext dc = DeviceContext.FromCompatibleDC(IntPtr.Zero); var wg = new WindowsGraphics(dc) { _disposeDc = true // we create it, we dispose it. }; // This instance is stored in a thread static so it will *always* get put on the finalizer queue. // As we can't do anything in the finalizer, suppress finalization for this instance (otherwise // our Dispose validation will assert and take down debug test runs). wg.SuppressFinalize(); return(wg); }