📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace jcbf
{
public partial class Form1 : Form
{
int fi_i1 = 0, fi_i2 = 0, fi_i3 = 0;
int type = 0;
int t = 0;
bool type1 = true;
bool type2 = true;
bool type3 = true;
bool is_run1 = true;
bool is_run2 = true;
bool is_run3 = true;
public Form1()
{
InitializeComponent();
}
public void suiji()
{
Random r1 = new Random();
type = r1.Next(8);
if (type < 4)
{
timer1.Interval=r1.Next(1,50);
}
else
{
if (type<7)
timer1.Interval=r1.Next(100,150);
else
timer1.Interval=r1.Next(200,300);
}
}
public void Run1()
{
if (is_run1 == true)
{
if (type1 == true)
{
if (4 * (fi_i1++) < 400)
pictureBox1.SetBounds(4 * (fi_i1++), 0, 50, 65);
else
type1 = false;
}
else
if (4 * (fi_i1) > 0)
pictureBox1.SetBounds(4 * (fi_i1--), 0, 50, 65);
else
type1 = true;
}
}
public void Run2()
{
if (is_run2 == true)
{
if (type2 == true)
{
if (4 * (fi_i2) < 400)
pictureBox2.SetBounds(4 * (fi_i2++), 0, 50, 67);
else
type2 = false;
}
else
if (4 * fi_i2 > 0)
pictureBox2.SetBounds(4 * (fi_i2--), 0, 50, 67);
else
type2 = true;
}
}
public void Run3()
{
if (is_run3 == true)
{
if (type3 == true)
{
if (4 * fi_i3 < 400)
pictureBox3.SetBounds(4 * (fi_i3++), 0, 50, 72);
else
type3 = false;
}
else
if (4 * fi_i3 > 0)
pictureBox3.SetBounds(4 * (fi_i3--), 0, 50, 72);
else
type3 = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
switch (type)
{
case 1:
timer1.Enabled = true;
this.Run1();
break;
case 2:
timer1.Enabled = true;
this.Run2();
break;
case 3:
timer1.Enabled = true;
this.Run3();
break;
case 4:
timer1.Enabled = true;
this.Run1(); this.Run2();
break;
case 5:
timer1.Enabled = true;
this.Run1(); this.Run3();
break;
case 6:
timer1.Enabled = true;
this.Run2(); this.Run3();
break;
case 7:
timer1.Enabled = true;
this.Run1(); this.Run2(); this.Run3();
break;
}
}
private void button5_Click(object sender, EventArgs e)
{
this.Close();
}
public void panduan()
{
if (is_run1 == true)
{
if (is_run2 == true)
{
if (is_run3 == true)
type = 7;
else
type = 4;
}
else
if (is_run3 == true)
type = 5;
else
type = 1;
}
else
{
if (is_run2 == true)
{
if (is_run3 == true)
type = 6;
else
type = 2;
}
else
if (is_run3 == true)
type = 3;
}
}
private void button1_Click(object sender, EventArgs e)
{
is_run1 = true;
timer1.Enabled = true;
this.panduan();
}
private void button2_Click(object sender, EventArgs e)
{
is_run1 = false;
this.panduan();
}
private void button3_Click(object sender, EventArgs e)
{
is_run2 = true;
timer1.Enabled = true;
this.panduan();
}
private void button4_Click(object sender, EventArgs e)
{
is_run2 = false;
this.panduan();
}
private void button6_Click(object sender, EventArgs e)
{
is_run3 = true;
timer1.Enabled = true;
this.panduan();
}
private void button7_Click(object sender, EventArgs e)
{
is_run3 = false;
this.panduan();
}
private void timer2_Tick(object sender, EventArgs e)
{
suiji();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -