⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shengrichengxu.txt

📁 自己编写的一个c#的程序,是一个生日程序
💻 TXT
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace HappyBirthdayToMe
{
    public partial class Form1 : Form
    {
        Point p;
        Random r;
        int f;
        Color[] color = { Color.Green,Color.Blue,
            Color.Red,Color.Yellow,
            Color.YellowGreen,
            Color.Tomato,
            Color.PowderBlue
        };
        public Form1()
        {
            InitializeComponent();
            r = new Random();    
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            p.X += 5;
            p.Y += 5;
            this.Location = p;
            if (this.Location.Y >= 150 && this.Location.X >= 300)
            {
                this.timer1.Stop();
                this.timer2.Start();
                f = r.Next(0, 7);
                this.button1.ForeColor = color[f];
            }
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            p.X -= 5;
            p.Y += 5;
            this.Location = p;
            if (this.Location.Y >= 300 && this.Location.X <= 150)
            {
                this.timer2.Stop();
                this.timer3.Start();
                f = r.Next(0, 7);
                this.button1.ForeColor = color[f];
            }
        }
        private void timer3_Tick(object sender, EventArgs e)
        {
            p.X -= 5;
            p.Y -= 5;
            this.Location = p;
            if (this.Location.Y <= 150 && this.Location.X <= 100)
            {
                this.timer3.Stop();
                this.timer4.Start();
                f = r.Next(0, 7);
                this.button1.ForeColor = color[f];
            }
        }
        private void timer4_Tick(object sender, EventArgs e)
        {
            p.X += 5;
            p.Y -= 5;
            this.Location = p;
            if (this.Location.Y <= 100 && this.Location.X >= 150)
            {
                this.timer4.Stop();
                this.timer1.Start();
                f = r.Next(0, 7);
                this.button1.ForeColor = color[f];
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.timer1.Stop();
            this.timer2.Stop();
            this.timer3.Stop();
            this.timer4.Stop();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            p = new Point(150, 100);
            this.Location = p;
            this.timer1.Start();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -