close

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int c, r;
public Form1()
{
InitializeComponent();
c = 0;
}
private void button2_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 3;
label1.Text = "r=" + r;
if (r == 0)
{
button1.Location = new Point(0, 0);
button2.BackColor = Color.Black;
}
if (r == 1)
{
button1.Location = new Point(0, 0);
button2.BackColor = Color.Black;
}
else
{
button1.Location = new Point(100, 0);
button2.BackColor = Color.Yellow;
}
}
private void button3_Click(object sender, EventArgs e)
{
c = c + 1;
r = c % 3;
label1.Text = "r=" + r;
if (r == 0)
{
button1.Location = new Point(0, 0);
button3.BackColor = Color.Black;
}
if (r == 1)
{
button1.Location = new Point(0, 0);
button3.BackColor = Color.Red;
}
else
{
button1.Location = new Point(100, 0);
button3.BackColor = Color.Black;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
r = c % 3;
label1.Text = "r=" + r;
if (r >= 1)
{
button3.BackColor = Color.Black;
button4.BackColor = Color.Yellow;
button5.BackColor = Color.Black;
if (r == 2)
{
button3.BackColor = Color.Red;
button4.BackColor = Color.Black;
button5.BackColor = Color.Black;
}
}
else
{
button3.BackColor = Color.Black;
button4.BackColor = Color.Black;
button5.BackColor = Color.Green;
}
}
}
}

 

arrow
arrow
    全站熱搜

    wunash830409 發表在 痞客邦 留言(0) 人氣()