找回密码
 入驻
搜索
查看: 407|回复: 17

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

[复制链接]
发表于 2007-10-11 23:18:24 | 显示全部楼层 |阅读模式
窗体四处飘动,字体颜色随机变换
hb.JPG

Debug.rar

9.75 KB, 下载次数: 16

发表于 2007-10-11 23:19:18 | 显示全部楼层
多学一门小技巧   不错
回复

使用道具 举报

 楼主| 发表于 2007-10-11 23:22:07 | 显示全部楼层
原帖由 ks453187387 于 2007-10-11 23:19 发表
多学一门小技巧   不错

对不起,我还没传代码。

  1. //这就帖
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Drawing.Drawing2D;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace HappyBirthdayToMe
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         Point p;
  15.         Random r;
  16.         int f;
  17.         Color[] color = { Color.Green,Color.Blue,
  18.             Color.Red,Color.Yellow,
  19.             Color.YellowGreen,
  20.             Color.Tomato,
  21.             Color.PowderBlue
  22.         };
  23.         public Form1()
  24.         {
  25.             InitializeComponent();
  26.             r = new Random();   
  27.         }
  28.         private void timer1_Tick(object sender, EventArgs e)
  29.         {
  30.             p.X += 5;
  31.             p.Y += 5;
  32.             this.Location = p;
  33.             if (this.Location.Y >= 150 && this.Location.X >= 300)
  34.             {
  35.                 this.timer1.Stop();
  36.                 this.timer2.Start();
  37.                 f = r.Next(0, 7);
  38.                 this.button1.ForeColor = color[f];
  39.             }
  40.         }
  41.         private void timer2_Tick(object sender, EventArgs e)
  42.         {
  43.             p.X -= 5;
  44.             p.Y += 5;
  45.             this.Location = p;
  46.             if (this.Location.Y >= 300 && this.Location.X <= 150)
  47.             {
  48.                 this.timer2.Stop();
  49.                 this.timer3.Start();
  50.                 f = r.Next(0, 7);
  51.                 this.button1.ForeColor = color[f];
  52.             }
  53.         }
  54.         private void timer3_Tick(object sender, EventArgs e)
  55.         {
  56.             p.X -= 5;
  57.             p.Y -= 5;
  58.             this.Location = p;
  59.             if (this.Location.Y <= 150 && this.Location.X <= 100)
  60.             {
  61.                 this.timer3.Stop();
  62.                 this.timer4.Start();
  63.                 f = r.Next(0, 7);
  64.                 this.button1.ForeColor = color[f];
  65.             }
  66.         }
  67.         private void timer4_Tick(object sender, EventArgs e)
  68.         {
  69.             p.X += 5;
  70.             p.Y -= 5;
  71.             this.Location = p;
  72.             if (this.Location.Y <= 100 && this.Location.X >= 150)
  73.             {
  74.                 this.timer4.Stop();
  75.                 this.timer1.Start();
  76.                 f = r.Next(0, 7);
  77.                 this.button1.ForeColor = color[f];
  78.             }
  79.         }
  80.         private void button1_Click(object sender, EventArgs e)
  81.         {
  82.             this.timer1.Stop();
  83.             this.timer2.Stop();
  84.             this.timer3.Stop();
  85.             this.timer4.Stop();
  86.         }
  87.         private void Form1_Load(object sender, EventArgs e)
  88.         {
  89.             p = new Point(150, 100);
  90.             this.Location = p;
  91.             this.timer1.Start();
  92.         }
  93.     }
  94. }
复制代码

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

使用道具 举报

发表于 2007-10-11 23:22:33 | 显示全部楼层
:1shocked1 :1shocked1 :1shocked1 ~~~~~~~~~~~~~~~~
回复

使用道具 举报

发表于 2007-10-11 23:24:04 | 显示全部楼层
今天发现是你生日了``请客``:shy1 :shy1
回复

使用道具 举报

发表于 2007-10-11 23:26:45 | 显示全部楼层
好难.........
回复

使用道具 举报

 楼主| 发表于 2007-10-11 23:27:00 | 显示全部楼层
原帖由 黑色幽默 于 2007-10-11 23:24 发表
今天发现是你生日了``请客``:shy1 :shy1

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

使用道具 举报

发表于 2007-10-11 23:28:16 | 显示全部楼层
好久不见了…… …… ……
回复

使用道具 举报

发表于 2007-10-11 23:29:57 | 显示全部楼层
原帖由 zkkpkk 于 2007-10-11 23:27 发表

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



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

使用道具 举报

发表于 2007-10-11 23:33:08 | 显示全部楼层
简单一句生日快乐````:titter1
回复

使用道具 举报

发表于 2007-10-12 07:39:18 | 显示全部楼层
原帖由 zkkpkk 于 2007-10-12 00:57 发表

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



不见你请我
回复

使用道具 举报

 楼主| 发表于 2007-10-12 13:53:42 | 显示全部楼层
原帖由 眼里只有¥ 于 2007-10-12 07:39 发表



不见你请我

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

使用道具 举报

 楼主| 发表于 2007-10-12 13:55:16 | 显示全部楼层
原帖由 鸭广梨 于 2007-10-11 23:29 发表



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

可以啊,不过现在这个代码没有优化过我认为太垃圾了,我怀疑用委托减少一下冗余好很多
回复

使用道具 举报

发表于 2007-10-12 13:55:28 | 显示全部楼层
:shy1 今晚在哪请客捏``?
回复

使用道具 举报

发表于 2007-10-12 14:00:26 | 显示全部楼层
:loveliness1
HAPPY BIRTHDAY !
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 入驻

本版积分规则

QQ|Archiver|手机版|小黑屋|思明论坛

GMT+8, 2024-9-28 13:20 , Processed in 0.067429 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表