111,129
社区成员
发帖
与我相关
我的任务
分享
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i;
int r;
string[] names = new string[] { "刘翔", "毕福建", "布什"};
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
timer1.Enabled = true;
label1.Visible = false;
label2.Visible = false;
}
if (e.KeyCode == Keys.Enter)
{
timer1.Enabled = false;
label1.Visible = true;
r = 0;
r = i % names.Length;
label1.Text = "恭喜您!抽中了:" + names[r];
}
if (e.KeyData == Keys.Escape) Application.Exit();
{
}
}
private void timer1_Tick(object sender, EventArgs e)
{
List<Image> lst = new List<Image>();//保存图片
lst.Add(Image.FromFile("C:\\choujiang\\毕福剑.jpg"));
lst.Add(Image.FromFile("C:\\choujiang\\布什.jpg"));
lst.Add(Image.FromFile("C:\\choujiang\\成龙.jpg"));
if (i>=lst.Count)
{
i = 0;
}
else
{
this.pictureBox1.Image = lst[i];
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
i = i + 1;
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
}
}