61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace YiDa_WinForm
|
|
{
|
|
public partial class StrengthTestUploadForm : Form
|
|
{
|
|
// 对外暴露的选择结果
|
|
public bool IsMoldProductionSelected { get; private set; }
|
|
public bool IsTimedAlarmSelected { get; private set; }
|
|
public int TimedInterval { get; private set; }
|
|
|
|
public StrengthTestUploadForm()
|
|
{
|
|
InitializeComponent();
|
|
// 初始化默认值
|
|
checkBoxMoldProduction.Checked = true;
|
|
checkBoxTimedAlarm.Checked = true;
|
|
textBoxInterval.Text = "120";
|
|
}
|
|
|
|
private void buttonConfirm_Click(object sender, EventArgs e)
|
|
{
|
|
// 获取用户选择
|
|
IsMoldProductionSelected = checkBoxMoldProduction.Checked;
|
|
IsTimedAlarmSelected = checkBoxTimedAlarm.Checked;
|
|
|
|
// 校验时间间隔输入
|
|
if (IsTimedAlarmSelected)
|
|
{
|
|
if (int.TryParse(textBoxInterval.Text, out int interval) && interval > 0)
|
|
{
|
|
TimedInterval = interval;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("请输入有效的正整数时间间隔!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
// 确认关闭弹窗
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
{
|
|
// 取消关闭弹窗
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
private void checkBoxTimedAlarm_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
// 根据勾选状态控制输入框可用性
|
|
textBoxInterval.Enabled = checkBoxTimedAlarm.Checked;
|
|
labelInterval.Enabled = checkBoxTimedAlarm.Checked;
|
|
}
|
|
}
|
|
} |