private void memoryCleanup(object sender, EventArgs e) { if (managedBackBuffer != null) { managedBackBuffer.Dispose(); } }
/// <summary> /// Destroys the current buffer and creates a new buffered graphics /// sized to the client area of the owner control. /// </summary> internal bool RecreateBuffer() { if (creatingGraphics) { return(false); } creatingGraphics = true; bufferContext = BufferedGraphicsManager.Current; if (disposed) { throw (new ObjectDisposedException("bufferContext")); } int width = System.Math.Max(mImageListView.Width, 1); int height = System.Math.Max(mImageListView.Height, 1); bufferContext.MaximumBuffer = new Size(width, height); if (bufferGraphics != null) { bufferGraphics.Dispose(); } bufferGraphics = bufferContext.Allocate(mImageListView.CreateGraphics(), new Rectangle(0, 0, width, height)); creatingGraphics = false; InitializeGraphics(bufferGraphics.Graphics); return(true); }
private void MemoryCleanup(object sender, EventArgs e) { if (!object.ReferenceEquals(mManagedBackBuffer, NO_MANAGED_BACK_BUFFER)) { mManagedBackBuffer.Dispose(); } }
void formCustomTemplate_Disposed(object sender, EventArgs e) { if (background != null) { background.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing && (components != null)) { if (components != null) { components.Dispose(); } if (Layers != null) { foreach (Layer l in Layers) { l.Dispose(); } } if (backbufferGraphics != null) { backbufferGraphics.Dispose(); } if (backbufferContext != null) { backbufferContext.Dispose(); } if (customBrush != null) { customBrush.Dispose(); } } base.Dispose(disposing); }
void WindowBlock_Disposed(object sender, EventArgs e) { if (background != null) { background.Dispose(); } }
private void DisposeManagedResources() { m_bufferedGraphicsContext.Dispose(); if (m_bufferedGraphics != null) { m_bufferedGraphics.Dispose(); } }
public void Dispose() { if (null != mBuffer) { mBuffer.Dispose(); mBuffer = null; } }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); if (buffer != null) { buffer.Dispose(); buffer = null; } }
protected override void OnHandleDestroyed(EventArgs e) { if (_gxBuffer != null) { _gxBuffer.Dispose(); _gxBuffer = null; } base.OnHandleDestroyed(e); }
private void DisplayUI_Resize(object sender, EventArgs e) { if (bg != null) { bg.Dispose(); bg = null; } Invalidate(); }
public void ClearBuffer() { lock (bufferLock) { if (buffer != null) { buffer.Dispose(); buffer = null; } } }
void formMenu_Disposed(object sender, EventArgs e) { if (shadow != null) { shadow.Dispose(); } if (buffer != null) { buffer.Dispose(); } }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); if (buffer != null) { buffer.Dispose(); buffer = null; } resize = redraw = true; this.Invalidate(); }
void OnResize(object sender, EventArgs e) { if (ManagedBackBuffer != NO_MANAGED_BACK_BUFFER) { ManagedBackBuffer.Dispose(); } GraphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1); ManagedBackBuffer = GraphicManager.Allocate(this.CreateGraphics(), ClientRectangle); this.Invalidate(); }
protected override void OnResize(EventArgs eventargs) { if (ManagedBackBuffer != NO_MANAGED_BACK_BUFFER) { ManagedBackBuffer.Dispose(); } GraphicManager.MaximumBuffer = new Size(this.Width + 1, this.Height + 1); ManagedBackBuffer = GraphicManager.Allocate(this.CreateGraphics(), ClientRectangle); this.Refresh(); }
/// <summary> /// 开始绘图 /// </summary> /// <param name="g">绘图对象</param> /// <param name="wRect">窗体区域</param> /// <param name="pRect">刷新区域</param> public void BeginPaint(Graphics g, RECT wRect, RECT pRect) { if (m_buffer != null) { m_g.Dispose(); m_buffer.Dispose(); m_buffer = null; m_g = null; } m_graphics = g; m_buffer = m_currentContext.Allocate(m_graphics, new Rectangle(pRect.left, pRect.top, pRect.right - pRect.left, pRect.bottom - pRect.top)); m_g = m_buffer.Graphics; m_g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; }
public void Dispose_ActualMultipleTimes_Success() { using (var context = new BufferedGraphicsContext()) using (var image = new Bitmap(3, 3)) using (Graphics targetGraphics = Graphics.FromImage(image)) { BufferedGraphics graphics = context.Allocate(targetGraphics, new Rectangle(0, 0, context.MaximumBuffer.Width + 1, context.MaximumBuffer.Height + 1)); Assert.NotNull(graphics.Graphics); graphics.Dispose(); Assert.Null(graphics.Graphics); graphics.Dispose(); } }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); if (buffer != null) { buffer.Dispose(); buffer = null; } rectCollapse = new Rectangle(this.Width - 50, 0, 50, this.Height); redraw = true; this.Invalidate(); }
private void MemoryCleanup(object sender, EventArgs e) { if (bufferGraphics != NoBufferGraphics) { bufferGraphics.Dispose(); } if (backBuffer != NoBackBuffer) { backBuffer.Dispose(); } if (managedBackBuffer != NoManagedBackBuffer) { managedBackBuffer.Dispose(); } }
public void Dispose_TempMultipleTimes_Success() { using (var context = new BufferedGraphicsContext()) using (var image = new Bitmap(3, 3)) using (Graphics targetGraphics = Graphics.FromImage(image)) { BufferedGraphics graphics = context.Allocate(targetGraphics, Rectangle.Empty); Assert.NotNull(graphics.Graphics); graphics.Dispose(); Assert.Null(graphics.Graphics); graphics.Dispose(); } }
/// <summary> /// Initializes the back buffer. Needs to be called when resizing the window. /// </summary> private void InitBackBuffer(Rectangle displayRectangle) { _backBuffer?.Dispose(); BufferedGraphicsContext myContext = BufferedGraphicsManager.Current; _backBuffer = myContext.Allocate(CreateGraphics(), displayRectangle); }
private void Draw() { //pictureBox1.Refresh(); //Bitmap bitmap = new Bitmap(@"player1.png"); //bitmap.SetResolution(96, 96); //创建在picturebox1上的图像g1 Graphics g1 = pictureBox1.CreateGraphics(); //将图像画在内存上 BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; BufferedGraphics myBuffer = currentContext.Allocate(g1, this.DisplayRectangle); Graphics g = myBuffer.Graphics; //自定义绘图 //animation_ctrl = animation_ctrl + 1; Map.draw(map, player, npc, g, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height)); myBuffer.Render(); myBuffer.Dispose(); }
internal void Reset() { _currentCacheSize = Size.Empty; if (_bufferGraphics != null) { _bufferGraphics.Dispose(); } // cleanup data if (_hdc != (IntPtr)0) { Win32Api.SelectClipRgn(_hdc, (IntPtr)0); Win32Api.ReleaseDC(_skiningForm.Handle, _hdc); } if (_region != null && _hrgn != (IntPtr)0) { _region.ReleaseHrgn(_hrgn); } if (_region != null) { _region.Dispose(); } if (_g != null) { _g.Dispose(); } }
private void WmPaint(ref Message m) { IntPtr iHandle = GISShare.Win32.API.GetDC(m.HWnd); try { Graphics g = Graphics.FromHdc(iHandle); Rectangle rectangle = this.DisplayRectangle; if (m_BufferedGraphics == null || this.m_CurrentCacheSize != rectangle.Size) { if (m_BufferedGraphics != null) { m_BufferedGraphics.Dispose(); } m_BufferedGraphics = this.m_BufferedGraphicsContext.Allocate(g, rectangle); this.m_CurrentCacheSize = rectangle.Size; } this.OnPaint(new PaintEventArgs(m_BufferedGraphics.Graphics, rectangle)); if (m_BufferedGraphics != null) { m_BufferedGraphics.Render(g); } g.Dispose(); } catch { } finally { GISShare.Win32.API.ReleaseDC(m.HWnd, iHandle); } }
void MainFormFormClosed(object sender, FormClosedEventArgs e) { bg.Dispose(); bgc.Dispose(); //mg.ReleaseHdc(); mg.Dispose(); }
public void GameLoop() { var stopWatch = Stopwatch.StartNew(); TimeSpan last = stopWatch.Elapsed; InitGame(); while (_isAlive) { // update var currentTimeSpan = stopWatch.Elapsed; _phaseManager.Update(currentTimeSpan - last); // render game phase _phaseManager.Render(_backBuffer); // render logs (if needed) _logsOverlay.Render(_backBuffer); _backBuffer.Render(); _backBuffer.Render(CreateGraphics()); Application.DoEvents(); last = currentTimeSpan; } _backBuffer.Dispose(); }
public void UpdateMap() { //清空之前占用的绘图资源 if (backMap != null) { if (backMap.Graphics != null) { backMap.Graphics.Dispose(); } backMap.Dispose();//释放backmap的所有资源 } //初始化绘图资源 Graphics frontgraphics = CreateGraphics(); backMap = backWindow.Allocate(frontgraphics, ClientRectangle);//创建使用指定的像素格式的指定大小的图像缓冲区 frontgraphics.Dispose(); //在背景窗口中绘图 Graphics graphics = backMap.Graphics; graphics.FillRectangle(new SolidBrush(Color.Black), ClientRectangle); layer.draw(graphics, view); //把绘图内容搬到前端 Invalidate();//使整个控件画面无效并重绘控件 UpdateStatusBar(); }
/// <summary> /// Render and dispose /// </summary> public void Dispose() { g.Flush(); _g.Render(); g.Dispose(); _g.Dispose(); }
protected override void OnSizeChanged(EventArgs e) { if (buffer != null) { buffer.Dispose(); buffer = null; } if (background != null) { background.Dispose(); background = null; } OnRedrawRequired(); base.OnSizeChanged(e); }