1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 設計者 /// <summary> int Count; int Move; int Height; /// 設計工具所需的變數。 /// </summary> namespace _103303058_0511_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void timer_Animation_Tick(object sender, EventArgs e) { pictureBox1.Image = imageList1.Images[Count%6]; Count++; } private void Form1_Click(object sender, EventArgs e) { if (timer_Animation.Enabled) { timer_Animation.Stop(); } else { timer_Animation.Start(); } if (timer_Runner.Enabled) { timer_Runner.Stop(); } else { timer_Runner.Start(); } } private void Form1_Load(object sender, EventArgs e) { Count = 0; Move = 0; } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { timer_Animation.Interval = (int) numericUpDown1.Value; //強制型別轉換 } private void timer_Runner_Tick(object sender, EventArgs e) { pictureBox1.Location = new Point(Move, Height); if (Move >= this.Width) { Move = -pictureBox1.Width; } else { Move += 15; } } private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text == "") { Height = 0; } else { Height = (int)Convert.ToDouble(textBox1.Text); } pictureBox1.Location = new Point(Move, Height); } private void numericUpDown2_ValueChanged(object sender, EventArgs e) { timer_Runner.Interval = (int)numericUpDown2.Value; } } } |
Direct link: https://paste.plurk.com/show/DANcl7ZzsFdOFzg1Zxgq