From 24c668cb423442108eda54ec4236da5b4b30f9e8 Mon Sep 17 00:00:00 2001 From: wangsr <gxhsoulstar@163.com> Date: Thu, 26 Oct 2023 18:45:13 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E8=87=AA=E5=8A=A8=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8D=95=E9=80=89=E5=8F=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/GelerWeterControlsEntity.cs | 16 ++++---- .../AutoControl/GelerWeterControl.cs | 21 ++++++---- .../AutoControl/InitAction.cs | 41 ++++++++++++++++++- .../AutoControl/RefreshAction.cs | 37 +++++++++++++---- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs index 47afe6d..761b0d0 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs @@ -12,14 +12,14 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity { public class GelerWeterControlsEntity { - public IBaseControl Line1 { get; set; } - public IBaseControl Line2 { get; set; } - public IBaseControl Line3 { get; set; } - public IBaseControl Line4 { get; set; } - public IBaseControl Line5 { get; set; } - public IBaseControl Line6 { get; set; } - public IBaseControl Line7 { get; set; } - public IBaseControl Line8 { get; set; } + public MCRadioButton Line1 { get; set; } + public MCRadioButton Line2 { get; set; } + public MCRadioButton Line3 { get; set; } + public MCRadioButton Line4 { get; set; } + public MCRadioButton Line5 { get; set; } + public MCRadioButton Line6 { get; set; } + public MCRadioButton Line7 { get; set; } + public MCRadioButton Line8 { get; set; } public MCCombobox ChooseMaterial1 { get; set; } public MCCombobox ChooseMaterial2 { get; set; } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs index 3b38dec..fb58eb6 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs @@ -615,14 +615,14 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl /// </summary> private void ControlImport() { - ControlsEntity.Line1 = GetBaseControl("Line1"); - ControlsEntity.Line2 = GetBaseControl("Line2"); - ControlsEntity.Line3 = GetBaseControl("Line3"); - ControlsEntity.Line4 = GetBaseControl("Line4"); - ControlsEntity.Line5 = GetBaseControl("Line5"); - ControlsEntity.Line6 = GetBaseControl("Line6"); - ControlsEntity.Line7 = GetBaseControl("Line7"); - ControlsEntity.Line8 = GetBaseControl("Line8"); + ControlsEntity.Line1 = GetMCRadioButtonControl("Line1"); + ControlsEntity.Line2 = GetMCRadioButtonControl("Line2"); + ControlsEntity.Line3 = GetMCRadioButtonControl("Line3"); + ControlsEntity.Line4 = GetMCRadioButtonControl("Line4"); + ControlsEntity.Line5 = GetMCRadioButtonControl("Line5"); + ControlsEntity.Line6 = GetMCRadioButtonControl("Line6"); + ControlsEntity.Line7 = GetMCRadioButtonControl("Line7"); + ControlsEntity.Line8 = GetMCRadioButtonControl("Line8"); ControlsEntity.ChooseMaterial1 = GetComboBoxControl("ChooseMaterial1"); ControlsEntity.ChooseMaterial2 = GetComboBoxControl("ChooseMaterial2"); @@ -672,6 +672,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl return McControls.First(x => x.Name == name) as MCCombobox; } + private MCRadioButton GetMCRadioButtonControl(string name) + { + return McControls.First(x => x.Name == name) as MCRadioButton; + } + #endregion } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs index 5c49fa0..d97e94a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs @@ -9,6 +9,7 @@ using Mesnac.Controls.Default; using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -21,6 +22,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl { GelerWeterControlsEntity ControlsEntity = new GelerWeterControlsEntity(); private List<Control> McControls; + Color backColor = Color.Transparent; public void Run(RuntimeParameter runtime) { @@ -32,11 +34,35 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl ControlImport(); ControlsEntity.Line1.MCValue = true; + ControlsEntity.Line1.BackColor = System.Drawing.Color.LightGreen; + + ControlsEntity.Line1.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line2.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line3.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line4.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line5.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line6.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line7.CheckedChanged += Mcradion_CheckedChanged; + ControlsEntity.Line8.CheckedChanged += Mcradion_CheckedChanged; ControlInitFromPLC(); } + private void Mcradion_CheckedChanged(object sender, EventArgs e) + { + MCRadioButton mCRadio = sender as MCRadioButton; + ControlsEntity.Line1.BackColor = backColor; + ControlsEntity.Line2.BackColor = backColor; + ControlsEntity.Line3.BackColor = backColor; + ControlsEntity.Line4.BackColor = backColor; + ControlsEntity.Line5.BackColor = backColor; + ControlsEntity.Line6.BackColor = backColor; + ControlsEntity.Line7.BackColor = backColor; + ControlsEntity.Line8.BackColor = backColor; + mCRadio.BackColor = Color.LightGreen; + } + /// <summary> /// 控件从Plc初始化 /// </summary> @@ -128,7 +154,14 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl /// </summary> private void ControlImport() { - ControlsEntity.Line1 = GetBaseControl("Line1"); + ControlsEntity.Line1 = GetMCRadioButtonControl("Line1"); + ControlsEntity.Line2 = GetMCRadioButtonControl("Line2"); + ControlsEntity.Line3 = GetMCRadioButtonControl("Line3"); + ControlsEntity.Line4 = GetMCRadioButtonControl("Line4"); + ControlsEntity.Line5 = GetMCRadioButtonControl("Line5"); + ControlsEntity.Line6 = GetMCRadioButtonControl("Line6"); + ControlsEntity.Line7 = GetMCRadioButtonControl("Line7"); + ControlsEntity.Line8 = GetMCRadioButtonControl("Line8"); ControlsEntity.ChooseMaterial1 = GetComboBoxControl("ChooseMaterial1"); ControlsEntity.ChooseMaterial2 = GetComboBoxControl("ChooseMaterial2"); @@ -161,5 +194,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl { return McControls.First(x => x.Name == name) as MCCombobox; } + + private MCRadioButton GetMCRadioButtonControl(string name) + { + return McControls.First(x => x.Name == name) as MCRadioButton; + } + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/RefreshAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/RefreshAction.cs index 9541eea..0e4e425 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/RefreshAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/RefreshAction.cs @@ -1,4 +1,6 @@ -using Mesnac.Action.Base; +using DataBlockHelper.Entity.DB2106Entity; +using HslCommunication.Instrument.DLT; +using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.AutoControl.DB; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; using Mesnac.Action.ChemicalWeighing.FreeDb; @@ -7,6 +9,7 @@ using Mesnac.Controls.Base; using Mesnac.Controls.Default; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -32,6 +35,10 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl } + + + #region 控件初始化 + /// <summary> /// 控件从Plc初始化 /// </summary> @@ -220,6 +227,10 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl } + #endregion + + #region 辅助类 + /// <summary> /// 单选选择 /// </summary> @@ -269,14 +280,14 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl /// </summary> private void ControlImport() { - ControlsEntity.Line1 = GetBaseControl("Line1"); - ControlsEntity.Line2 = GetBaseControl("Line2"); - ControlsEntity.Line3 = GetBaseControl("Line3"); - ControlsEntity.Line4 = GetBaseControl("Line4"); - ControlsEntity.Line5 = GetBaseControl("Line5"); - ControlsEntity.Line6 = GetBaseControl("Line6"); - ControlsEntity.Line7 = GetBaseControl("Line7"); - ControlsEntity.Line8 = GetBaseControl("Line8"); + ControlsEntity.Line1 = GetMCRadioButtonControl("Line1"); + ControlsEntity.Line2 = GetMCRadioButtonControl("Line2"); + ControlsEntity.Line3 = GetMCRadioButtonControl("Line3"); + ControlsEntity.Line4 = GetMCRadioButtonControl("Line4"); + ControlsEntity.Line5 = GetMCRadioButtonControl("Line5"); + ControlsEntity.Line6 = GetMCRadioButtonControl("Line6"); + ControlsEntity.Line7 = GetMCRadioButtonControl("Line7"); + ControlsEntity.Line8 = GetMCRadioButtonControl("Line8"); ControlsEntity.ChooseMaterial1 = GetComboBoxControl("ChooseMaterial1"); ControlsEntity.ChooseMaterial2 = GetComboBoxControl("ChooseMaterial2"); @@ -309,5 +320,13 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl { return McControls.First(x => x.Name == name) as MCCombobox; } + + private MCRadioButton GetMCRadioButtonControl(string name) + { + return McControls.First(x => x.Name == name) as MCRadioButton; + } + + #endregion + } }