DotNetBar,它包含很多漂亮的控件,功能也委实强大
适用于WinForm编程,我这有一个破解版的 (点击下载)
右边是安装完成后我的。NET工具箱中出现的相关控件
这里我要说的小程序玩继承
第一步:新建一个WinForm工程,相信这是很简单的啦
第二步:把自动生成的窗体删除
第三步:添加DevComponents.DotNetBar的dll引用
第四步:添加继承的窗体(自定义你窗体的名称),
选择要继承的组件为Ballon如下图所示
第五步:初始化你的窗体
要说明的是:你的窗体继承自Ballon所有具有了Ballon的属性,哈哈,是不是很好玩呢?
那就意味着,你的窗体可以像Ballon那样完成提醒的功能,而且提醒完之后,生命自动终止
还有很多更神奇的功能先不说,我们先来吧这个程序完成吧……
它是支持可视化效果的,你的任何修改马上可以在Form里看到,你当然也可以像编其他任何
WinForm程序一样,往窗体里拖你的控件,就和操作其他窗体一样。
你想让它干什么,就在给它编什么样的代码,提醒你的日程安排、纪念日等等
这里我做的是让它提醒我和女朋友在一起的日子多少天
代码和简单注释如下:
1
using
System;
2 using System.Collections;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Windows.Forms;
6 using DevComponents.DotNetBar;
7
8 namespace EveryDayNotice
9 {
10 public class EveryDayNotice : DevComponents.DotNetBar.Balloon
11 {
12 private System.Windows.Forms.Label label1;
13 private System.Windows.Forms.Timer timer1;
14 private System.ComponentModel.IContainer components = null;
15
16 public EveryDayNotice()
17 {
18 // 该调用是 Windows 窗体设计器所必需的。
19 InitializeComponent();
20 }
21
22
23 protected override void Dispose( bool disposing )
24 {
25 if( disposing )
26 {
27 if (components != null)
28 {
29 components.Dispose();
30 }
31 }
32 base.Dispose( disposing );
33 }
34
35 [STAThread]
36 static void Main()
37 {
38 Application.Run(new EveryDayNotice());
39 }
40
41 //我的获取提醒时间的简单函数
42 public int GetDayNotice()
43 {
44 DateTime date1 = Convert.ToDateTime(Convert.ToDateTime("2005-4-6"));
45 DateTime date2 = DateTime.Now.Date;
46
47 System.TimeSpan diff1 = date1.Subtract(Convert.ToDateTime("2005-6-25"));
48 System.TimeSpan diff2 = date2.Subtract(Convert.ToDateTime("2005-6-25"));
49 System.TimeSpan diff3 = diff2 - diff1;
50 return diff3.Days;
51 }
52
53 设计器生成的代码#region 设计器生成的代码
54 /**//// <summary>
55 /// 设计器支持所需的方法 - 说明:根据你拖的控件,修改的属性自动生成
56 /// </summary>
57 private void InitializeComponent()
58 {
59 this.components = new System.ComponentModel.Container();
60 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EveryDayNotice));
61 this.label1 = new System.Windows.Forms.Label();
62 this.timer1 = new System.Windows.Forms.Timer(this.components);
63 this.SuspendLayout();
64 //
65 // label1
66 //
67 this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
68 this.label1.ForeColor = System.Drawing.Color.Red;
69 this.label1.Location = new System.Drawing.Point(48, 72);
70 this.label1.Name = "label1";
71 this.label1.Size = new System.Drawing.Size(240, 48);
72 this.label1.TabIndex = 0;
73 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
74 //
75 // timer1
76 //
77 this.timer1.Enabled = true;
78 this.timer1.Interval = 1000;
79 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
80 //
81 // EveryDayNotice
82 //
83 this.AlertAnimationDuration = 100;
84 this.AutoScaleBaseSize = new System.Drawing.Size(7, 14);
85 this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(207)), ((System.Byte)(221)), ((System.Byte)(244)));
86 this.BackColor2 = System.Drawing.Color.White;
87 this.CaptionColor = System.Drawing.Color.Red;
88 this.CaptionFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
89 this.CaptionImage = ((System.Drawing.Image)(resources.GetObject("$this.CaptionImage")));
90 this.CaptionText = "I love you for ever";
91 this.ClientSize = new System.Drawing.Size(355, 152);
92 this.CloseButtonHot = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonHot")));
93 this.CloseButtonNormal = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonNormal")));
94 this.CloseButtonPressed = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonPressed")));
95 this.Controls.Add(this.label1);
96 this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
97 this.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(102)), ((System.Byte)(114)), ((System.Byte)(196)));
98 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
99 this.Location = new System.Drawing.Point(1024, 768);
100 this.Name = "EveryDayNotice";
101 this.Opacity = 0.8;
102 this.Style = DevComponents.DotNetBar.eBallonStyle.Alert;
103 this.ResumeLayout(false);
104
105 }
106 #endregion
107
108
109 //弹出提箱气球的函数
110 public void Myshow()
111 {
112 label1.Text = "今天是我们在一起第 "+GetDayNotice()+" 天";
113 Rectangle r=Screen.GetWorkingArea(this);
114 //设置出现位置
115 this.Location=new Point(r.Right-this.Width,r.Bottom-this.Height);
116 //必须的,自动Dispose
117 this.AutoClose=true;
118 //自动消失的时间
119 this.AutoCloseTimeOut=5;
120 //弹出动画,这里是从底往上
121 this.AlertAnimation=eAlertAnimation.BottomToTop;
122 //动画时间
123 this.AlertAnimationDuration=300;
124 this.Show(false);
125 }
126
127 //注:Timeer控件让它在一定时间期之后发生一次Show()
128 private void timer1_Tick(object sender, System.EventArgs e)
129 {
130 timer1.Stop();
131 timer1.Enabled=false;
132 Myshow();
133 }
134 }
135}
136
137
2 using System.Collections;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Windows.Forms;
6 using DevComponents.DotNetBar;
7
8 namespace EveryDayNotice
9 {
10 public class EveryDayNotice : DevComponents.DotNetBar.Balloon
11 {
12 private System.Windows.Forms.Label label1;
13 private System.Windows.Forms.Timer timer1;
14 private System.ComponentModel.IContainer components = null;
15
16 public EveryDayNotice()
17 {
18 // 该调用是 Windows 窗体设计器所必需的。
19 InitializeComponent();
20 }
21
22
23 protected override void Dispose( bool disposing )
24 {
25 if( disposing )
26 {
27 if (components != null)
28 {
29 components.Dispose();
30 }
31 }
32 base.Dispose( disposing );
33 }
34
35 [STAThread]
36 static void Main()
37 {
38 Application.Run(new EveryDayNotice());
39 }
40
41 //我的获取提醒时间的简单函数
42 public int GetDayNotice()
43 {
44 DateTime date1 = Convert.ToDateTime(Convert.ToDateTime("2005-4-6"));
45 DateTime date2 = DateTime.Now.Date;
46
47 System.TimeSpan diff1 = date1.Subtract(Convert.ToDateTime("2005-6-25"));
48 System.TimeSpan diff2 = date2.Subtract(Convert.ToDateTime("2005-6-25"));
49 System.TimeSpan diff3 = diff2 - diff1;
50 return diff3.Days;
51 }
52
53 设计器生成的代码#region 设计器生成的代码
54 /**//// <summary>
55 /// 设计器支持所需的方法 - 说明:根据你拖的控件,修改的属性自动生成
56 /// </summary>
57 private void InitializeComponent()
58 {
59 this.components = new System.ComponentModel.Container();
60 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EveryDayNotice));
61 this.label1 = new System.Windows.Forms.Label();
62 this.timer1 = new System.Windows.Forms.Timer(this.components);
63 this.SuspendLayout();
64 //
65 // label1
66 //
67 this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
68 this.label1.ForeColor = System.Drawing.Color.Red;
69 this.label1.Location = new System.Drawing.Point(48, 72);
70 this.label1.Name = "label1";
71 this.label1.Size = new System.Drawing.Size(240, 48);
72 this.label1.TabIndex = 0;
73 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
74 //
75 // timer1
76 //
77 this.timer1.Enabled = true;
78 this.timer1.Interval = 1000;
79 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
80 //
81 // EveryDayNotice
82 //
83 this.AlertAnimationDuration = 100;
84 this.AutoScaleBaseSize = new System.Drawing.Size(7, 14);
85 this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(207)), ((System.Byte)(221)), ((System.Byte)(244)));
86 this.BackColor2 = System.Drawing.Color.White;
87 this.CaptionColor = System.Drawing.Color.Red;
88 this.CaptionFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
89 this.CaptionImage = ((System.Drawing.Image)(resources.GetObject("$this.CaptionImage")));
90 this.CaptionText = "I love you for ever";
91 this.ClientSize = new System.Drawing.Size(355, 152);
92 this.CloseButtonHot = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonHot")));
93 this.CloseButtonNormal = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonNormal")));
94 this.CloseButtonPressed = ((System.Drawing.Image)(resources.GetObject("$this.CloseButtonPressed")));
95 this.Controls.Add(this.label1);
96 this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
97 this.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(102)), ((System.Byte)(114)), ((System.Byte)(196)));
98 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
99 this.Location = new System.Drawing.Point(1024, 768);
100 this.Name = "EveryDayNotice";
101 this.Opacity = 0.8;
102 this.Style = DevComponents.DotNetBar.eBallonStyle.Alert;
103 this.ResumeLayout(false);
104
105 }
106 #endregion
107
108
109 //弹出提箱气球的函数
110 public void Myshow()
111 {
112 label1.Text = "今天是我们在一起第 "+GetDayNotice()+" 天";
113 Rectangle r=Screen.GetWorkingArea(this);
114 //设置出现位置
115 this.Location=new Point(r.Right-this.Width,r.Bottom-this.Height);
116 //必须的,自动Dispose
117 this.AutoClose=true;
118 //自动消失的时间
119 this.AutoCloseTimeOut=5;
120 //弹出动画,这里是从底往上
121 this.AlertAnimation=eAlertAnimation.BottomToTop;
122 //动画时间
123 this.AlertAnimationDuration=300;
124 this.Show(false);
125 }
126
127 //注:Timeer控件让它在一定时间期之后发生一次Show()
128 private void timer1_Tick(object sender, System.EventArgs e)
129 {
130 timer1.Stop();
131 timer1.Enabled=false;
132 Myshow();
133 }
134 }
135}
136
137
哈哈,是不是很好玩呢?
.DotNetBar是个很爽的东西,推荐给大家……