using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Module.Plc.ModbusTcp.Tool; using MorClient; using static System.Windows.Forms.AxHost; using Sunny.UI; namespace MorClient { public partial class Initialize : UserControl { private delegate void PrintCSStateValueCallBack(); //委托事件 private PrintCSStateValueCallBack ShowCSStateValue; public static bool IsPrintReadValue = true; public Initialize() { InitializeComponent(); } /// /// 窗体打开事件 /// /// /// public void Initialize_Load(object sender, EventArgs e) { if (!PubStaticClass.bthreedInitialize) { PubStaticClass.bthreedInitialize = true; //委托展示参数实时值 ShowCSStateValue = new PrintCSStateValueCallBack(PrintParamRealValue); //开始显示实时值线程 System.Threading.Thread printRealValueThread = new System.Threading.Thread(StartPrintParamRealValue); printRealValueThread.IsBackground = true; printRealValueThread.Start(); } } /// /// 开始显示实时值线程 /// private async void StartPrintParamRealValue() { await Task.Run(() => { while (IsPrintReadValue) { if (this.IsHandleCreated) { this.BeginInvoke(ShowCSStateValue, null); } System.Threading.Thread.Sleep(1000); } }); } /// /// 展示参数实时值 /// private void PrintParamRealValue() { try { PubStaticClass.initialize.uiButton3.FillColor = Common.allInitialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton2.FillColor = Common.brtInitialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton1.FillColor = Common.stationCA.F_StationInitialization ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton4.FillColor = Common.scr1Initialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton7.FillColor = Common.scr2Initialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton6.FillColor = Common.scr3Initialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); PubStaticClass.initialize.uiButton5.FillColor = Common.scr4Initialize ? Color.FromArgb(146, 208, 80) : Color.FromArgb(32, 56, 100); } catch (Exception ex) { ex.ToString(); } GC.Collect(); GC.WaitForPendingFinalizers(); } private void uiButton3_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlHighOrder("4800"); } private void uiButton2_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("4534"); } private void uiButton1_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("4410"); } private void uiButton4_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("1550"); } private void uiButton7_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("2150"); } private void uiButton6_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("2750"); } private void uiButton5_MouseDown(object sender, MouseEventArgs e) { PublicPara.PlcTool.ValveControlLowOrder("3350"); } private void uiButton3_MouseEnter(object sender, EventArgs e) { if (uiButton3.FillColor == Color.FromArgb(146, 208, 80)) { uiButton3.FillColor = Color.FromArgb(146, 208, 80); uiButton3.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton3.FillColor == Color.FromArgb(32, 56, 100)) { uiButton3.FillColor = Color.FromArgb(32, 56, 100); uiButton3.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton2_MouseEnter(object sender, EventArgs e) { if (uiButton2.FillColor == Color.FromArgb(146, 208, 80)) { uiButton2.FillColor = Color.FromArgb(146, 208, 80); uiButton2.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton2.FillColor == Color.FromArgb(32, 56, 100)) { uiButton2.FillColor = Color.FromArgb(32, 56, 100); uiButton2.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton1_MouseEnter(object sender, EventArgs e) { if (uiButton1.FillColor == Color.FromArgb(146, 208, 80)) { uiButton1.FillColor = Color.FromArgb(146, 208, 80); uiButton1.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton1.FillColor == Color.FromArgb(32, 56, 100)) { uiButton1.FillColor = Color.FromArgb(32, 56, 100); uiButton1.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton4_MouseEnter(object sender, EventArgs e) { if (uiButton4.FillColor == Color.FromArgb(146, 208, 80)) { uiButton4.FillColor = Color.FromArgb(146, 208, 80); uiButton4.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton4.FillColor == Color.FromArgb(32, 56, 100)) { uiButton4.FillColor = Color.FromArgb(32, 56, 100); uiButton4.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton7_MouseEnter(object sender, EventArgs e) { if (uiButton7.FillColor == Color.FromArgb(146, 208, 80)) { uiButton7.FillColor = Color.FromArgb(146, 208, 80); uiButton7.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton7.FillColor == Color.FromArgb(32, 56, 100)) { uiButton7.FillColor = Color.FromArgb(32, 56, 100); uiButton7.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton6_MouseEnter(object sender, EventArgs e) { if (uiButton6.FillColor == Color.FromArgb(146, 208, 80)) { uiButton6.FillColor = Color.FromArgb(146, 208, 80); uiButton6.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton6.FillColor == Color.FromArgb(32, 56, 100)) { uiButton6.FillColor = Color.FromArgb(32, 56, 100); uiButton6.FillHoverColor = Color.FromArgb(32, 56, 100); } } private void uiButton5_MouseEnter(object sender, EventArgs e) { if (uiButton5.FillColor == Color.FromArgb(146, 208, 80)) { uiButton5.FillColor = Color.FromArgb(146, 208, 80); uiButton5.FillHoverColor = Color.FromArgb(146, 208, 80); } else if (uiButton5.FillColor == Color.FromArgb(32, 56, 100)) { uiButton5.FillColor = Color.FromArgb(32, 56, 100); uiButton5.FillHoverColor = Color.FromArgb(32, 56, 100); } } } }