Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
DoubleBuffer.cs
Package: ProgressBar_src.rar [view]
Upload User: nnpulika
Upload Date: 2013-02-15
Package Size: 597k
Code Size: 2k
Category:
StatusBar
Development Platform:
C#
- using System;
- using System.Drawing;
- using UtilityLibrary.General;
- namespace UtilityLibrary.WinControls
- {
- /// <summary>
- /// Summary description for DoubleBuffer.
- /// </summary>
- public class DoubleBuffer
- {
- #region Class Variables
- int bufferWidth;
- int bufferHeight;
- Bitmap surface;
- Graphics buffer;
- #endregion
- #region Constructors
- public DoubleBuffer()
- {
- }
- public void Dispose()
- {
- Cleanup();
- }
- #endregion
- #region Methods
- public Graphics RequestBuffer(int width, int height, Graphics g)
- {
- if (width == bufferWidth && height == bufferHeight && buffer != null)
- {
- return buffer;
- }
- Cleanup();
- surface = new Bitmap(width, height, g);
- buffer = Graphics.FromImage(surface);
- bufferWidth = width;
- bufferHeight = height;
- return buffer;
- }
- public void PaintBuffer(Graphics dest, int x, int y)
- {
- dest.DrawImage(surface, x, y);
- }
- public void PaintBuffer(Graphics dest, Rectangle destRect, Rectangle sourceRect)
- {
- dest.DrawImage(surface, destRect, sourceRect, GraphicsUnit.Pixel);
- }
- public void GDIPaintBuffer(Graphics dest, Rectangle destRect, Rectangle srcRect)
- {
- GDIUtil.StrechBitmap(dest, destRect, srcRect, surface);
- }
- #endregion
- #region Implementation
- private void Cleanup()
- {
- if (buffer != null)
- {
- buffer.Dispose();
- buffer = null;
- }
- if (surface != null)
- {
- surface.Dispose();
- surface = null;
- }
- }
- #endregion
- }
- }