[問題] 關於 使用Panel 表現圓形移動的方法

看板C_Sharp (C#)作者 (emeth)時間18年前 (2007/04/29 12:39), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
以下為使用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
你要不要檢查一下status變數..
04/30 02:00, 1F
文章代碼(AID): #16D26Blv (C_Sharp)
文章代碼(AID): #16D26Blv (C_Sharp)