CRVM-redis-6/client/SetAlarmRingForm.cs

142 lines
4.4 KiB
C#
Raw Permalink Normal View History

2025-11-07 02:02:31 +08:00
using System;
using System.Windows.Forms;
using CRVM.Entity;
using CRVM.CIDExcuter;
namespace CRVM
{
public partial class SetAlarmRingForm : Form
{
private AlarmRing alarmRing = new AlarmRing();
public SetAlarmRingForm()
{
InitializeComponent();
}
private void displayingingSetting_Load(object sender, EventArgs e)
{
initial();
}
private void OkDrawing_Click(object sender, EventArgs e)
{
setting();
//this.Close();
}
private void CancelDrawing_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnTry_Click(object sender, EventArgs e)
{
//void Ring(bool low,bool mid ,bool high)
string ringName = comboBox_RingType.Text.Trim();
if (ringName == "铃声1")
{
alarmRing.Ring(true, false, false);
}
else if (ringName == "铃声2")
{
alarmRing.Ring(false, true, false);
}
else if (ringName == "铃声3")
{
alarmRing.Ring(false, false, true);
}
else
{
MessageBox.Show("请选择铃声");
}
}
private void setting()
{
string ringName = comboBox_RingType.Text.Trim();
if (ringName == "铃声1")
{
SysParam.Instance.ringType = 0;
}
else if (ringName == "铃声2")
{
SysParam.Instance.ringType = 1;
}
else if (ringName == "铃声3")
{
SysParam.Instance.ringType = 2;
}
else
{
MessageBox.Show("请选择铃声");
return;
}
string ringFreStr = textBox_ringFre.Text.Trim();
short ringFreInt = (short)0;
if (!short.TryParse(ringFreStr, out ringFreInt))
{
MessageBox.Show("铃声播放间隔只能为数字!");
return;
}
if (ringFreInt <= 0 || ringFreInt > 30)
{
MessageBox.Show("铃声播放间隔只能为1~30之间的正整数");
return;
}
SysParam.Instance.ringFre = Convert.ToInt16(ringFreInt);
SysParam.Instance.isStand1Ring = checkBox_stand1.Checked ? true : false;
SysParam.Instance.isStand2Ring = checkBox_stand2.Checked ? true : false;
SysParam.Instance.isStand3Ring = checkBox_stand3.Checked ? true : false;
SysParam.Instance.isStand4Ring = checkBox_stand4.Checked ? true : false;
SysParam.Instance.isStand5Ring = checkBox_stand5.Checked ? true : false;
SysParam.Instance.isStand6Ring = checkBox_stand6.Checked ? true : false;
MessageBox.Show("保存成功!");
}
private void initial()
{
checkBox_stand1.Checked = SysParam.Instance.isStand1Ring ? true : false;
checkBox_stand2.Checked = SysParam.Instance.isStand2Ring ? true : false;
checkBox_stand3.Checked = SysParam.Instance.isStand3Ring ? true : false;
checkBox_stand4.Checked = SysParam.Instance.isStand4Ring ? true : false;
checkBox_stand5.Checked = SysParam.Instance.isStand5Ring ? true : false;
checkBox_stand6.Checked = SysParam.Instance.isStand6Ring ? true : false;
if (SysParam.Instance.ringFre <= 0 || SysParam.Instance.ringFre > 30)
{
textBox_ringFre.Text = "1";
SysParam.Instance.ringFre = (short)1;
}
else
{
textBox_ringFre.Text = SysParam.Instance.ringFre.ToString();
}
if (SysParam.Instance.ringType == 0)
{
comboBox_RingType.Text = "铃声1";
}
else if (SysParam.Instance.ringType == 1)
{
comboBox_RingType.Text = "铃声2";
}
else if (SysParam.Instance.ringType == 2)
{
comboBox_RingType.Text = "铃声3";
}
else
{
comboBox_RingType.Text = "铃声1";
SysParam.Instance.ringType = 0;
}
}
}
}