我正在尝试覆盖Windows窗体的绘制事件,但是即使在我Invalidate()
和Update()
表单之后,我对表单所做的所有绘画都会保留。
我正在使用计时器Invalidate()
和Update()
表单,这会导致OnPaint()
被调用
以下是代码:
// In the constructor the timer is created and enabled
private void UpdaterElapsed(object sender, System.Timers.ElapsedEventArgs e)
{
WIDGET.Invalidate();
WIDGET.Update();
}
private void WIDGET_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
String text = DateTime.Now.ToString("hh:mm:ss tt");
e.Graphics.DrawString(text, new Font("Arial", 32), Brushes.Black, new Point(0, 0));
}