122 lines
4.4 KiB
C#
122 lines
4.4 KiB
C#
using CleanMachine.Model.BAS;
|
||
using Krypton.Toolkit;
|
||
using NX_LogUtility;
|
||
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;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
|
||
namespace CleanMachineHMI.frmChild
|
||
{
|
||
public partial class frmPopupWarningMsg : KryptonForm
|
||
{
|
||
public frmPopupWarningMsg()
|
||
{
|
||
InitializeComponent();
|
||
RefreshFrmHost = new dlgRefreshFrmHost(SetDataGridView);
|
||
}
|
||
public delegate void dlgRefreshFrmHost();
|
||
public static dlgRefreshFrmHost RefreshFrmHost;
|
||
public static List<Warning> warnLst = new List<Warning>();
|
||
private void frmPopupWarningMsg_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
private void SetDataGridView()
|
||
{
|
||
try
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
if (warnLst.Count > 0)
|
||
{
|
||
kryptonDataGridView1.Rows.Clear();
|
||
foreach (Warning item in warnLst)
|
||
{
|
||
int index = kryptonDataGridView1.Rows.Add();
|
||
kryptonDataGridView1.Rows[index].Cells[0].Value = index + 1;
|
||
kryptonDataGridView1.Rows[index].Cells[1].Value = item.WarningMessage.ToString();
|
||
}
|
||
}
|
||
}));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteLog($"刷新报警信息发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||
}
|
||
}
|
||
private void frmPopupWarningMsg_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
//try
|
||
//{
|
||
// Task.Run(async delegate
|
||
// {
|
||
// if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||
// {
|
||
// LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||
// }
|
||
// await Task.Delay(100);
|
||
// GlobalHelper.PopupWarningMsgForm = null;
|
||
// });
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// LogHelper.WriteLog($"关闭报警信息弹出页面发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||
//}
|
||
}
|
||
|
||
private void frmPopupWarningMsg_FormClosed(object sender, FormClosedEventArgs e)
|
||
{
|
||
//if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||
//{
|
||
// LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||
//}
|
||
}
|
||
|
||
private void kryptonButton1_Click(object sender, EventArgs e)
|
||
{
|
||
kryptonButton1.Enabled = false;
|
||
try
|
||
{
|
||
Task.Run(async delegate
|
||
{
|
||
if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||
{
|
||
LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||
}
|
||
await Task.Delay(500);
|
||
Global.PopupWarningMsgForm = null;
|
||
this.Close();
|
||
});
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteLog($"关闭报警信息弹出页面发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||
//kryptonButton1.Enabled = true;
|
||
}
|
||
//kryptonButton1.Enabled = true;
|
||
}
|
||
[DllImport("user32.dll")]
|
||
public static extern bool ReleaseCapture();
|
||
|
||
[DllImport("user32.dll")]
|
||
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
||
public const int WM_SYSCOMMAND = 0x0112;
|
||
public const int SC_MOVE = 0xF010;
|
||
public const int HTCAPTION = 0x0002;
|
||
public bool isFrmStateNormal = true;
|
||
private void kryptonGroupBox1_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
ReleaseCapture();
|
||
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
|
||
}
|
||
}
|
||
}
|