我正在尝试根据从 XML 文件中读取的坐标绘制一个移动圆。目前圆圈只会画一次。有人可以告诉我我要去哪里错了吗?!
EyeMove 方法在循环中调用,该循环从 XML 读取 X 和 Y 字符串并解析为浮点数
public void EyeMove(float x, float y)
{
point = new PointF(x, y);
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawCircle(e.Graphics, point.X, point.Y);
}
private void DrawCircle(Graphics g, float x, float y)
{
using (Brush semiTransBrush = new SolidBrush(Color.Coral))
{
using (Pen pen = new Pen(Color.Aquamarine, 2))
{
g.DrawEllipse(pen, x, y, 50, 50);
g.FillEllipse(semiTransBrush, x, y, 50, 50);
}
}
}