2020-11-11

namespace windows窗体表白神器
{
public partial class Form1 : Form
{
public static int count=0; //定义一个全局变量count
public static int count1 = 0; //全局变量

public Form1()
{
InitializeComponent();
pictureBox1.Image = Image.FromFile(“H:\图片\1.gif”); //初始化
}

    **private void button2_Click(object sender, EventArgs e)
    {
 
        int x = this.ClientSize.Width - button2.Width;         //如果鼠标靠近  button2  移动位置
        int y = this.ClientSize.Height - button2.Height;        //但是不能超出这个窗体的范围
        Random r = new Random();            //获取随机数
        button2.Location = new Point(r.Next(0, x + 1), r.Next(0, y + 1));  //button2 的坐标
    }
    private void button1_Click(object sender, EventArgs e)
    {
        count1++;
        if (count1 == 1)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\6.jpg");
        }
        else if (count1 == 2)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\7.jpg");
        }
        else if (count1== 3)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\8.jpg");
        }
        else 
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\9.jpg");
            MessageBox.Show("从此以后你就是我的小祖宗了", "信息提示", MessageBoxButtons.OKCancel);
        }
        button2.Location = new System.Drawing.Point(128,305);           //如果按完好的时候  button2  和  button3  回到原位置
        button3.Location = new System.Drawing.Point(373, 305);              //但是始终不会被按到
    }
    private void button3_Click(object sender, EventArgs e)
    {
        button3.Enabled = false;
        MessageBox.Show("想退出,门都没有", "信息提示", MessageBoxButtons.OKCancel);
    }
    private void button4_Click(object sender, EventArgs e)
    {
        count++;
        if (count == 1)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\2.jpg");
        }
        else if (count == 2)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\3.jpg");
        }
        else if (count == 3)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\4.jpg");
        }
        else if (count == 4)
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\5.jpg");
        }
        else
        {
            pictureBox1.Image = Image.FromFile("H:\\图片\\最后.jpg");
            MessageBox.Show("你已经没有可以考虑的了","信息提示",MessageBoxButtons.OKCancel);   //弹出消息框
        }
        button2.Location = new System.Drawing.Point(128, 305);           //如果按完好的时候  button2  和  button3  回到原位置
        button3.Location = new System.Drawing.Point(373, 305);              //但是始终不会被按到
    }
    private void button4_MouseEnter(object sender, EventArgs e)
    {
        button2.Location = new System.Drawing.Point(128, 305);           //如果按完好的时候  button2  和  button3  回到原位置
    }
}

}**

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值