Little test for invalidation. Nice for profiling.

svn path=/trunk/winforms/; revision=54257
This commit is contained in:
Jackson Harper 2005-12-12 20:34:22 +00:00
Родитель 91c73ffd9f
Коммит e366382ede
2 изменённых файлов: 80 добавлений и 0 удалений

10
invalidate/Makefile Normal file
Просмотреть файл

@ -0,0 +1,10 @@
all: mono
mono: swf-invalidate.cs
mcs swf-invalidate.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
dotnet: swf-invalidate.cs
csc swf-invalidate.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
clean:
rm swf-invalidate.exe -r -f

Просмотреть файл

@ -0,0 +1,70 @@
using System;
using System.Drawing;
using System.Windows.Forms;
public class InvalidateForm : Form {
private Timer timer;
private int width;
private bool region;
public InvalidateForm ()
{
timer = new Timer ();
timer.Interval = 500;
timer.Tick += new EventHandler (TimerTick);
timer.Enabled = true;
BackColor = Color.Blue;
Paint += new PaintEventHandler (PaintHandler);
Click += new EventHandler (ClickHandler);
}
private void TimerTick (object sender, EventArgs e)
{
width += 10;
if (width > Width + 11) {
width = 0;
Refresh ();
region = !region;
return;
}
if (!region) {
Invalidate (new Rectangle (0, 0, width, Height));
} else {
int half = width / 2;
int xmiddle = Width / 2;
int ymiddle = Height / 2;
Rectangle rect = new Rectangle (xmiddle - half, ymiddle - half, width, width);
Invalidate (new Region (rect));
}
}
private void ClickHandler (object sender, EventArgs e)
{
timer.Enabled = !timer.Enabled;
}
private void PaintHandler (object sender, PaintEventArgs pe)
{
if (pe.ClipRectangle.Width == Width && pe.ClipRectangle.Height == Height) {
Console.WriteLine ("Clearing Form");
pe.Graphics.FillRectangle (new SolidBrush (BackColor), pe.ClipRectangle);
return;
}
Console.WriteLine ("Filling: " + pe.ClipRectangle);
pe.Graphics.FillRectangle (new SolidBrush (Color.Red), pe.ClipRectangle);
}
public static void Main ()
{
Application.Run (new InvalidateForm ());
}
}