using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication2
{
/// <summary>
/// Form2 的摘要描述。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Timer timer3;
private System.Windows.Forms.Timer timer4;
private System.ComponentModel.IContainer components;
[STAThread]
static void Main()
{
Application.Run(new Form2());
}
public Form2()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
Init();
}
private void Init()
{
this.HeightMax = 120;//窗體滾動的高度
this.WidthMax = 148;//窗體滾動的寬度
this.ScrollShow();
}
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form 設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.timer4 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Teal;
this.label1.Font = new System.Drawing.Font("新細明體", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(24, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 24);
this.label1.TabIndex = 0;
this.label1.Text = "Welcome";
//
// timer1
//
this.timer1.Interval = 10;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer2
//
this.timer2.Interval = 10;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// timer3
//
this.timer3.Interval = 10;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// timer4
//
this.timer4.Interval = 10;
this.timer4.Tick += new System.EventHandler(this.timer4_Tick);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.BackColor = System.Drawing.Color.Teal;
this.ClientSize = new System.Drawing.Size(152, 136);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form2";
this.ShowInTaskbar = false;
this.Text = "Form2";
this.TopMost = true;
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
private int heightMax, widthMax;
public int HeightMax
{
set
{
heightMax = value;
}
get
{
return heightMax;
}
}
public int WidthMax
{
set
{
widthMax = value;
}
get
{
return widthMax;
}
}
public void ScrollShow()
{
this.Width = widthMax;
this.Height = 0;
this.Show();
this.timer1.Enabled = true;
}
public int StayTime = 5000;
public int StayTime = 20000;
private void ScrollUp()
{
if(Height < heightMax)
{
this.Height += 3;
this.Location = new Point(this.Location.X, this.Location.Y - 3);
}
else
{
this.timer1.Enabled = false;
this.timer2.Enabled = true;
}
}
private void ScrollDown()
{
if(Height > 3)
{
this.Height -= 3;
this.Location = new Point(this.Location.X, this.Location.Y + 3);
}
else
{
this.timer3.Enabled = false;
//this.Close();
this.timer4.Enabled = true;
}
}
private void timer1_Tick(object sender, System.EventArgs e)
{
ScrollUp();
}
private void timer2_Tick(object sender, System.EventArgs e)
{
timer2.Enabled = false;
timer3.Enabled = true;
}
private void timer3_Tick(object sender, System.EventArgs e)
{
ScrollDown();
}
private void timer4_Tick(object sender, System.EventArgs e)
{
timer4.Enabled=false;
timer1.Enabled=true;
}
private void Form2_Load(object sender, System.EventArgs e)
{
Screen[] screens = Screen.AllScreens;
Screen screen = screens[0];//獲取屏幕變量
this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34);//WorkingArea為Windows桌面的工作區
this.timer2.Interval = StayTime;
this.timer4.Interval = StayTime;
}
}
}
浙公网安备 33010602011771号