using ComponentFactory.Krypton.Toolkit; using NXWMS.Client.Model.AppModels.Condition.Monitor; using NXWMS.Client.Model.AppModels.Result.Monitor; using NXWMS.Services; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace NXWMS.Forms.Monitor { public partial class frmWcsMotBinStatus : KryptonForm { public frmWcsMotBinStatus() { InitializeComponent(); } private void frmWcsMotBinStatus_Load(object sender, EventArgs e) { try { Thread th = new Thread(ShowBinMonitorMsg) { IsBackground = true }; th.Start(); } catch (Exception ex) { KryptonMessageBox.Show(ex.Message); } } private void pictureBox980_Paint(object sender, PaintEventArgs e) { Pen pp = new Pen(Color.FromArgb(83, 92, 89), 3); e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1); } private void pictureBox980_MouseHover(object sender, EventArgs e) { try { ToolTip ttp = new ToolTip { InitialDelay = 200, AutoPopDelay = 3000, ReshowDelay = 200, ShowAlways = true, IsBalloon = true }; PictureBox pic = sender as PictureBox; int ptbIndex = Convert.ToInt32(pic.Name.Replace("pictureBox", "")); int maxColIndex = 49; int maxLayerIndex = 10; if (Convert.ToInt32(pic.Tag) == 2) { ptbIndex -= maxColIndex * maxLayerIndex; } int binLayerIndex = 0; int binColIndex = 0; switch (ptbIndex % maxLayerIndex) { case 0: binLayerIndex = maxLayerIndex; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: binLayerIndex = ptbIndex % maxLayerIndex; break; default: break; } binColIndex = (ptbIndex - binLayerIndex + maxLayerIndex) / maxLayerIndex; WcsMotBalanceMonitor binMd = binMonitorLst.FirstOrDefault(x => x.BIN_ROW == Convert.ToInt32(pic.Tag) && x.BIN_COLUMN == binColIndex && x.BIN_LAYER == binLayerIndex); if (binMd != null) { string tipShowMsg = $"库位号:【{binMd.BIN_CODE}】\r\n托盘号:【{binMd.PALLET_CODE}】\r\n任务号:【{binMd.TASK_NO}】\r\n指令号:【{binMd.CMD_NO}】\r\n库存状态:【{binMd.BALANCE_STATUS_NAME}】\r\n库位状态:【{binMd.USED_FLAG_NAME}】"; ttp.SetToolTip(pic, tipShowMsg); } } catch (Exception ex) { KryptonMessageBox.Show(ex.Message); } } public List binMonitorLst = new List(); private void ShowBinMonitorMsg() { while (true) { try { binMonitorLst = WcsMonitorService.wcsMotManageService.GetBinMonitorData(new WcsMotBalanceSearchMd { RegionMsg = "YCLK_Region" }).Data; if (binMonitorLst != null && binMonitorLst.Count > 0) { int maxLayer = binMonitorLst.Max(x => x.BIN_LAYER); int maxColumn = binMonitorLst.Max(x => x.BIN_COLUMN); foreach (WcsMotBalanceMonitor item in binMonitorLst) { if (item.BIN_ROW == 1) { int picNum = item.BIN_LAYER + (item.BIN_COLUMN - 1) * maxLayer; Invoke(new Action(() => { Control picControl = this.Controls.Find("pictureBox" + picNum, true)[0]; if (picControl is PictureBox) { PictureBox ptb = picControl as PictureBox; if (item.USED_FLAG == 1) { if (item.BALANCE_STATUS == 0) { ptb.BackColor = Color.FromArgb(216, 211, 205); } else if (item.BALANCE_STATUS > 0 && item.BALANCE_STATUS < 55) { ptb.BackColor = Color.Yellow; } else if (item.BALANCE_STATUS == 55) { ptb.BackColor = Color.Lime; } else if (item.BALANCE_STATUS > 55 && item.BALANCE_STATUS < 99) { ptb.BackColor = Color.FromArgb(80, 160, 255); } else { ptb.BackColor = Color.FromArgb(216, 211, 205); } } else { ptb.BackColor = Color.Red; } } })); } else { int picNum = item.BIN_LAYER + (item.BIN_COLUMN - 1) * maxLayer + maxLayer * maxColumn; Invoke(new Action(() => { Control picControl = this.Controls.Find("pictureBox" + picNum, true)[0]; if (picControl is PictureBox) { PictureBox ptb = picControl as PictureBox; if (item.USED_FLAG == 1) { if (item.BALANCE_STATUS == 0) { ptb.BackColor = Color.FromArgb(216, 211, 205); } else if (item.BALANCE_STATUS > 0 && item.BALANCE_STATUS < 55) { ptb.BackColor = Color.Yellow; } else if (item.BALANCE_STATUS == 55) { ptb.BackColor = Color.Lime; } else if (item.BALANCE_STATUS > 55 && item.BALANCE_STATUS < 99) { ptb.BackColor = Color.FromArgb(80, 160, 255); } else { ptb.BackColor = Color.FromArgb(216, 211, 205); } } else { ptb.BackColor = Color.Red; } } })); } } } } catch { } Thread.Sleep(500); } } } }