zkkpkk 发表于 2007-10-11 23:18:24

生日!写个程序祝福自己!HappyBirthdayToMe

窗体四处飘动,字体颜色随机变换

ks453187387 发表于 2007-10-11 23:19:18

多学一门小技巧   不错

zkkpkk 发表于 2007-10-11 23:22:07

原帖由 ks453187387 于 2007-10-11 23:19 发表 http://172.16.1.236/images/common/back.gif
多学一门小技巧   不错
对不起,我还没传代码。

//这就帖
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;
            }
      }
      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;
            }
      }
      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;
            }
      }
      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;
            }
      }
      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();
      }
    }
}

本来想用GDI画的但是好难处理重绘问题,后来改了

444494444 发表于 2007-10-11 23:22:33

:1shocked1 :1shocked1 :1shocked1 ~~~~~~~~~~~~~~~~

黑色幽默 发表于 2007-10-11 23:24:04

今天发现是你生日了``请客``:shy1 :shy1

鸭广梨 发表于 2007-10-11 23:26:45

好难.........

zkkpkk 发表于 2007-10-11 23:27:00

原帖由 黑色幽默 于 2007-10-11 23:24 发表 http://172.16.1.236/images/common/back.gif
今天发现是你生日了``请客``:shy1 :shy1
明晚,嘘..........别招太多人,我穷

ˊ血滴 发表于 2007-10-11 23:28:16

好久不见了…… …… ……

鸭广梨 发表于 2007-10-11 23:29:57

原帖由 zkkpkk 于 2007-10-11 23:27 发表 http://172.16.1.236/images/common/back.gif

明晚,嘘..........别招太多人,我穷


我去问你怎么弄这个东西可以不:loveliness1

316998731 发表于 2007-10-11 23:33:08

简单一句生日快乐````:titter1

眼里只有¥ 发表于 2007-10-12 07:39:18

原帖由 zkkpkk 于 2007-10-12 00:57 发表 http://172.16.1.236/images/common/back.gif

明晚,嘘..........别招太多人,我穷


不见你请我

zkkpkk 发表于 2007-10-12 13:53:42

原帖由 眼里只有¥ 于 2007-10-12 07:39 发表 http://172.16.1.236/images/common/back.gif



不见你请我
今晚你也可以去嘛,本来我过生日很随便的加上没钱请,我之所以请那两个朋友是因为大一刚来的时候我们约定到毕业前一定学有所成,这次是汇报时间~~~~~~

zkkpkk 发表于 2007-10-12 13:55:16

原帖由 鸭广梨 于 2007-10-11 23:29 发表 http://172.16.1.236/images/common/back.gif



我去问你怎么弄这个东西可以不:loveliness1
可以啊,不过现在这个代码没有优化过我认为太垃圾了,我怀疑用委托减少一下冗余好很多

黑色幽默 发表于 2007-10-12 13:55:28

:shy1 今晚在哪请客捏``?

喜新不厌旧 发表于 2007-10-12 14:00:26

:loveliness1
HAPPY BIRTHDAY !
页: [1] 2
查看完整版本: 生日!写个程序祝福自己!HappyBirthdayToMe