public RazorPainterWPFCtl() { InitializeComponent(); hDCGraphics = RazorBackend1.CreateGraphics(); hDCRef = new HandleRef(hDCGraphics, hDCGraphics.GetHdc()); RP = new RazorPainter(); RazorBMP = new System.Drawing.Bitmap(RazorWidth, RazorHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb); RazorGFX = System.Drawing.Graphics.FromImage(RazorBMP); RazorBackend1.Resize += (sender, args) => { lock (RazorLock) { if (RazorGFX != null) { RazorGFX.Dispose(); } if (RazorBMP != null) { RazorBMP.Dispose(); } RazorBMP = new System.Drawing.Bitmap(RazorWidth, RazorWidth, System.Drawing.Imaging.PixelFormat.Format32bppArgb); RazorGFX = System.Drawing.Graphics.FromImage(RazorBMP); } }; }
/// <summary> /// Освободить все используемые ресурсы. /// </summary> /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } lock (this) { if (RazorGFX != null) { RazorGFX.Dispose(); } if (RazorBMP != null) { RazorBMP.Dispose(); } if (hDCGraphics != null) { hDCGraphics.Dispose(); } RP.Dispose(); } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { lock (RazorLock) { if (RazorGFX != null) { RazorGFX.Dispose(); } if (RazorBMP != null) { RazorBMP.Dispose(); } //hDCGraphics.ReleaseHdc(); if (hDCGraphics != null) { hDCGraphics.Dispose(); } //RP.Dispose(); } base.Dispose(disposing); }