using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DBFactory; using System.Net.Sockets; using System.Threading; using System.Linq; using Microsoft.VisualBasic; using System.IO.Ports; using System.Resources; using System.Drawing.Drawing2D; namespace wcfControlMonitorClient { /// <summary> /// Creator:Richard.liu /// µ÷¶È³ÌÐòÖ÷´°¿Ú /// </summary> public partial class FrmControlMonitor : WeifenLuo.WinFormsUI.Docking.DockContent { StringBuilder sql = new StringBuilder(); Model.MDevice devinfo; FrmDeviceStatus _deviceStatus = new FrmDeviceStatus(); DBFactory.DBOperator dbo = CStaticClass.dbo; DBFactory.DBOperator dbo1 = new DBFactory.DBOperator(); private static FrmControlMonitor _formInstance; public static FrmControlMonitor FormInstance { get { if (_formInstance == null) { _formInstance = new FrmControlMonitor(); } return _formInstance; } set { _formInstance = value; } } public FrmControlMonitor() { InitializeComponent(); //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ////É趨×ÖÌå´óСΪ12px //this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); _formInstance = this; } #region ·½·¨ public void FlashPanit(string obj, bool visible) { this.Controls[obj].Visible = visible; } public void FlashPanit(string obj, Image backgroundImage) { this.Controls[obj].BackgroundImage = backgroundImage; } public void FlashPanit(string obj, ImageLayout backgroundImageLayout) { this.Controls[obj].BackgroundImageLayout = backgroundImageLayout; } public void FlashPanit(string obj, int top, int left) { this.Controls[obj].Top = top; this.Controls[obj].Left = left; } public void FlashPanit(string obj, string text, bool append) { if (append == true) { this.Controls[obj].Text += text; } else { this.Controls[obj].Text = text; } } public string GetObjectText(string obj) { return this.Controls[obj].Text; } public void MonitorRefresh(object dataSource) { #region Added by DingXiaoxu for Dock TaskList on 20101219 FrmTaskList.FormInstance.MonitorRefresh(dataSource); #endregion //this.dgvMonitor.DataSource = dataSource; ////20100108 //dataSource = null; } public void ManagerRefresh(object dataSource) { #region Added by DingXiaoxu for Dock TaskList on 20101219 FrmTaskList.FormInstance.ManagerRefresh(dataSource); #endregion //this.dgvManager.DataSource = dataSource; ////20100108 //dataSource = null; } #endregion protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000;//WS_CLIPCHILDREN Á½¸ö´°Ìåµþ¼Óʱ£¬Öصþ²¿·Ö²»ÖØ»æ return cp; } } private void timerFlash_Tick(object sender, EventArgs e) { string[] DS; char[] dd = new char[1] { '.' }; Model.MDevice device; TimeSpan ts = DateTime.Now.TimeOfDay; DataView dv; DataView dvJY; this.SuspendLayout(); //richard.liu20140806 try { #region if (CStaticClass.WCFOK == true) { sql.Remove(0, sql.Length);//richard.liu20140806 sql.Append("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_LockedState = - 1) "); dvJY = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//richard.liu20140806 dvJY.Sort = "F_DeviceIndex"; //// ³ÉÆ·¿â¶Ñ¶â»ú Button stackcp1 = this.rxDj1; Button stackcp2 = this.rxDj2; //Button stackcp3 = bt11003; //Button stackcp4 = bt11004; //Button stackcp5 = bt11005; //Button stackcp9 = bt11009; //Button stackcp10 = bt11010; //Button stackcp11 = bt11011; //Button stackcp12 = bt11012; //// ³ÉÆ·¶Ñ¶â»úÔØÎï TextBox twcp1 = this.rxDjW1; TextBox twcp2 = this.rxDjW2; //TextBox twcp3 = t11003; //TextBox twcp4 = t11004; //TextBox twcp5 = t11005; int smallbarcode = 0; int bigbarcode = 0; int stackInitX = 0; double StackcpInitXX = 0; //Panel pp = plAccessorial1; Panel pRxkS = RxkPl; double startXadd = 0;//µÚÒ»ÁÐͼÉÏ×ø±ê double startDadd = 0;//µÚÒ»ÁÐͼÉÏ×ø±ê double kcpX = 0;//ͼÉÏ»õ¼Ü³¤¶È/С°ü»õ¼Üʵ¼Ê³¤¶È double kcpD = 0;//ͼÉÏ»õ¼Ü³¤¶È/¶Ö°ü»õ¼Üʵ¼Ê³¤¶È double startcode2 = 0;//µÚÒ»ÁжÔÓ¦µÄʵ¼Ê×ø±ê if (this.tabControl1.SelectedTab.Name == "tabPage2")// ³ÉÆ·1Â¥ { //pp = plAccessorial1; kcpX = (double)(pictureBox2.Size.Width)/9;// 26;//ͼÉÏ»õ¼Ü³¤¶È/С°ü»õ¼Üʵ¼Ê³¤¶È55ÁÐ kcpD = (double)(pictureBox2.Size.Width)/9;// 26;//ͼÉÏ»õ¼Ü³¤¶È/¶Ö°üʵ¼Ê³¤¶È55ÁÐ startXadd = 600; //rxDj2.Location.X; startDadd = 600;//rxDj2.Location.X; } #region ÿ²ãÂ¥¼àÊÓ»Ãæ #region É豸״̬¶¯» foreach (Button ctrl in pRxkS.Controls.OfType<Button>()) { if (ctrl.Enabled == false) continue; //if (ctrl.Tag == "22001") //{ // device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)); //} //else //{ //if (ctrl.Tag.ToString() == "12271.0") //{ //} //if (ctrl.Tag.ToString() == "11001") //{ //} device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)); //} //if (device.DeviceIndex.ToString().IndexOf("13") == 0) continue; //if (device.DeviceIndex.ToString().IndexOf("11") == 0) continue; if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } //²»ÏÔʾ½ûÓõĻ¥³â¶Ñ¶â»ú 20181008 #region ¶¯» if (device.DeviceKind == 1) {//¶Ñ¶â»ú // //182500 1225 // //double a = 0;//3.9423=(49-41.1153)/2(14755:¶Ñ¶â»úͼÉÏ¿í¶È£¬44.1152£ºÁ½Áлõ¼ÜͼÉÏ¿í¶È£¬a:×ø±êÆ«²î) // //double startadd = 178;//;//1ÁÐ×ø±ê // //double width = 44.05;//881/20=44.05 £¨µ¥Áлõ¼Ü¿í¶È£© // //int locationX = (int)(startadd + a + width * (device.XCoor - 1)); // ////int locationX = (int)(startadd + a + width * (device.XCoor - 1)); // ////int locationX = (int)(startadd - a - width * (20 - 1)); #region ³ÉÆ·¿â¶Ñ¶â»ú // ³ÉÆ·¿â¶Ñ¶â»ú if (device.DeviceIndex >= 11001 && device.DeviceIndex <= 11005) { int CPX = device.XCoor - 1 <= 0 ? 0 : device.XCoor - 1; switch (device.DeviceIndex) { case 11001: stackcp1.Location = new Point((int)(startDadd - kcpD * CPX), stackcp1.Location.Y); twcp1.Location = new Point(stackcp1.Location.X + 8, stackcp1.Location.Y + 5); break; case 11002: stackcp2.Location = new Point((int)(startDadd - kcpD * CPX), stackcp2.Location.Y); twcp2.Location = new Point(stackcp2.Location.X + 8, stackcp2.Location.Y + 5); break; //case 31103: // stackcp3.Location = new Point((int)(startXadd - kcpX * CPX), stackcp3.Location.Y); // twcp3.Location = new Point(stackcp3.Location.X + 8, stackcp3.Location.Y + 5); // break; //case 31104: // stackcp4.Location = new Point((int)(startXadd - kcpX * CPX), stackcp4.Location.Y); // twcp4.Location = new Point(stackcp4.Location.X + 8, stackcp4.Location.Y + 5); // break; //case 31105: // stackcp5.Location = new Point((int)(startXadd - kcpX * CPX), stackcp5.Location.Y); // twcp5.Location = new Point(stackcp5.Location.X + 8, stackcp5.Location.Y + 5); // break; } } #endregion } else if (device.DeviceKind == 4) {//RGV //double startadd = 852;//µÚÒ»ÁÐͼÉÏ×ø±ê//730 //double k = (double)(button87.Location.Y - button114.Location.Y) / (double)27765;//ͼÉϹìµÀ¸ß¶È/»õ¼Üʵ¼ÊÂëÖµ³¤¶È ////int locationX = (int)(startadd - k * (xcoor - startcode)); //switch (device.DeviceIndex) //{ // case 23001: // //startadd = button160.Location.Y; // 22024 λÖÃ,button160 - 22001λÖà // k = (double)(button87.Location.Y - button114.Location.Y) / (double)(36305-1436);//ͼÉϹìµÀ¸ß¶È/»õ¼Üʵ¼ÊÂëÖµ³¤¶È(×î´óÖµ-×îСֵ) // if (device.XCoor <= 1436 || device.XCoor <= 1) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button114.Location.Y)); // } // else if (device.XCoor == 3000 || device.XCoor ==2) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button124.Location.Y)); // } // else if (device.XCoor == 4442 || device.XCoor == 3) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button112.Location.Y)); // } // else if (device.XCoor == 9011 || device.XCoor == 4) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button108.Location.Y)); // } // else if (device.XCoor == 12020 || device.XCoor == 5) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button110.Location.Y)); // } // else if (device.XCoor == 16568 || device.XCoor == 6) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button92.Location.Y)); // } // else if (device.XCoor == 19574 || device.XCoor == 7) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button94.Location.Y)); // } // else if (device.XCoor == 20090 || device.XCoor == 8) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button97.Location.Y)); // } // else if (device.XCoor == 25762 || device.XCoor == 9) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button88.Location.Y)); // } // else if (device.XCoor == 28740 || device.XCoor == 10) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button90.Location.Y)); // } // else if (device.XCoor == 32801 || device.XCoor == 11) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button106.Location.Y)); // } // else if (device.XCoor == 33316 || device.XCoor == 12) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button84.Location.Y)); // } // else if (device.XCoor == 36305 || device.XCoor == 13) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button86.Location.Y)); // } // else // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button86.Location.Y - k * (36305 - device.XCoor))); // } // //bt23001.Location = new Point(bt23001.Location.X, bt23001.Location .Y); // t23001.Location = new Point(bt23001.Location.X + 21, bt23001.Location.Y+6); // break; //} } #endregion #region ÉèÖÃÉ豸״̬ switch (device.RunState) { //¿ÕÏÐ case 0: if (device.DeviceKind == 1 || device.DeviceKind == 4 || device.DeviceKind == 17) { if (device.ControlMode > 0) { ctrl.BackColor = Color.DarkViolet; } else { ctrl.BackColor = Color.Orange; } } else { //if (device.DeviceIndex >= 13014 && device.DeviceIndex <= 13015) //{ // ctrl.BackColor = Color.LightPink; //} //else // if (device.DeviceIndex == 12014 || device.DeviceIndex == 12018 || device.DeviceIndex == 12022) // { // ctrl.BackColor = Color.LightPink; // } //else // if (device.DeviceIndex >= 13023 && device.DeviceIndex <= 13024) // { // ctrl.BackColor = Color.Khaki; // } // else // if (device.DeviceIndex >= 13007 && device.DeviceIndex <= 13008) // { // ctrl.BackColor = Color.Khaki; // } // else // { ctrl.BackColor = Color.LightSkyBlue; //} } break; //ÔËÐÐ case 1: ctrl.BackColor = Color.Lime; break; //¹ÊÕÏ case 2: ctrl.BackColor = Color.Red; break; //ÀëÏß case 3: ctrl.BackColor = Color.LightYellow; break; //Í£Óà case 4: ctrl.BackColor = Color.Maroon; break; //20090920¶¯×÷Íê³É case 5: ctrl.BackColor = Color.SeaGreen;//MediumOrchid; break; } #endregion #region É豸±»½ûÓà //richar.liu20140806 int index = dvJY.Find(device.DeviceIndex); if (index >= 0) { ctrl.BackColor = Color.Maroon; } if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = true; } #endregion } foreach (Button ctrl in this.Rxkx.Controls.OfType<Button>()) { if (ctrl.Enabled == false) continue; //if (ctrl.Tag == "22001") //{ // device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)); //} //else //{ device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)); //} //if (device.DeviceIndex.ToString().IndexOf("13") == 0) continue; //if (device.DeviceIndex.ToString().IndexOf("11") == 0) continue; if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } //²»ÏÔʾ½ûÓõĻ¥³â¶Ñ¶â»ú 20181008 #region ¶¯» if (device.DeviceKind == 1) {//¶Ñ¶â»ú // //182500 1225 // //double a = 0;//3.9423=(49-41.1153)/2(14755:¶Ñ¶â»úͼÉÏ¿í¶È£¬44.1152£ºÁ½Áлõ¼ÜͼÉÏ¿í¶È£¬a:×ø±êÆ«²î) // //double startadd = 178;//;//1ÁÐ×ø±ê // //double width = 44.05;//881/20=44.05 £¨µ¥Áлõ¼Ü¿í¶È£© // //int locationX = (int)(startadd + a + width * (device.XCoor - 1)); // ////int locationX = (int)(startadd + a + width * (device.XCoor - 1)); // ////int locationX = (int)(startadd - a - width * (20 - 1)); #region ³ÉÆ·¿â¶Ñ¶â»ú // ³ÉÆ·¿â¶Ñ¶â»ú if (device.DeviceIndex >= 31101 && device.DeviceIndex <= 31105) { int CPX = device.XCoor - 1 <= 0 ? 0 : device.XCoor - 1; switch (device.DeviceIndex) { //case 31101: // stackcp1.Location = new Point((int)(startDadd - kcpD * CPX), stackcp1.Location.Y); // twcp1.Location = new Point(stackcp1.Location.X + 8, stackcp1.Location.Y + 5); // break; //case 31102: // stackcp2.Location = new Point((int)(startDadd - kcpD * CPX), stackcp2.Location.Y); // twcp2.Location = new Point(stackcp2.Location.X + 8, stackcp2.Location.Y + 5); // break; //case 31103: // stackcp3.Location = new Point((int)(startXadd - kcpX * CPX), stackcp3.Location.Y); // twcp3.Location = new Point(stackcp3.Location.X + 8, stackcp3.Location.Y + 5); // break; //case 31104: // stackcp4.Location = new Point((int)(startXadd - kcpX * CPX), stackcp4.Location.Y); // twcp4.Location = new Point(stackcp4.Location.X + 8, stackcp4.Location.Y + 5); // break; //case 31105: // stackcp5.Location = new Point((int)(startXadd - kcpX * CPX), stackcp5.Location.Y); // twcp5.Location = new Point(stackcp5.Location.X + 8, stackcp5.Location.Y + 5); // break; } } #endregion } else if (device.DeviceKind == 4) {//RGV //double startadd = 852;//µÚÒ»ÁÐͼÉÏ×ø±ê//730 //double k = (double)(button87.Location.Y - button114.Location.Y) / (double)27765;//ͼÉϹìµÀ¸ß¶È/»õ¼Üʵ¼ÊÂëÖµ³¤¶È ////int locationX = (int)(startadd - k * (xcoor - startcode)); //switch (device.DeviceIndex) //{ // case 23001: // //startadd = button160.Location.Y; // 22024 λÖÃ,button160 - 22001λÖà // k = (double)(button87.Location.Y - button114.Location.Y) / (double)(36305-1436);//ͼÉϹìµÀ¸ß¶È/»õ¼Üʵ¼ÊÂëÖµ³¤¶È(×î´óÖµ-×îСֵ) // if (device.XCoor <= 1436 || device.XCoor <= 1) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button114.Location.Y)); // } // else if (device.XCoor == 3000 || device.XCoor ==2) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button124.Location.Y)); // } // else if (device.XCoor == 4442 || device.XCoor == 3) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button112.Location.Y)); // } // else if (device.XCoor == 9011 || device.XCoor == 4) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button108.Location.Y)); // } // else if (device.XCoor == 12020 || device.XCoor == 5) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button110.Location.Y)); // } // else if (device.XCoor == 16568 || device.XCoor == 6) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button92.Location.Y)); // } // else if (device.XCoor == 19574 || device.XCoor == 7) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button94.Location.Y)); // } // else if (device.XCoor == 20090 || device.XCoor == 8) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button97.Location.Y)); // } // else if (device.XCoor == 25762 || device.XCoor == 9) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button88.Location.Y)); // } // else if (device.XCoor == 28740 || device.XCoor == 10) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button90.Location.Y)); // } // else if (device.XCoor == 32801 || device.XCoor == 11) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button106.Location.Y)); // } // else if (device.XCoor == 33316 || device.XCoor == 12) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button84.Location.Y)); // } // else if (device.XCoor == 36305 || device.XCoor == 13) // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button86.Location.Y)); // } // else // { // bt23001.Location = new Point(bt23001.Location.X, (int)(button86.Location.Y - k * (36305 - device.XCoor))); // } // //bt23001.Location = new Point(bt23001.Location.X, bt23001.Location .Y); // t23001.Location = new Point(bt23001.Location.X + 21, bt23001.Location.Y+6); // break; //} } #endregion #region ÉèÖÃÉ豸״̬ switch (device.RunState) { //¿ÕÏÐ case 0: if (device.DeviceKind == 1 || device.DeviceKind == 4 || device.DeviceKind == 17) { if (device.ControlMode > 0) { ctrl.BackColor = Color.DarkViolet; } else { ctrl.BackColor = Color.Orange; } } else { //if (device.DeviceIndex >= 13014 && device.DeviceIndex <= 13015) //{ // ctrl.BackColor = Color.LightPink; //} //else // if (device.DeviceIndex == 12014 || device.DeviceIndex == 12018 || device.DeviceIndex == 12022) // { // ctrl.BackColor = Color.LightPink; // } //else // if (device.DeviceIndex >= 13023 && device.DeviceIndex <= 13024) // { // ctrl.BackColor = Color.Khaki; // } // else // if (device.DeviceIndex >= 13007 && device.DeviceIndex <= 13008) // { // ctrl.BackColor = Color.Khaki; // } // else // { ctrl.BackColor = Color.LightSkyBlue; //} } break; //ÔËÐÐ case 1: ctrl.BackColor = Color.Lime; break; //¹ÊÕÏ case 2: ctrl.BackColor = Color.Red; break; //ÀëÏß case 3: ctrl.BackColor = Color.LightYellow; break; //Í£Óà case 4: ctrl.BackColor = Color.Maroon; break; //20090920¶¯×÷Íê³É case 5: ctrl.BackColor = Color.SeaGreen;//MediumOrchid; break; } #endregion #region É豸±»½ûÓà //richar.liu20140806 int index = dvJY.Find(device.DeviceIndex); if (index >= 0) { ctrl.BackColor = Color.Maroon; } if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = true; } #endregion } #endregion #region »õÎï̽²â foreach (TextBox ctrl in pRxkS.Controls.OfType<TextBox>()) { if (ctrl.Tag.ToString() == "") { continue; } DS = ctrl.Tag.ToString().Split(dd); int devicebyte = 0; int devbit = 0; int.TryParse(DS[0], out devicebyte); int.TryParse(DS[1], out devbit); device = Model.CGetInfo.GetDeviceInfo(devicebyte); if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } //if (ctrl.Tag.ToString() == "11003.0") //{ // string s = ctrl.Name; //} //if (ctrl.Tag.ToString() == "11003.1") //{ // string s = ctrl.Name; //} //if (device.DeviceIndex == 19002) //{ // string s = ctrl.Name; //} if (device.DeviceIndex == 12271) { } int index = dvJY.Find(device.DeviceIndex); switch (devbit) { case 0: if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = device.SplitByte_0 >= 1 ? true : false; } break; case 1: if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = device.SplitByte_1 >= 1 ? true : false; } break; case 2: ctrl.Visible = device.SplitByte_2 == 1 ? true : false; break; case 3: ctrl.Visible = device.SplitByte_3 == 1 ? true : false; break; case 4: ctrl.Visible = device.SplitByte_4 == 1 ? true : false; break; case 5: ctrl.Visible = device.SplitByte_5 == 1 ? true : false; break; case 6: ctrl.Visible = device.SplitByte_6 == 1 ? true : false; ctrl.BackColor = Color.Goldenrod; break; case 7: ctrl.Visible = device.SplitByte_7 == 1 ? true : false; break; } } foreach (TextBox ctrl in this.Rxkx.Controls.OfType<TextBox>()) { if (ctrl.Tag.ToString() == "") { continue; } DS = ctrl.Tag.ToString().Split(dd); int devicebyte = 0; int devbit = 0; int.TryParse(DS[0], out devicebyte); int.TryParse(DS[1], out devbit); device = Model.CGetInfo.GetDeviceInfo(devicebyte); if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } //if (ctrl.Tag.ToString() == "11003.0") //{ // string s = ctrl.Name; //} //if (ctrl.Tag.ToString() == "11003.1") //{ // string s = ctrl.Name; //} //if (device.DeviceIndex == 19002) //{ // string s = ctrl.Name; //} if (device.DeviceIndex == 12271) { } int index = dvJY.Find(device.DeviceIndex); switch (devbit) { case 0: if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = device.SplitByte_0 == 1 ? true : false; } break; case 1: if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà { ctrl.Visible = false; } else { ctrl.Visible = device.SplitByte_1 == 1 ? true : false; } break; case 2: ctrl.Visible = device.SplitByte_2 == 1 ? true : false; break; case 3: ctrl.Visible = device.SplitByte_3 == 1 ? true : false; break; case 4: ctrl.Visible = device.SplitByte_4 == 1 ? true : false; break; case 5: ctrl.Visible = device.SplitByte_5 == 1 ? true : false; break; case 6: ctrl.Visible = device.SplitByte_6 == 1 ? true : false; ctrl.BackColor = Color.Goldenrod; break; case 7: ctrl.Visible = device.SplitByte_7 == 1 ? true : false; break; } } //foreach (TextBox ctrl in this.ZjkXPl.Controls.OfType<TextBox>()) //{ // if (ctrl.Tag.ToString() == "") // { // continue; // } // DS = ctrl.Tag.ToString().Split(dd); // int devicebyte = 0; int devbit = 0; // int.TryParse(DS[0], out devicebyte); // int.TryParse(DS[1], out devbit); // device = Model.CGetInfo.GetDeviceInfo(devicebyte); // if (device == null) // {//20100108 // if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) // { // tsStatus.ForeColor = Color.Red; // this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; // } // continue; // } // //if (ctrl.Tag.ToString() == "11003.0") // //{ // // string s = ctrl.Name; // //} // //if (ctrl.Tag.ToString() == "11003.1") // //{ // // string s = ctrl.Name; // //} // //if (device.DeviceIndex == 19002) // //{ // // string s = ctrl.Name; // //} // if (device.DeviceIndex==12271) // { // } // int index = dvJY.Find(device.DeviceIndex); // switch (devbit) // { // case 0: // if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà // { // ctrl.Visible = false; // } // else // { // ctrl.Visible = device.SplitByte_0 == 1 ? true : false; // } // break; // case 1: // if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà // { // ctrl.Visible = false; // } // else // { // ctrl.Visible = device.SplitByte_1 == 1 ? true : false; // } // break; // case 2: // ctrl.Visible = device.SplitByte_2 == 1 ? true : false; // break; // case 3: // ctrl.Visible = device.SplitByte_3 == 1 ? true : false; // break; // case 4: // ctrl.Visible = device.SplitByte_4 == 1 ? true : false; // break; // case 5: // ctrl.Visible = device.SplitByte_5 == 1 ? true : false; // break; // case 6: // ctrl.Visible = device.SplitByte_6 == 1 ? true : false; // ctrl.BackColor = Color.Goldenrod; // break; // case 7: // ctrl.Visible = device.SplitByte_7 == 1 ? true : false; // break; // } //} //foreach (TextBox ctrl in this.ZjkSPl.Controls.OfType<TextBox>()) //{ // if (ctrl.Tag.ToString() == "") // { // continue; // } // DS = ctrl.Tag.ToString().Split(dd); // int devicebyte = 0; int devbit = 0; // int.TryParse(DS[0], out devicebyte); // int.TryParse(DS[1], out devbit); // device = Model.CGetInfo.GetDeviceInfo(devicebyte); // if (device == null) // {//20100108 // if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) // { // tsStatus.ForeColor = Color.Red; // this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; // } // continue; // } // //if (ctrl.Tag.ToString() == "11003.0") // //{ // // string s = ctrl.Name; // //} // //if (ctrl.Tag.ToString() == "11003.1") // //{ // // string s = ctrl.Name; // //} // //if (device.DeviceIndex == 19002) // //{ // // string s = ctrl.Name; // //} // if (device.DeviceIndex == 12271) // { // } // int index = dvJY.Find(device.DeviceIndex); // switch (devbit) // { // case 0: // if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà // { // ctrl.Visible = false; // } // else // { // ctrl.Visible = device.SplitByte_0 == 1 ? true : false; // } // break; // case 1: // if (device.VirtualStack > 0 && index >= 0)//»¥³â¶Ñ¶â»ú±»½ûÓà // { // ctrl.Visible = false; // } // else // { // ctrl.Visible = device.SplitByte_1 == 1 ? true : false; // } // break; // case 2: // ctrl.Visible = device.SplitByte_2 == 1 ? true : false; // break; // case 3: // ctrl.Visible = device.SplitByte_3 == 1 ? true : false; // break; // case 4: // ctrl.Visible = device.SplitByte_4 == 1 ? true : false; // break; // case 5: // ctrl.Visible = device.SplitByte_5 == 1 ? true : false; // break; // case 6: // ctrl.Visible = device.SplitByte_6 == 1 ? true : false; // ctrl.BackColor = Color.Goldenrod; // break; // case 7: // ctrl.Visible = device.SplitByte_7 == 1 ? true : false; // break; // } //} #endregion #region ¸ßλ¿ª¹ØÌ½²â foreach (Label ctrl in pRxkS.Controls.OfType<Label>()) { if (ctrl.Tag != null && ctrl.ForeColor != Color.Red) { DS = ctrl.Tag.ToString().Split(dd); int devicebyte = 0; int devbit = 0; int.TryParse(DS[0], out devicebyte); int.TryParse(DS[1], out devbit); device = Model.CGetInfo.GetDeviceInfo(devicebyte); if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } if (device.DeviceIndex == 13003) { } if (devbit < 8) { switch (devbit) { case 0: ctrl.Visible = device.SplitByte_0 == 1 ? true : false; break; case 1: ctrl.Visible = device.SplitByte_1 == 1 ? true : false; break; case 2: ctrl.Visible = device.SplitByte_2 == 1 ? true : false; break; case 3: ctrl.Visible = device.SplitByte_3 == 1 ? true : false; break; case 4: ctrl.Visible = device.SplitByte_4 == 1 ? true : false; break; case 5: ctrl.Visible = device.SplitByte_5 == 1 ? true : false; break; case 6: ctrl.Visible = device.SplitByte_6 == 1 ? true : false; ctrl.BackColor = Color.Goldenrod; break; case 7: ctrl.Visible = device.SplitByte_7 == 1 ? true : false; break; } } else { devbit = devbit % 8; switch (devbit) { case 0: ctrl.Visible = (device.SplitByte_5 & 1) == 1 ? true : false; break; case 1: ctrl.Visible = (device.SplitByte_5 & 2) == 2 ? true : false; break; case 2: ctrl.Visible = (device.SplitByte_5 & 4) == 4 ? true : false; break; case 3: ctrl.Visible = (device.SplitByte_5 & 8) == 8 ? true : false; break; case 4: ctrl.Visible = (device.SplitByte_5 & 16) == 16 ? true : false; break; case 5: ctrl.Visible = (device.SplitByte_5 & 32) == 32 ? true : false; break; case 6: ctrl.Visible = (device.SplitByte_5 & 64) == 64 ? true : false; break; case 7: ctrl.Visible = (device.SplitByte_5 & 128) == 128 ? true : false; break; } } } } #endregion #region Âß¼ÓÐÎïÏÔʾ foreach (RadioButton ctrl in pRxkS.Controls.OfType<RadioButton>()) { //20100108DataView dvh; dv = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_DeviceIndex = " + ctrl.Tag + ") AND (F_HaveGoods >0)").Tables[0].DefaultView; if (dv.Count > 0) { ctrl.Visible = true; ctrl.BackColor = Color.Blue; } else { ctrl.Visible = false; } } #endregion #region ¹ÊÕϵã //foreach (PictureBox ctrl in pp.Controls.OfType<PictureBox>()) //{ // if (ctrl.Tag.ToString() != "") // { // DS = ctrl.Tag.ToString().Split(dd); // if (DS.Length > 1) // { // int devicebyte = 0; int devbit = 0; // int.TryParse(DS[0], out devicebyte); // int.TryParse(DS[1], out devbit); // device = Model.CGetInfo.GetDeviceInfo(devicebyte); // if (device == null) // {//20100108 // if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) // { // tsStatus.ForeColor = Color.Red; // this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; // } // continue; // } // switch (devbit) // { // case 0: // ctrl.Visible = device.SplitByte_0 == 1 ? true : false; // break; // case 1: // ctrl.Visible = device.SplitByte_1 == 1 ? true : false; // break; // case 2: // ctrl.Visible = device.SplitByte_2 == 1 ? true : false; // break; // case 3: // ctrl.Visible = device.SplitByte_3 == 1 ? true : false; // break; // case 4: // ctrl.Visible = device.SplitByte_4 == 1 ? true : false; // break; // case 5: // ctrl.Visible = device.SplitByte_5 == 1 ? true : false; // break; // case 6: // ctrl.Visible = device.SplitByte_6 == 1 ? true : false; // break; // case 7: // ctrl.Visible = device.SplitByte_7 == 1 ? true : false; // break; // } // } // } //} #endregion #region ¼±Í£°´Å¥ÏÔʾ //foreach (PictureBox ctrl in pp.Controls.OfType<PictureBox>()) //{ // if (ctrl.Tag.ToString() == "") // { // continue; // } // //°´Å¥°´ÏÂʱºò // if (!ctrl.Tag.ToString().Contains(".")) // { // device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Name.ToString().Substring(ctrl.Name.Length-5 ,5))); // if (device.DeviceKind == 40) // { // // È¡µ½¶Ñ¶â»ú״̬ // device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)); // if (device == null) // { // if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag.ToString()+"ûÓмǼ£¡")<0) // { // tsStatus.ForeColor = Color.Red; // tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag.ToString() + "ûÓмǼ£¡"; // } // continue; // } // DataView dvRunDevcie = dbo.ExceSQL(" select F_DeviceIndex from T_Base_Device where F_DeviceKindIndex = 1 or F_DeviceKindIndex = 4").Tables[0].DefaultView; // for (int i = 0; i < dvRunDevcie.Count; i++) // { // if (ctrl.Tag.ToString()== dvRunDevcie[i]["F_DeviceIndex"].ToString()) // { // Model.MDevice DeviceRun = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag.ToString())); // if (DeviceRun.SplitByte_6 == 1)// δͣ³µ // { // ctrl.Image = wcfControlMonitorClient.Properties.Resources.StopButtonUp; // } // if (DeviceRun.SplitByte_6 == 0)// Í£³µÖÐ // { // ctrl.Image = wcfControlMonitorClient.Properties.Resources.StopButtonDown; // } // } // } // } // } //} #endregion #region °²È«ÃÅÏÔʾ foreach (PictureBox ctrl in pRxkS.Controls.OfType<PictureBox>()) { if (ctrl.Enabled == false) continue; if (ctrl.Tag.ToString().Contains('.')) { DS = ctrl.Tag.ToString().Split(dd); int devicebyte = 0; int devbit = 0; int.TryParse(DS[0], out devicebyte); int.TryParse(DS[1], out devbit); device = Model.CGetInfo.GetDeviceInfo(devicebyte); if (device == null) {//20100108 if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!"; } continue; } if (device.SplitByte_2 == 1)// °²È«ÃÅ´ò¿ª { ctrl.Image = wcfControlMonitorClient.Properties.Resources.linkerror; } if (device.SplitByte_6 == 0)// °²È«ÃÅ¹Ø±Õ { ctrl.Image = wcfControlMonitorClient.Properties.Resources.linkok; } } } #endregion #endregion } #endregion } catch (Exception ex) {//20100108 if (tsStatus.Text.IndexOf("ˢнçÃæ¶¯»Ê±£º" + ex.Message) < 0) { tsStatus.ForeColor = Color.Red; this.tsStatus.Text += "ˢнçÃæ¶¯»Ê±£º" + ex.Message; } } finally {//20100108 TimeSpan ts1 = DateTime.Now.TimeOfDay; device = null; this.ResumeLayout();//richard.liu20140806 } } private void ctrl_Click(object sender, EventArgs e) { Button btn = (Button)sender; _deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag); _deviceStatus.ShowDialog(); } private void Btn_MouseEnter(object sender, EventArgs e) { int deviceindex; string[] DS; char[] dd = new char[1] { '.' }; string msg = (sender as Control).Tag.ToString(); string name = (sender as Control).Name.ToString(); DS = msg.Split(dd); if (DS.Length > 0) { if (int.TryParse(DS[0], out deviceindex)) { devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex); if (devinfo != null) { //msg = string.Format("{0},λÖÃX,Y:({1},{2})", devinfo.DeviceName, (sender as Control).Location.X,(sender as Control).Location.Y+83); msg = string.Format("{0}", devinfo.DeviceName); if (devinfo.DeviceKind == 55) { if (devinfo.SplitByte_2 == 0) { msg = string.Format("{0}-¹Ø±Õ", devinfo.DeviceName); } else { msg = string.Format("{0}-´ò¿ª", devinfo.DeviceName); } } //if (DS.Length > 1) //{ // if (DS[1] == "2" ) // { // if(devinfo .SplitByte_2 == 0) // { // msg = "°²È«ÃŹرÕ"; // } // else // { // msg = "°²È«ÃÅ´ò¿ª"; // } // } //} //msg = string.Format("{0}", devinfo.DeviceName); } } } if(name.IndexOf("lift")>0) { msg = "ÇëÁ¢¼´°áÀëÍÐÅÌ!"; } toolTip_DeviceIndex.SetToolTip(sender as Control, msg); } private void ctrl_ClickLabel(object sender, EventArgs e) { Label label = (Label)sender; _deviceStatus.DeviceIndex = Convert.ToInt32(label.Tag); _deviceStatus.ShowDialog(); } private void ctrl_ClickPic(object sender, EventArgs e) { PictureBox btn = (PictureBox)sender; _deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag); _deviceStatus.ShowDialog(); } /// <summary> /// ¹ö¶¯·½·¨ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void FormSample_MouseWheel(object sender, MouseEventArgs e) { ////»ñÈ¡¹â±êλÖà //Point mousePoint = new Point(e.X, e.Y); ////»»Ëã³ÉÏà¶Ô±¾´°ÌåµÄλÖà //mousePoint.Offset(this.Location.X, this.Location.Y); ////ÅжÏÊÇ·ñÔÚpanelÄÚ //if (panelWareHouse.RectangleToScreen(panelWareHouse.DisplayRectangle).Contains(mousePoint)) //{ // //¹ö¶¯ // panelWareHouse.AutoScrollPosition = new Point(0, panelWareHouse.VerticalScroll.Value - e.Delta); //} } private void FrmControlMonitor_Load(object sender, EventArgs e) { try { //this.panelWareHouse.MouseWheel += new MouseEventHandler(FormSample_MouseWheel); //this.panelWareHouse.Focus(); #region Ìí¼ÓÊäËÍ»ú¡¢´©Ë󳵺ͶѶâ»úµÄµ¥»÷ʼþ //foreach (Control ctrl in this.plAccessorial1.Controls) //{ // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null)) // { // ctrl.Click += new EventHandler(ctrl_Click); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red)) // { // ctrl.Click += new EventHandler(ctrl_ClickLabel); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.BackColor == Color.LightSteelBlue)) // //{ // // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // //} // if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true)) // { // //ctrl.Click += new EventHandler(ctrl_ClickPic); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } //} //foreach (Control ctrl in this.panelWareHouse.Controls) //{ // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null)) // { // ctrl.Click += new EventHandler(ctrl_Click); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red)) // { // ctrl.Click += new EventHandler(ctrl_ClickLabel); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Blue)) // //{ // // ctrl.Visible = true; // // ctrl.Visible = false; // //} // //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.BackColor == Color.LightSteelBlue)) // //{ // // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // //} // if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true)) // { // //ctrl.Click += new EventHandler(ctrl_ClickPic); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } //} //foreach (Control ctrl in this.InOutAreaPanel.Controls) //{ // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null)) // { // ctrl.Click += new EventHandler(ctrl_Click); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red)) // { // ctrl.Click += new EventHandler(ctrl_ClickLabel); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } // //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Blue)) // //{ // // ctrl.Visible = true; // // ctrl.Visible = false; // //} // //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.BackColor == Color.LightSteelBlue)) // //{ // // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // //} // if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true)) // { // //ctrl.Click += new EventHandler(ctrl_ClickPic); // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); // } //} #endregion // tabÒ³¸ù¾Ýuser±íÉèÖÃÀ´ÏÔʾ foreach (TabPage tabPage in tabControl1.TabPages) { if (tabPage.Tag.ToString() == CStaticClass.UserArea || CStaticClass.UserArea == "") { foreach (Control ctrls in tabPage.Controls) { if (ctrls.GetType().ToString() == "System.Windows.Forms.Panel") { foreach (Control ctrl in ctrls.Controls) { if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null)) { ctrl.Click += new EventHandler(ctrl_Click); ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); } if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red)) { ctrl.Click += new EventHandler(ctrl_ClickLabel); ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); } //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.BackColor == Color.LightSteelBlue)) //{ // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); //} if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true)) { // ctrl.Click += new EventHandler(ctrl_ClickPic); //ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); //2020Ôö¼Ó¼±Í£°´Å¥ if (!ctrl.Tag.ToString().Contains(".")) { if (ctrl.Name.ToString().Contains("pic300"))// ¼±Í£°´Å¥ { ctrl.Click += new EventHandler(ctrl_Click_1); ctrl.MouseEnter += new EventHandler(Btn_MouseEnter_Stop); } else { // Ò»°ãÉ豸¶Ñ¶â»ú¡¢´©Ëó³µ ctrl.Click += new EventHandler(ctrl_ClickPic); ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); } } else { ctrl.MouseEnter += new EventHandler(Btn_MouseEnter); } } #region 20200917 zb Ôö¼Ógroupbox Àï¿Ø¼þʼþ,²âÊÔʼþ³É¹¦Ìí¼Ó£¬Ë¢ÐÂ״̬ҲҪÐÞ¸Ä //if (ctrl.GetType().ToString() == "System.Windows.Forms.GroupBox") //{ // foreach (Control ctrlss in ctrl.Controls) // { // if ((ctrlss.GetType().ToString() == "System.Windows.Forms.Button") && (ctrlss.Tag != null)) // { // ctrlss.Click += new EventHandler(ctrl_Click); // ctrlss.MouseEnter += new EventHandler(Btn_MouseEnter); // } // if ((ctrlss.GetType().ToString() == "System.Windows.Forms.Label") && (ctrlss.Tag != null) && (ctrlss.ForeColor == Color.Red)) // { // ctrlss.Click += new EventHandler(ctrl_ClickLabel); // ctrlss.MouseEnter += new EventHandler(Btn_MouseEnter); // } // } //} #endregion } } } } else { tabPage.Parent = null; } } } catch (Exception ex) { throw (ex); } } /// <summary> /// ¼±Í£°´Å¥Ê¼þ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ctrl_Click_1(object sender, EventArgs e) { PictureBox pb = (PictureBox) sender; int DeviceIndexForRunButton = Convert.ToInt32(pb.Name.Substring(pb.Name.Length - 5, 5)); Model.MDevice DeviceRun = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(pb.Tag.ToString())); int ivalue = 0; ivalue = DeviceRun.SplitByte_6 == 1 ? 0 : 1; CStaticClass.WcfControl.BeginSendDeviceReset(DeviceIndexForRunButton,ivalue,new AsyncCallback(SendDeviceResetCallback) ,ivalue); } void SendDeviceResetCallback(IAsyncResult ar) { string ErrorTest = string.Empty; if (CStaticClass.WcfControl.EndSendDeviceReset( out ErrorTest,ar)==false) { MessageBox.Show(ErrorTest,"²Ù×÷Ìáʾ",MessageBoxButtons.OK,MessageBoxIcon.Error); } } /// <summary> /// ¼±Í£°´Å¥ÏÔʾÉ豸ÐÅÏ¢ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_MouseEnter_Stop(object sender, EventArgs e) { string DeviceIndex = (sender as Control).Tag.ToString(); devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(DeviceIndex)); if (devinfo!= null) { if (devinfo.SplitByte_6 == 1)// δͣ³µ { DeviceIndex = string.Format("{0}-δÁª»úÍ£³µ£¡",devinfo.DeviceIndex); } if (devinfo.SplitByte_6 == 0)//Í£³µ { DeviceIndex = string.Format("{0}-Áª»úÍ£³µÖУ¡", devinfo.DeviceIndex); } } toolTip_DeviceIndex.SetToolTip(sender as Control, DeviceIndex); } private void tsStatus_ForeColorChanged(object sender, EventArgs e) { FrmErrorMessage.FormInstance.NewForeColor((sender as TextBox).ForeColor); } private void tsStatus_TextChanged(object sender, EventArgs e) { //throw new System.Exception("The method or operation is not implemented."); string msg = (sender as TextBox).Text; if (msg != "") { //msg = string.Format("{0}\r\n", msg); //msg=msg+"\r\n"; CommonClassLib.CCarryConvert.WriteDarkCasket("Error", msg, "", "", ""); FrmErrorMessage.FormInstance.NewMessage(msg); } } private void tabPage1_Click(object sender, EventArgs e) { } private void button6_Click(object sender, EventArgs e) { string enddevices, startsdevices, strinfo = string.Empty;//²ð¶âÈÎÎñÖÕµã string sqlstr = string.Empty; DataView dvdv = new DataView(); int EndDevice =12018; sqlstr = string.Format("select * from T_Base_TaskCount where F_DeviceIndex={0}", EndDevice);//²éÕÒÖÕµãÉ豸¶ÔÓ¦µÄ³ö¿âÈÎÎñ»ñÈ¡ÊýÁ¿ºÍÖ´ÐÐÊýÁ¿ dvdv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView; if (dvdv.Count > 0) { int getcount, execount; getcount = Convert.ToInt32(dvdv[0]["F_MAXCOUNT"]); execount = Convert.ToInt32(dvdv[0]["F_EXECOUNT"]); //checkdevice = Convert.ToInt32(dvdv[0]["F_CHECKDEVICE"]);// enddevices = Convert.ToString(dvdv[0]["F_CHECKENDDEVICE"]);//ÒªÅжÁÊÇ·ñ´æÔÚ¸ÃÖÕµãµÄÉ豸 startsdevices = Convert.ToString(dvdv[0]["F_CHECKSTARTDEVICE"]);//ÒªÅжÏÊÇ·ñ´æÔÚ¸ÃÆðµãµÄÉ豸 if (startsdevices != "0" || enddevices != "0")//±íʾͬʱִÐÐʱ { sqlstr = string.Format("SELECT FID,F_ManageTaskKindIndex FROM T_Manage_Task WHERE (FSTARTDEVICE in({0})) OR (FENDDEVICE in({1}))", startsdevices, enddevices); dvdv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView; if (dvdv.Count > 0)//´æÔÚÏ໥¸ÉÈŵijöÈë¿âÈÎÎñʱ£¬°´³ö¿âÊýÁ¿ÏÞÖÆ { // outcount = execount; } else//Ö»´æÔÚµ±Ç°ÖÕµãµÄÈÎÎñʱ£¬°´»ñÈ¡ÊýÁ¿ÏÞÖÆ£¬Ò»°ãÇé¿ö »ñÈ¡ÊýÁ¿Òª´óÓÚÖ´ÐÐÊýÁ¿ { //outcount = getcount; } } } } private void button6_Click_1(object sender, EventArgs e) { bool a = GetTransDeviceIfFull("11003;11004;11005"); } public bool GetTransDeviceIfFull(string Devices) { try { char[] cc = new char[1] { ';' }; string[] sp; sp = Devices.Split(cc); int count = sp.Length;//É豸ÊýÁ¿ int goodscount = 0;//»õÎïÊýÁ¿ for (int i = 0; i < count; i++) { int deviceindex = Convert.ToInt32(sp[i]); devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex); if (devinfo != null) { goodscount += devinfo.SplitByte_0; goodscount += devinfo.SplitByte_1; } } if (goodscount >= count) { return true; } else { return false; } } catch (Exception ex) { return false; } } //private void tabControl1_TabIndexChanged(object sender, EventArgs e) //{ //} private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { int index = ((TabControl)sender).SelectedIndex; if (index == 1) { //button242.Focus(); } } private void button134_Click(object sender, EventArgs e) { //textBox85.Visible = true; } private void button161_Click(object sender, EventArgs e) { } private void button20_Click(object sender, EventArgs e) { //textBox44.Visible = !textBox44.Visible; } private void tabPage3_Click(object sender, EventArgs e) { } private void tabPage4_Click(object sender, EventArgs e) { } private void tabPage2_Click(object sender, EventArgs e) { } private void RxkPl_Paint(object sender, PaintEventArgs e) { } } }