This commit is contained in:
2025-12-11 09:52:50 +08:00
commit a4cbc24e25
74 changed files with 33284 additions and 0 deletions

209
FrmSetPenName.cs Normal file
View File

@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApp
{
public partial class FrmSetPenName : Form
{
string EventName = string.Empty;
string PenSerial = string.Empty;
int onoff = 1;
int once_valid = 0;
int is_enable = 1;
int is_contd = 1;
public uint once_buzz_count;
public delegate void btnSpeedChangeClickHandle(string name,string penserial, string speedStr,string speedType,int interval=0, int buzzcount=0,int onoff=0,int oncevalid=0);
public event btnSpeedChangeClickHandle SpeedChangeClickEvent;
public FrmSetPenName(string name,string penserial)
{
InitializeComponent();
EventName = name;
PenSerial = penserial;
}
private void FrmSetPenName_Load(object sender, EventArgs e)
{
SetDouble(transparentTabControl1);
transparentTabControl1.MakeTransparent();
transparentTabControl1.Visible = false;
if (EventName == "SetPenName")
{
transparentTabControl1.SelectedIndex = 0;
}
else if (EventName == "SetPenLed"|| EventName == "SetPenLedTemporary")
{
if (EventName == "SetPenLed") {
panel1.Visible = false;
}
radioFiring.Checked = true;
radioYes.Checked = true;
transparentTabControl1.SelectedIndex = 1;
var list = new List<LED_STATE>();
list.Add(new LED_STATE { ID = "BLUE_LIGHT_ON", Name = "蓝灯常亮" });
list.Add(new LED_STATE { ID = "BLUE_LIGHT_FLASHING", Name = "蓝灯闪烁" });
list.Add(new LED_STATE { ID = "GREEN_LIGHT_ON", Name = "绿灯常亮" });
list.Add(new LED_STATE { ID = "GREEN_LIGHT_FLASHING", Name = "绿灯闪烁" });
list.Add(new LED_STATE { ID = "RED_LIGHT_ON", Name = "红灯常亮" });
list.Add(new LED_STATE { ID = "RED_LIGHT_FLASHING", Name = "红灯闪烁" });
list.Add(new LED_STATE { ID = "YELLOW_LIGHT_ON", Name = "黄灯常亮" });
list.Add(new LED_STATE { ID = "YELLOW_LIGHT_FLASHING", Name = "黄灯闪烁" });
list.Add(new LED_STATE { ID = "PINK_LIGHT_ON", Name = "粉红灯常亮" });
list.Add(new LED_STATE { ID = "PINK_LIGHT_FLASHING", Name = "粉红灯闪烁" });
list.Add(new LED_STATE { ID = "LIGHT_BLUE_LIGHT_ON", Name = "浅蓝灯常亮" });
list.Add(new LED_STATE { ID = "LIGHT_BLUE_LIGHT_FLASHING", Name = "浅蓝灯闪烁" });
list.Add(new LED_STATE { ID = "WHITE_LIGHT_ON", Name = "白灯常亮" });
list.Add(new LED_STATE { ID = "WHITE_LIGHT_FLASHING", Name = "白灯闪烁" });
cmbLamp.ValueMember = "ID";
cmbLamp.DisplayMember = "Name";
cmbLamp.DataSource = list;
cmbLamp.SelectedIndex = 0;
var listtype = new List<LED_STATE>();
listtype.Add(new LED_STATE { ID = "POWER_ON_LED", Name = "上电默认状态" });
listtype.Add(new LED_STATE { ID = "BLE_CONNECT_LED", Name = "蓝牙连接状态" });
listtype.Add(new LED_STATE { ID = "LOW_POWER_WARNING_LED", Name = "低电量警告状态" });
listtype.Add(new LED_STATE { ID = "CHARGING_LED", Name = "充电状态" });
listtype.Add(new LED_STATE { ID = "STORAGE_FULL_LED", Name = "存储满状态" });
cmbLedType.ValueMember = "ID";
cmbLedType.DisplayMember = "Name";
cmbLedType.DataSource = listtype;
cmbLedType.SelectedIndex = 0;
}
//else if () {
//}
else if (EventName == "SetdownTime")
{
transparentTabControl1.SelectedIndex = 3;
}
else if (EventName == "SetPenBuzzer")
{
transparentTabControl1.SelectedIndex = 2;
radioopen.Checked = true;
radioalways.Checked = true;
}
}
public void SetDouble(Control contorl)
{
contorl.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(contorl, true, null);
}
private void btnSetName_Click(object sender, EventArgs e)
{
SpeedChangeClickEvent(EventName, PenSerial, txtSetName.Text.Trim(),"");
this.Close();
}
//设置指示灯
private void btnLamp_Click(object sender, EventArgs e)
{
SpeedChangeClickEvent(EventName, PenSerial, cmbLamp.SelectedValue.ToString(), cmbLedType.SelectedValue.ToString(), is_enable, is_contd, Convert.ToInt32(txtDuration.Text.Trim()));
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
SpeedChangeClickEvent(EventName, PenSerial, ShutdownTime.Text.Trim(), "");
this.Close();
}
private void btnBuzz_Click(object sender, EventArgs e)
{
SpeedChangeClickEvent(EventName, PenSerial, txtBuzz.Text.Trim(), txtBuzzTime.Text.Trim(),Convert.ToInt32(txtBuzzinTerval.Text.Trim()),Convert.ToInt32(txtBuzzCount.Text.Trim()),onoff, once_valid);
this.Close();
}
private void on_off(object sender, EventArgs e)
{
//把object类型赋值为当前按下的控件
RadioButton radioButtonClick = sender as RadioButton;
if (radioButtonClick.Checked)
{
switch (radioButtonClick.Name)
{
case "radioopen":
onoff=1;
break;
case "radioclose":
onoff=0;
break;
}
}
}
private void lifespanClick(object sender, EventArgs e)
{
//把object类型赋值为当前按下的控件
RadioButton radioButtonClick = sender as RadioButton;
if (radioButtonClick.Checked)
{
switch (radioButtonClick.Name)
{
case "radioalways":
once_valid = 0;
break;
case "radioonce":
once_valid = 1;
break;
}
}
}
private void firing_stop_click(object sender, EventArgs e)
{
//把object类型赋值为当前按下的控件
RadioButton radioButtonClick = sender as RadioButton;
if (radioButtonClick.Checked)
{
switch (radioButtonClick.Name)
{
case "radioFiring":
is_enable = 1;
break;
case "radioStop":
is_enable = 0;
break;
}
}
}
private void Yes_No_click(object sender, EventArgs e)
{
//把object类型赋值为当前按下的控件
RadioButton radioButtonClick = sender as RadioButton;
if (radioButtonClick.Checked)
{
switch (radioButtonClick.Name)
{
case "radioYes":
is_contd = 1;
break;
case "radioNo":
is_contd = 0;
break;
}
}
}
}
public class LED_STATE
{
public string ID { get; set; }
public string Name { get; set; }
}
}