Library code snippets
An AutoRedraw Property
By Michael H, published on 05 Sep 2003
This demonstrates an autoredraw property in .NET to play around with!
using System;
using System.Diagnostics;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
public class AutoRedrawForm : Form {
private Bitmap b;
public AutoRedrawForm() {
b = new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
this.Resize += new EventHandler(this_Resize);
this.Paint += new PaintEventHandler(this_Paint);
}
private void this_Paint(object s,PaintEventArgs e) {
if(autoredraw) {
Graphics g = base.CreateGraphics();
g.DrawImage(b,0,0);
}
}
private void this_Resize(object s,EventArgs e) {
if(this.ClientSize.Width>b.Width && this.ClientSize.Height>b.Height) {
Bitmap c = new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
Graphics g = Graphics.FromImage(c);
g.DrawImage(b,0,0);
b = c;
g.Dispose();
}
}
private bool autoredraw;
public bool AutoRedraw {
get { return autoredraw; }
set { autoredraw = value; }
}
public new Graphics CreateGraphics() {
if(autoredraw) {
return Graphics.FromImage(b);
}
return base.CreateGraphics();
}
}
Related articles
Related discussion
-
How to optimize mysql subquery performance?
by Jayaram P (0 replies)
-
C# video Editing/rendering
by pkuchaliya (0 replies)
-
How to Fill DataSet with more records (around 1 lakh) in a faster way
by Jayaram P (0 replies)
-
Can't print on the network with MSADESS ??
by anatha1 (2 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
This thread is for discussions of An AutoRedraw Property.