渐隐藏的窗口。

using System;

using System.ComponentModel;

using System.Drawing;

using System.Resources;

using System.Windows.Forms;

using Microsoft.Win32;

using Message = com.Message;

 

namespace TrafficClient

{

     /// <summary>

     /// Summary description for Reminder.

     /// </summary>

     public class Reminder : Form

     {

         private Timer CloseTimer;

         private IContainer components;

         private PictureBox CloseWindow;

         private LinkLabel ShowMainWindow;

 

         private int StartOpacity;

         private Label SMSHead;

         private Label SMSContent;

         private Form MainWindow;

         private LinkLabel ReplyMessage;

         private LinkLabel StopAnimation;

 

         private bool AutoHide;

 

         public Reminder( Message message, Form parent ) : this(message, parent, true) {}

 

         public Reminder( Message message, Form parent, bool autoHide )

         {

              //

              // Required for Windows Form Designer support

              //

              InitializeComponent();

 

              //

              // TODO: Add any constructor code after InitializeComponent call

              //

              this.SMSHead.Text = message.UserPhone + "/n" + message.HappenTime;

              this.SMSContent.Text = message.Content;

 

              this.AutoHide = autoHide;

 

              this.MainWindow = parent;

         }

 

         /// <summary>

         /// Clean up any resources being used.

         /// </summary>

         protected override void Dispose( bool disposing )

         {

              if( disposing )

              {

                   if(components != null)

                   {

                       components.Dispose();

                   }

              }

              base.Dispose( disposing );

         }

 

         #region Windows Form Designer generated code

         /// <summary>

         /// Required method for Designer support - do not modify

         /// the contents of this method with the code editor.

         /// </summary>

         private void InitializeComponent()

         {

              this.components = new Container();

              ResourceManager resources = new ResourceManager(typeof(Reminder));

              this.SMSHead = new Label();

              this.SMSContent = new Label();

              this.ShowMainWindow = new LinkLabel();

              this.CloseTimer = new Timer(this.components);

              this.CloseWindow = new PictureBox();

              this.ReplyMessage = new LinkLabel();

              this.StopAnimation = new LinkLabel();

              this.SuspendLayout();

              //

              // SMSHead

              //

              this.SMSHead.Location = new Point(16, 8);

              this.SMSHead.Name = "SMSHead";

              this.SMSHead.Size = new Size(440, 56);

              this.SMSHead.TabIndex = 0;

              //

              // SMSContent

              //

              this.SMSContent.Font = new Font("STZhongsong", 16F , FontStyle.Bold, GraphicsUnit.Point, ((Byte)(134)));

              this.SMSContent.Location = new Point(16, 80);

              this.SMSContent.Name = "SMSContent";

              this.SMSContent.Size = new Size(472, 232);

              this.SMSContent.TabIndex = 1;

              //

              // ShowMainWindow

              //

              this.ShowMainWindow.Location = new Point(440, 320);

              this.ShowMainWindow.Name = "ShowMainWindow";

              this.ShowMainWindow.Size = new Size(56, 16);

              this.ShowMainWindow.TabIndex = 2;

              this.ShowMainWindow.TabStop = true;

              this.ShowMainWindow.Text = "显示界面";

              this.ShowMainWindow.LinkClicked += new LinkLabelLinkClickedEventHandler(this.ShowMainWindow_LinkClicked);

              //

              // CloseTimer

              //

              this.CloseTimer.Interval = 50;

              this.CloseTimer.Tick += new EventHandler(this.CloseTimer_Tick);

              //

              // CloseWindow

              //

              this.CloseWindow.Image = ((Image)(resources.GetObject("CloseWindow.Image")));

              this.CloseWindow.Location = new Point(472, 0);

              this.CloseWindow.Name = "CloseWindow";

              this.CloseWindow.Size = new Size(32, 32);

              this.CloseWindow.TabIndex = 3;

              this.CloseWindow.TabStop = false;

              this.CloseWindow.Click += new EventHandler(this.CloseWindow_Click);

              //

              // ReplyMessage

              //

              this.ReplyMessage.Location = new Point(8, 320);

              this.ReplyMessage.Name = "ReplyMessage";

              this.ReplyMessage.Size = new Size(56, 16);

              this.ReplyMessage.TabIndex = 4;

              this.ReplyMessage.TabStop = true;

              this.ReplyMessage.Text = "回复信息";

              //

              // StopAnimation

              //

              this.StopAnimation.Location = new Point(360, 320);

              this.StopAnimation.Name = "StopAnimation";

              this.StopAnimation.Size = new Size(56, 16);

              this.StopAnimation.TabIndex = 5;

              this.StopAnimation.TabStop = true;

              this.StopAnimation.Text = "停止关闭";

              this.StopAnimation.LinkClicked += new LinkLabelLinkClickedEventHandler(this.StopAnimation_LinkClicked);

              //

              // Reminder

              //

              this.AutoScaleBaseSize = new Size(5, 13);

              this.BackColor = SystemColors.Info;

              this.ClientSize = new Size(502, 342);

              this.ControlBox = false;

              this.Controls.Add(this.StopAnimation);

              this.Controls.Add(this.ReplyMessage);

              this.Controls.Add(this.CloseWindow);

              this.Controls.Add(this.ShowMainWindow);

              this.Controls.Add(this.SMSContent);

              this.Controls.Add(this.SMSHead);

              this.FormBorderStyle = FormBorderStyle.FixedSingle;

              this.Icon = ((Icon)(resources.GetObject("$this.Icon")));

              this.MaximizeBox = false;

              this.MinimizeBox = false;

              this.Name = "Reminder";

              this.ShowInTaskbar = false;

              this.StartPosition = FormStartPosition.CenterScreen;

              this.TopMost = true;

              this.Load += new EventHandler(this.Reminder_Load);

              this.ResumeLayout(false);

 

         }

         #endregion

 

         private void CloseTimer_Tick(object sender, EventArgs e)

         {

              DecreaseOpacity();

         }

 

         private void DecreaseOpacity()

         {

              this.StartOpacity --;

              this.Opacity = (double) this.StartOpacity / 100;

 

              if (this.StartOpacity == 0)

              this.Dispose();

         }

 

         private void Reminder_Load(object sender, EventArgs e)

         {

              if (this.AutoHide)

                   this.CloseTimer.Start();

 

              this.InitStartOpacity();

         }

 

         private void CloseWindow_Click(object sender, EventArgs e)

         {

              this.Dispose();

         }

 

         private void ShowMainWindow_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

         {

              this.MainWindow.Show();

         }

 

         private void StopAnimation_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

         {

              this.CloseTimer.Stop();

 

              this.InitStartOpacity();

         }

 

         private void InitStartOpacity()

         {

              this.StartOpacity = Int32.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE/TrafficClient").GetValue("ReminderOpacity", "50").ToString());

 

              this.Opacity = (double) this.StartOpacity / 100;

         }

 

     }

}

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值