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;
}
}
}