using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace DMGY
{
public partial class DealMsg : Form
{
private static DealMsg dealMsg; //静态对象
private bool finished = false; //设置
private int screenWidth;//屏幕宽度
private int screenHeight;//屏幕高度
public DealMsg()
{
InitializeComponent();
// this.empSet = empSet;
}
/// <summary>
/// 窗体关闭-关闭时慢慢消失
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnQuit_Click(object sender, EventArgs e)
{
finished = true;
}
/// <summary>
/// 运行
/// </summary>
internal static void Run()
{
//获得客户列表
if (dealMsg==null || dealMsg.IsDisposed)
dealMsg = new DealMsg();
dealMsg.Show();
//显示信息
}
///窗体加载
private void DealMsg_Load(object sender, EventArgs e)
{
screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
//设置提示窗口坐标在屏幕可显示区域之外
this.SetDesktopLocation(screenWidth-this.Width, screenHeight-this.Height);
DataBind();
timer.Start();
}
///定时器 用于慢慢消失窗体
private void timer_Tick(object sender, EventArgs e)
{
if (!finished)
//如果提示窗口没有完全显示
{
//如果提示窗口的纵坐标与提示窗口的高度之和大于屏幕高度
if (Location.Y + Height >= screenHeight)
{
Location = new Point(Location.X, Location.Y - 2);
// this.SetDesktopLocation(screenWidth, screenHeight-1);
}
}
else
//如果提示窗口已经完成了显示,并且点击了确定按钮
{
//如果提示窗口没有完全从屏幕上消失
if (Location.Y < screenHeight)
{
Location = new Point(Location.X, Location.Y + 2);
//this.SetDesktopLocation(screenWidth, screenHeight + 1);
}
else
{
this.Close();
timer.Stop();
}
}
}
}
}
///主窗体
namespace DMGY
{
public partial class frmMain : Form
{
///控制定时器10分显示一次消息
private void TimerInfo_Tick(object sender, EventArgs e)
{
DealMsg.Run();
TimerInfo.Interval = 10 * 60*1000;//10分钟 提醒一次
}
}
}