109 lines
3.0 KiB
C#
109 lines
3.0 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Data;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Runtime.InteropServices;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
|
||
|
|
namespace JY.Inspection
|
||
|
|
{
|
||
|
|
public partial class FrmAlert : Form
|
||
|
|
{
|
||
|
|
|
||
|
|
public FrmAlert()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private FrmAlert.enmAction action; //当前窗体状态变量
|
||
|
|
private int x, y; //显示的坐标变量
|
||
|
|
//定义窗体状态枚举
|
||
|
|
private enum enmAction
|
||
|
|
{
|
||
|
|
wait,
|
||
|
|
start,
|
||
|
|
close
|
||
|
|
}
|
||
|
|
//定义弹窗类型枚举
|
||
|
|
public enum enmType
|
||
|
|
{
|
||
|
|
Success,
|
||
|
|
Warning,
|
||
|
|
Error,
|
||
|
|
Info
|
||
|
|
}
|
||
|
|
//外部访问该函数实现窗体的实现 传入显示信息,弹窗类型
|
||
|
|
public void ShowAlert(string msg, enmType type)
|
||
|
|
{
|
||
|
|
this.Opacity = 0.0;
|
||
|
|
this.StartPosition = FormStartPosition.Manual;
|
||
|
|
string fname;
|
||
|
|
|
||
|
|
for (int i = 1; i < 10; i++)
|
||
|
|
{
|
||
|
|
fname = "alert" + i.ToString();
|
||
|
|
FrmAlert frm = (FrmAlert)Application.OpenForms[fname];
|
||
|
|
|
||
|
|
if (frm == null)
|
||
|
|
{
|
||
|
|
this.Name = fname;
|
||
|
|
this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15;
|
||
|
|
this.y = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 5 * i;
|
||
|
|
this.Location = new Point(this.x, this.y);
|
||
|
|
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width - 5;
|
||
|
|
|
||
|
|
switch (type)
|
||
|
|
{
|
||
|
|
case enmType.Success:
|
||
|
|
this.pictureBox1.Image = JY.Inspection.Properties.Resources.success;
|
||
|
|
this.BackColor = Color.SeaGreen;
|
||
|
|
break;
|
||
|
|
case enmType.Error:
|
||
|
|
this.pictureBox1.Image = JY.Inspection.Properties.Resources.error;
|
||
|
|
this.BackColor = Color.DarkRed;
|
||
|
|
break;
|
||
|
|
case enmType.Info:
|
||
|
|
this.pictureBox1.Image = JY.Inspection.Properties.Resources.info;
|
||
|
|
this.BackColor = Color.RoyalBlue;
|
||
|
|
break;
|
||
|
|
case enmType.Warning:
|
||
|
|
this.pictureBox1.Image = JY.Inspection.Properties.Resources.warning;
|
||
|
|
this.BackColor = Color.DarkOrange;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
this.lblMsg.Text = msg;
|
||
|
|
|
||
|
|
this.Show();
|
||
|
|
//this.action = enmAction.start;
|
||
|
|
this.timer1.Interval = 2000;
|
||
|
|
this.timer1.Start();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//关闭窗体调用
|
||
|
|
public void ShowClose()
|
||
|
|
{
|
||
|
|
timer1.Interval = 1;
|
||
|
|
action = enmAction.close;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|