using Common; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Media; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CarMonitor { public partial class frmMsgInfo : Form { private static frmMsgInfo frm = null; private static frmMonitor frmP; public static frmMsgInfo CreateInstrance(frmMonitor frmMonitoring) { if (frm == null) { frm = new frmMsgInfo(); } frmP = frmMonitoring; return frm; } public frmMsgInfo() { InitializeComponent(); } string rk_CurPath = Application.StartupPath; //System.Environment.CurrentDirectory;//获取到当前路径 SoundPlayer play_ls = null; public void setLbTxt(string pointName) { lbPoint.Text = pointName; } private void frmMsgInfo_Load(object sender, EventArgs e) { try { play_ls = new SoundPlayer(rk_CurPath + "\\Sound\\7887.wav"); } catch (Exception ex) { } finally { timer1.Start(); } } private void timer1_Tick(object sender, EventArgs e) { play_ls.Play(); } private void frmMsgInfo_FormClosing(object sender, FormClosingEventArgs e) { try { if (play_ls != null) { play_ls.Stop(); } } catch (Exception ex) { } finally { frmP.bMsgOpen = false; frm = null; timer1.Stop(); PbCacheMonitor.frmMsgClosingTime = DateTime.Now; } } public void CloseFrm() { this.Close(); } public void setFrmNull() { setFormInfo(frm); } public void setFormInfo(Form fm) { setFormMsg(fm); } /// /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable 3为check /// /// /// /// private void setFormMsg(Form fm) { if (fm.InvokeRequired) { Action
action = new Action(setFormInfo); Invoke(action, new object[] { fm }); } else { fm.Close(); } } protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (!IsHandleCreated) { this.Close(); } } } }