更新UI界面
This commit is contained in:
19
全自动水压检测仪/NormalTemperatureMode.Designer.cs
generated
19
全自动水压检测仪/NormalTemperatureMode.Designer.cs
generated
@@ -627,17 +627,17 @@ namespace 全自动水压检测仪
|
||||
//
|
||||
this.uiTableLayoutPanel5.ColumnCount = 1;
|
||||
this.uiTableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.uiTableLayoutPanel5.Controls.Add(this.uiPanel9, 0, 0);
|
||||
this.uiTableLayoutPanel5.Controls.Add(this.uiPanel18, 0, 1);
|
||||
this.uiTableLayoutPanel5.Controls.Add(this.uiPanel12, 0, 2);
|
||||
// 隐藏阀门状态区域 - 已移至状态设置弹窗
|
||||
// this.uiTableLayoutPanel5.Controls.Add(this.uiPanel9, 0, 0);
|
||||
this.uiTableLayoutPanel5.Controls.Add(this.uiPanel18, 0, 0);
|
||||
this.uiTableLayoutPanel5.Controls.Add(this.uiPanel12, 0, 1);
|
||||
this.uiTableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.uiTableLayoutPanel5.Location = new System.Drawing.Point(8, 8);
|
||||
this.uiTableLayoutPanel5.Name = "uiTableLayoutPanel5";
|
||||
this.uiTableLayoutPanel5.Padding = new System.Windows.Forms.Padding(1);
|
||||
this.uiTableLayoutPanel5.RowCount = 3;
|
||||
this.uiTableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 24F));
|
||||
this.uiTableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 38F));
|
||||
this.uiTableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 38F));
|
||||
this.uiTableLayoutPanel5.RowCount = 2;
|
||||
this.uiTableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.uiTableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.uiTableLayoutPanel5.Size = new System.Drawing.Size(766, 598);
|
||||
this.uiTableLayoutPanel5.TabIndex = 1;
|
||||
this.uiTableLayoutPanel5.TagString = null;
|
||||
@@ -2036,11 +2036,12 @@ namespace 全自动水压检测仪
|
||||
// uiPanel1
|
||||
//
|
||||
this.uiPanel1.BackColor = System.Drawing.Color.White;
|
||||
this.uiPanel1.Controls.Add(this.uiPanel17);
|
||||
// 隐藏温度模式和阀门状态显示 - 已移至状态设置弹窗
|
||||
// this.uiPanel1.Controls.Add(this.uiPanel17);
|
||||
this.uiPanel1.Controls.Add(this.uiButton14);
|
||||
this.uiPanel1.Controls.Add(this.uiPanel4);
|
||||
this.uiPanel1.Controls.Add(this.uiPanel3);
|
||||
this.uiPanel1.Controls.Add(this.uiPanel2);
|
||||
// this.uiPanel1.Controls.Add(this.uiPanel2);
|
||||
this.uiPanel1.FillColor = System.Drawing.Color.White;
|
||||
this.uiPanel1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.uiPanel1.Location = new System.Drawing.Point(12, 13);
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace 全自动水压检测仪
|
||||
BoolSignal boolSignal1 = new BoolSignal();
|
||||
private Coeffiicientsetting _coeffiicientsetting;
|
||||
private ScanImport _scanImport;
|
||||
private StatusSettingsForm _statusSettingsForm; // 新增状态设置窗体
|
||||
|
||||
public List<ConductivityTestData> CurrentReport;
|
||||
private Report _report;
|
||||
@@ -896,8 +897,8 @@ namespace 全自动水压检测仪
|
||||
System.Diagnostics.Debug.WriteLine($"[NormalTemperatureMode] 管理员登录,显示录入系统按钮");
|
||||
}
|
||||
|
||||
string plcIp = "192.168.1.10";
|
||||
//string plcIp = "127.0.0.1";
|
||||
// string plcIp = "192.168.1.10";
|
||||
string plcIp = "127.0.0.1";
|
||||
bool initSuccess = Data.ModbusResourceManager.Instance.Init(plcIp, 502);
|
||||
if (!initSuccess)
|
||||
{
|
||||
@@ -917,7 +918,8 @@ namespace 全自动水压检测仪
|
||||
|
||||
ma = new Function(_modbusMaster);
|
||||
c = new DataChange();
|
||||
_modbusMaster?.WriteSingleCoil(1, 30, true);
|
||||
// 暂时注释
|
||||
// _modbusMaster?.WriteSingleCoil(1, 30, true);
|
||||
boolSignal1.OnRisingEdge += BoolSignal1_OnRisingEdge;
|
||||
|
||||
// 在 Load 完成初始化后再启动定时器,避免定时器在 c / ma 未就绪时触发访问导致异常
|
||||
@@ -1152,14 +1154,14 @@ namespace 全自动水压检测仪
|
||||
pressStopwatch.Stop();
|
||||
if (pressStopwatch.ElapsedMilliseconds >= LONG_PRESS_THRESHOLD)
|
||||
{
|
||||
// 执行长按操作
|
||||
// 执行长按操作 - 打开系数设置
|
||||
EnterFunction();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// // 执行点击操作(可选)
|
||||
// ClickFunction();
|
||||
//}
|
||||
else
|
||||
{
|
||||
// 执行点击操作 - 打开状态设置窗体
|
||||
OpenStatusSettingsForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void EnterFunction()
|
||||
@@ -1402,6 +1404,59 @@ namespace 全自动水压检测仪
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态设置窗体的显示
|
||||
/// </summary>
|
||||
public void UpdateStatusSettingsForm(StatusSettingsForm form)
|
||||
{
|
||||
if (form == null || form.IsDisposed)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 更新温度模式状态
|
||||
var light1State = uiLight1 != null ? uiLight1.State : UILightState.Off;
|
||||
var light2State = uiLight2 != null ? uiLight2.State : UILightState.Off;
|
||||
var modeText = uiLabel11 != null ? uiLabel11.Text : "";
|
||||
|
||||
form.UpdateTempModeStatus(light1State, light2State, modeText);
|
||||
|
||||
// 更新阀门状态
|
||||
form.UpdateValveStatus(
|
||||
uiLight3 != null ? uiLight3.State : UILightState.Off,
|
||||
uiLight4 != null ? uiLight4.State : UILightState.Off,
|
||||
uiLight5 != null ? uiLight5.State : UILightState.Off,
|
||||
uiLight6 != null ? uiLight6.State : UILightState.Off,
|
||||
uiLight7 != null ? uiLight7.State : UILightState.Off,
|
||||
uiLight8 != null ? uiLight8.State : UILightState.Off,
|
||||
uiLight9 != null ? uiLight9.State : UILightState.Off,
|
||||
uiLight10 != null ? uiLight10.State : UILightState.Off,
|
||||
uiLight11 != null ? uiLight11.State : UILightState.Off,
|
||||
uiLight12 != null ? uiLight12.State : UILightState.Off
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"更新状态设置窗体失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开状态设置窗体
|
||||
/// </summary>
|
||||
private void OpenStatusSettingsForm()
|
||||
{
|
||||
if (_statusSettingsForm == null || _statusSettingsForm.IsDisposed)
|
||||
{
|
||||
_statusSettingsForm = new StatusSettingsForm(this);
|
||||
_statusSettingsForm.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_statusSettingsForm.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler ReturnToLoginRequested;
|
||||
//返回登录
|
||||
private void uiButton9_Click(object sender, EventArgs e)
|
||||
|
||||
152
全自动水压检测仪/StatusSettingsForm.Designer.cs
generated
Normal file
152
全自动水压检测仪/StatusSettingsForm.Designer.cs
generated
Normal file
@@ -0,0 +1,152 @@
|
||||
namespace 全自动水压检测仪
|
||||
{
|
||||
partial class StatusSettingsForm
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
// 控件声明
|
||||
private Sunny.UI.UILight uiLight1_Status;
|
||||
private Sunny.UI.UILight uiLight2_Status;
|
||||
private Sunny.UI.UILight uiLight3_Status;
|
||||
private Sunny.UI.UILight uiLight4_Status;
|
||||
private Sunny.UI.UILight uiLight5_Status;
|
||||
private Sunny.UI.UILight uiLight6_Status;
|
||||
private Sunny.UI.UILight uiLight7_Status;
|
||||
private Sunny.UI.UILight uiLight8_Status;
|
||||
private Sunny.UI.UILight uiLight9_Status;
|
||||
private Sunny.UI.UILight uiLight10_Status;
|
||||
private Sunny.UI.UILight uiLight11_Status;
|
||||
private Sunny.UI.UILight uiLight12_Status;
|
||||
private Sunny.UI.UILabel uiLabel11_Status;
|
||||
private Sunny.UI.UIButton uiButton_Close;
|
||||
private Sunny.UI.UIPanel mainPanel;
|
||||
private Sunny.UI.UIPanel tempModePanel;
|
||||
private Sunny.UI.UIPanel valveStatusPanel;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mainPanel = new Sunny.UI.UIPanel();
|
||||
this.tempModePanel = new Sunny.UI.UIPanel();
|
||||
this.valveStatusPanel = new Sunny.UI.UIPanel();
|
||||
this.uiLight1_Status = new Sunny.UI.UILight();
|
||||
this.uiLight2_Status = new Sunny.UI.UILight();
|
||||
this.uiLight3_Status = new Sunny.UI.UILight();
|
||||
this.uiLight4_Status = new Sunny.UI.UILight();
|
||||
this.uiLight5_Status = new Sunny.UI.UILight();
|
||||
this.uiLight6_Status = new Sunny.UI.UILight();
|
||||
this.uiLight7_Status = new Sunny.UI.UILight();
|
||||
this.uiLight8_Status = new Sunny.UI.UILight();
|
||||
this.uiLight9_Status = new Sunny.UI.UILight();
|
||||
this.uiLight10_Status = new Sunny.UI.UILight();
|
||||
this.uiLight11_Status = new Sunny.UI.UILight();
|
||||
this.uiLight12_Status = new Sunny.UI.UILight();
|
||||
this.uiLabel11_Status = new Sunny.UI.UILabel();
|
||||
this.uiButton_Close = new Sunny.UI.UIButton();
|
||||
|
||||
this.SuspendLayout();
|
||||
|
||||
// mainPanel
|
||||
this.mainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mainPanel.Location = new System.Drawing.Point(0, 35);
|
||||
this.mainPanel.Name = "mainPanel";
|
||||
this.mainPanel.Size = new System.Drawing.Size(850, 515);
|
||||
this.mainPanel.TabIndex = 0;
|
||||
this.mainPanel.FillColor = System.Drawing.Color.White;
|
||||
|
||||
// tempModePanel - 温度模式区域
|
||||
this.tempModePanel.Location = new System.Drawing.Point(20, 20);
|
||||
this.tempModePanel.Size = new System.Drawing.Size(810, 120);
|
||||
this.tempModePanel.FillColor = System.Drawing.Color.FromArgb(245, 245, 245);
|
||||
this.tempModePanel.Radius = 8;
|
||||
|
||||
// valveStatusPanel - 阀门状态区域
|
||||
this.valveStatusPanel.Location = new System.Drawing.Point(20, 160);
|
||||
this.valveStatusPanel.Size = new System.Drawing.Size(810, 280);
|
||||
this.valveStatusPanel.FillColor = System.Drawing.Color.FromArgb(245, 245, 245);
|
||||
this.valveStatusPanel.Radius = 8;
|
||||
|
||||
// 温度模式指示灯和标签
|
||||
this.uiLight1_Status.Location = new System.Drawing.Point(30, 50);
|
||||
this.uiLight1_Status.Size = new System.Drawing.Size(30, 30);
|
||||
this.uiLight1_Status.OnColor = System.Drawing.Color.Blue;
|
||||
this.uiLight1_Status.OffColor = System.Drawing.Color.LightGray;
|
||||
|
||||
this.uiLight2_Status.Location = new System.Drawing.Point(30, 90);
|
||||
this.uiLight2_Status.Size = new System.Drawing.Size(30, 30);
|
||||
this.uiLight2_Status.OnColor = System.Drawing.Color.Red;
|
||||
this.uiLight2_Status.OffColor = System.Drawing.Color.LightGray;
|
||||
|
||||
this.uiLabel11_Status.Location = new System.Drawing.Point(80, 50);
|
||||
this.uiLabel11_Status.Size = new System.Drawing.Size(200, 30);
|
||||
this.uiLabel11_Status.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
|
||||
|
||||
// 阀门状态指示灯 - 使用循环布局
|
||||
int startX = 30, startY = 30, spacing = 150, row = 0, col = 0;
|
||||
var valveLights = new[] {
|
||||
(this.uiLight3_Status, "高压出阀"),
|
||||
(this.uiLight4_Status, "高压进阀"),
|
||||
(this.uiLight5_Status, "常温抽水阀"),
|
||||
(this.uiLight6_Status, "常温水箱加水阀"),
|
||||
(this.uiLight7_Status, "高温抽水阀"),
|
||||
(this.uiLight8_Status, "空气抽气阀"),
|
||||
(this.uiLight9_Status, "加热状态"),
|
||||
(this.uiLight10_Status, "常温回水阀"),
|
||||
(this.uiLight11_Status, "高温水箱加水阀"),
|
||||
(this.uiLight12_Status, "高温回水阀")
|
||||
};
|
||||
|
||||
foreach (var (light, label) in valveLights)
|
||||
{
|
||||
light.Location = new System.Drawing.Point(startX + col * spacing, startY + row * 50);
|
||||
light.Size = new System.Drawing.Size(25, 25);
|
||||
light.OnColor = System.Drawing.Color.Green;
|
||||
light.OffColor = System.Drawing.Color.LightGray;
|
||||
this.valveStatusPanel.Controls.Add(light);
|
||||
|
||||
var lbl = new Sunny.UI.UILabel();
|
||||
lbl.Location = new System.Drawing.Point(startX + col * spacing + 35, startY + row * 50);
|
||||
lbl.Size = new System.Drawing.Size(110, 25);
|
||||
lbl.Text = label;
|
||||
lbl.Font = new System.Drawing.Font("微软雅黑", 9F);
|
||||
this.valveStatusPanel.Controls.Add(lbl);
|
||||
|
||||
col++;
|
||||
if (col >= 5) { col = 0; row++; }
|
||||
}
|
||||
|
||||
// 关闭按钮
|
||||
this.uiButton_Close.Location = new System.Drawing.Point(350, 460);
|
||||
this.uiButton_Close.Size = new System.Drawing.Size(150, 40);
|
||||
this.uiButton_Close.Text = "关闭";
|
||||
this.uiButton_Close.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiButton_Close.Click += new System.EventHandler(this.uiButton_Close_Click);
|
||||
|
||||
// 添加控件到面板
|
||||
this.tempModePanel.Controls.AddRange(new System.Windows.Forms.Control[] {
|
||||
this.uiLight1_Status, this.uiLight2_Status, this.uiLabel11_Status
|
||||
});
|
||||
|
||||
this.mainPanel.Controls.AddRange(new System.Windows.Forms.Control[] {
|
||||
this.tempModePanel, this.valveStatusPanel, this.uiButton_Close
|
||||
});
|
||||
|
||||
this.Controls.Add(this.mainPanel);
|
||||
|
||||
// 窗体设置
|
||||
this.ClientSize = new System.Drawing.Size(850, 550);
|
||||
this.Name = "StatusSettingsForm";
|
||||
this.Text = "状态监控设置";
|
||||
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
113
全自动水压检测仪/StatusSettingsForm.cs
Normal file
113
全自动水压检测仪/StatusSettingsForm.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using Sunny.UI;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace 全自动水压检测仪
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态设置弹窗 - 显示温度模式和阀门状态
|
||||
/// </summary>
|
||||
public partial class StatusSettingsForm : UIForm
|
||||
{
|
||||
private System.Windows.Forms.Timer _updateTimer;
|
||||
private NormalTemperatureMode _parentForm;
|
||||
|
||||
public StatusSettingsForm(NormalTemperatureMode parentForm)
|
||||
{
|
||||
_parentForm = parentForm;
|
||||
InitializeComponent();
|
||||
|
||||
// 设置窗体属性
|
||||
this.Text = "状态监控设置";
|
||||
this.Width = 850;
|
||||
this.Height = 550;
|
||||
this.StartPosition = FormStartPosition.CenterParent;
|
||||
this.ShowInTaskbar = false;
|
||||
|
||||
// 初始化更新定时器
|
||||
_updateTimer = new System.Windows.Forms.Timer();
|
||||
_updateTimer.Interval = 500; // 每500ms更新一次
|
||||
_updateTimer.Tick += UpdateTimer_Tick;
|
||||
|
||||
this.Load += StatusSettingsForm_Load;
|
||||
this.FormClosing += StatusSettingsForm_FormClosing;
|
||||
}
|
||||
|
||||
private void UpdateTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
UpdateStatusDisplay();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"更新状态显示失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatusDisplay()
|
||||
{
|
||||
if (_parentForm == null || _parentForm.IsDisposed)
|
||||
return;
|
||||
|
||||
// 从父窗体获取状态并更新
|
||||
_parentForm.UpdateStatusSettingsForm(this);
|
||||
}
|
||||
|
||||
// 公共方法供父窗体调用更新状态
|
||||
public void UpdateTempModeStatus(UILightState light1State, UILightState light2State, string modeText)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new Action(() => UpdateTempModeStatus(light1State, light2State, modeText)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (uiLight1_Status != null) uiLight1_Status.State = light1State;
|
||||
if (uiLight2_Status != null) uiLight2_Status.State = light2State;
|
||||
if (uiLabel11_Status != null) uiLabel11_Status.Text = modeText;
|
||||
}
|
||||
|
||||
public void UpdateValveStatus(
|
||||
UILightState light3, UILightState light4, UILightState light5,
|
||||
UILightState light6, UILightState light7, UILightState light8,
|
||||
UILightState light9, UILightState light10, UILightState light11, UILightState light12)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new Action(() => UpdateValveStatus(light3, light4, light5, light6, light7, light8, light9, light10, light11, light12)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (uiLight3_Status != null) uiLight3_Status.State = light3;
|
||||
if (uiLight4_Status != null) uiLight4_Status.State = light4;
|
||||
if (uiLight5_Status != null) uiLight5_Status.State = light5;
|
||||
if (uiLight6_Status != null) uiLight6_Status.State = light6;
|
||||
if (uiLight7_Status != null) uiLight7_Status.State = light7;
|
||||
if (uiLight8_Status != null) uiLight8_Status.State = light8;
|
||||
if (uiLight9_Status != null) uiLight9_Status.State = light9;
|
||||
if (uiLight10_Status != null) uiLight10_Status.State = light10;
|
||||
if (uiLight11_Status != null) uiLight11_Status.State = light11;
|
||||
if (uiLight12_Status != null) uiLight12_Status.State = light12;
|
||||
}
|
||||
|
||||
private void StatusSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
_updateTimer?.Start();
|
||||
UpdateStatusDisplay();
|
||||
}
|
||||
|
||||
private void StatusSettingsForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
_updateTimer?.Stop();
|
||||
_updateTimer?.Dispose();
|
||||
}
|
||||
|
||||
private void uiButton_Close_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,12 @@
|
||||
<Compile Include="ScanImport.Designer.cs">
|
||||
<DependentUpon>ScanImport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StatusSettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StatusSettingsForm.Designer.cs">
|
||||
<DependentUpon>StatusSettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NormalTemperatureMode.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user