G
Guest
Hi everyone,
I'm developing a custom control that basically draws a circle. However I
notice that when I resize a form that contains the control, there is a lot of
flicker. I suppose that is because I'm not clipping using the ClipRectangle
property of the PaintEventArgs that comes with the OnPaint handler.
The OnPaint handler currently looks like this:
protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
{
e.Graphics.DrawEllipse (
Pens.Black,
ClientRectangle
);
e.Graphics.FillEllipse (
Brushes.Green,
ClientRectangle
);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
Font textFont = new Font( "Times New Roman", 10F );
e.Graphics.DrawString (
"Head",
textFont,
Brushes.White,
ClientRectangle,
stringFormat
);
base.OnPaint( e );
}
I do not see how I could use the ClipRectangle to only draw the portion that
needs to be redrawn... Can someone help me out?
Thanks, and kind regards,
I'm developing a custom control that basically draws a circle. However I
notice that when I resize a form that contains the control, there is a lot of
flicker. I suppose that is because I'm not clipping using the ClipRectangle
property of the PaintEventArgs that comes with the OnPaint handler.
The OnPaint handler currently looks like this:
protected override void OnPaint( System.Windows.Forms.PaintEventArgs e )
{
e.Graphics.DrawEllipse (
Pens.Black,
ClientRectangle
);
e.Graphics.FillEllipse (
Brushes.Green,
ClientRectangle
);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
Font textFont = new Font( "Times New Roman", 10F );
e.Graphics.DrawString (
"Head",
textFont,
Brushes.White,
ClientRectangle,
stringFormat
);
base.OnPaint( e );
}
I do not see how I could use the ClipRectangle to only draw the portion that
needs to be redrawn... Can someone help me out?
Thanks, and kind regards,