📄 msn.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace GzglClient.Froms
{
/// <summary>
/// Msn 的摘要说明。
/// </summary>
public class Msn : 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.PictureBox pictureBox1;
private System.ComponentModel.IContainer components;
private int heightMax,widthMax;
private int staytime = 5000;//添加一个StayTime属性设置窗体停留时间(默认为5秒)
public Msn()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Msn));
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.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
this.label1.Location = new System.Drawing.Point(0, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(171, 30);
this.label1.TabIndex = 0;
this.label1.Text = "大家好,不错1";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 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);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(171, 65);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// Msn
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(171, 65);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Msn";
this.ShowInTaskbar = false;
this.Text = "Form2";
this.TopMost = true;
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
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 - 27);//WorkingArea为Windows桌面的工作区
//screen.WorkingArea.Width,screen.WorkingArea.Height相对于屏幕右下角的距离
this.timer2.Interval = staytime;
}
/// <summary>
/// 停留秒数
/// </summary>
public int StayTime
{
set{staytime = value;}
get{return staytime;}
}
/// <summary>
/// 高度
/// </summary>
public int HeightMax
{
set{heightMax = value;}
get{return heightMax;}
}
/// <summary>
/// 宽度
/// </summary>
public int WidthMax
{
set{widthMax = value;}
get{return widthMax;}
}
/// <summary>
/// 显示
/// </summary>
public void ScrollShow()
{
this.Width = widthMax;
this.Height = 0;
this.Show();
this.timer1.Enabled = true;
}
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();
}
}
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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -