public void Dispose() { if (this.m_matrix != null) { if (!Win32.SetWorldTransform(this.m_hdc, ref this.m_oldXForm)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } if (Win32.SetGraphicsMode(this.m_hdc, this.m_oldMode) == 0) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } this.m_matrix.Dispose(); this.m_matrix = null; } if (!this.m_hdc.IsInvalid) { this.m_graphics.ReleaseHdc(); } this.m_graphics.PageScale = this.m_pageScale; this.m_graphics.PageUnit = this.m_pageUnits; GC.SuppressFinalize(this); }
private void SetupGraphics(float dpi) { this.m_graphics.PageUnit = GraphicsUnit.Pixel; this.m_graphics.PageScale = 1f; this.m_hdc = new Win32DCSafeHandle(this.m_graphics.GetHdc(), false); this.m_oldXForm = default(Win32.XFORM); if (this.m_matrix != null) { this.m_xForm = new Win32.XFORM(this.m_matrix, this.m_pageUnits, dpi); this.m_oldMode = Win32.SetGraphicsMode(this.m_hdc, 2); if (!Win32.GetWorldTransform(this.m_hdc, ref this.m_oldXForm)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } if (!Win32.SetWorldTransform(this.m_hdc, ref this.m_xForm)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } } else { this.m_xForm = Win32.XFORM.Identity; } }