[問題] 關於 使用Panel 表現圓形移動的方法
以下為使用Timer 跟 Panel 的程式碼...
可是沒有顯示出我想要的結果
請問是我哪理觀念錯了嗎??
public partial class Form1 : Form
{
int status;
static int x;
int y;
System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
static bool exitFlag = false;
public Form1()
{
InitializeComponent();
status = 1;
x = 25;
y = 25;
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen pen = new Pen(Color.Blue);
if (status == 0)
{
g.DrawPie(pen, x, y, 15, 15,0,360);
}
}
private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
x += 5;
myTimer.Stop();
panel1.Invalidate();
myTimer.Enabled = true;
if(x==100)
{
exitFlag = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Interval = 500;
myTimer.Start();
while (exitFlag == false)
{
Application.DoEvents();
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.8.69.235
推
04/30 02:00, , 1F
04/30 02:00, 1F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章