using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace evonne
{
public partial class Form1 : Form
{
int a = -50, b = -50, f,d;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
d = a % 150;
button1.Text = d.ToString();
pictureBox1.Location = new Point(a+=50, b+=50);
if (a > 500)
{
f = 1;
}
if (a <= 50)
{
f = 2;
}
if (f == 1)
{
pictureBox1.Location = new Point(a-=50*2, b-=50*2);
}
}
private void button2_Click(object sender, EventArgs e)
{
d = a % 150;
button2.Text = b.ToString();
pictureBox1.Location = new Point(a += 50, b += 50);
if (a > 500)
{
f = 1;
}
if (a <= 50)
{
f = 2;
}
if (f == 1)
{
pictureBox1.Location = new Point(a -= 50 * 2, b -= 50 * 2);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
d = a % 150;
button1.Text = d.ToString();
pictureBox1.Location = new Point(a += 50, b += 50);
if (a > 500)
{
f = 1;
}
if (a <= 50)
{
f = 2;
}
if (f == 1)
{
pictureBox1.Location = new Point(a -= 50 * 2, b -= 50 * 2);
}
if (d == 50)
{
button1.BackColor = System.Drawing.Color.Red;
}
if(d==100){
button1.BackColor = System.Drawing.Color.Black;
}
if (d == 0)
{
button1.BackColor = System.Drawing.Color.White;
}
if (d == 100)
{
button2.BackColor = System.Drawing.Color.Red;
}
if (d == 0)
{
button2.BackColor = System.Drawing.Color.Black;
}
if (d == 50)
{
button2.BackColor = System.Drawing.Color.White;
}
if (d == 0)
{
button3.BackColor = System.Drawing.Color.Red;
}
if (d == 50)
{
button3.BackColor = System.Drawing.Color.Black;
}
if (d == 100)
{
button3.BackColor = System.Drawing.Color.White;
}
}
}
沒有留言:
張貼留言