| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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);
- }
- /// <summary>
- /// 如果ResultMessage为true或者false,则sType 为0的时候readonly 1为enable 2为visable 3为check
- /// </summary>
- /// <param name="control"></param>
- /// <param name="ResultMessage"></param>
- /// <param name="sType"></param>
- private void setFormMsg(Form fm)
- {
- if (fm.InvokeRequired)
- {
- Action<Form> action = new Action<Form>(setFormInfo);
- Invoke(action, new object[] { fm });
- }
- else
- {
- fm.Close();
- }
- }
- protected override void OnVisibleChanged(EventArgs e)
- {
- base.OnVisibleChanged(e);
- if (!IsHandleCreated)
- {
- this.Close();
- }
- }
- }
- }
|