日期:2014-05-17 浏览次数:20780 次
void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath path = new GraphicsPath();
path.Reset();
path.AddArc(50, 50, 200, 200, 150, angle + 1);
g.DrawPath(new Pen(Color.Red, 50f), path);
path.Reset();
path.AddArc(50, 50, 200, 200, 150 + angle, 240 - angle + 2);
g.DrawPath(new Pen(Color.Gray, 50f), path);
path.Reset();
path.AddArc(50, 50, 200, 200, 30, 120 + 1);
g.DrawPath(new Pen(Color.Green, 50f), path);
float x = (float)Math.Cos((angle + 150) * Math.PI / 180) * 150 + 150;
float y = (float)Math.Sin((angle + 150) * Math.PI / 180) * 150 + 150;
path.Reset();
path.AddLine(x, y, 150, 150);
Pen pen = new Pen(Color.Blue, 10f);
pen.StartCap = LineCap.ArrowAnchor;
g.DrawPath(pen, path);
pen.Dispose();
path.Dispose();
}
private Timer timer;
int angle = 0;
void DrawArc()
{
angle++;
if (angle >= 240) angle = 0;
this.Invalidate();
}
void timer_Tick(object sender, EventArgs e)
{
DrawArc();
}