FrmConfig.cs
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using SmartShelf.Common;
using SmartShelf.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SmartShelf
{
internal partial class FrmConfig :Form
{
internal FrmConfig( )
{
InitializeComponent();
}
private List<string> ColorList = new List<string>();
private void FrmPwd_Load(object sender, EventArgs e)
{
txtIP.Text = LEDManager.DefaultIP;
txtStaDmxId.Text = ConfigAppSettings.GetValue(Setting_Init.StatusLedDmx);
ColorList = new List<string>(){
"RGB=红绿蓝",
"RBG=红蓝绿",
"GRB=绿红蓝",
"GBR=绿蓝红",
"BRG=蓝红绿",
"BGR=蓝绿红"};
comBoxColor.Items.Clear();
int index = 0;
int i = 0;
foreach (string s in ColorList)
{
comBoxColor.Items.Add(s);
if (s.Contains(LEDManager.ColorRule))
{
index = i;
}
i++;
}
comBoxColor.SelectedIndex = 0;
if (LEDManager.ConnectionMode.Equals(0))
{
cmbConMode.SelectedIndex = 0;
}
else
{
cmbConMode.SelectedIndex = 1;
}
}
private void btnNext_Click(object sender, EventArgs e)
{
string ip = txtIP.Text;
ConfigAppSettings.SaveValue(Setting_Init.DefaultDeviceIP, ip);
LEDManager.DefaultIP = ip;
string dmxIds = txtStaDmxId.Text.Trim();
ConfigAppSettings.SaveValue(Setting_Init.StatusLedDmx, dmxIds);
LEDManager.LoadStatusDMX();
string colorText = comBoxColor.Text;
if (colorText.Length >= 7)
{
string result = colorText.Substring(0, 3);
ConfigAppSettings.SaveValue(Setting_Init.ColorRuleConfig, result);
LEDManager.ColorRule = result;
LogUtil.info("保存灯条颜色配置:" + Setting_Init.ColorRuleConfig +"="+ result);
}
int modeIndex = cmbConMode.SelectedIndex;
ConfigAppSettings.SaveValue(Setting_Init.ConnectionMode, modeIndex);
LogUtil.info("保存控制器连接方式:" + modeIndex);
MessageBox.Show("保存成功,重启软件后生效");
this.Close();
}
private void btnBack_Click(object sender, EventArgs e)
{
this.Close();
}
private void FrmPwd_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Enter))
{
btnNext_Click(null, null);
}
}
private void txtPwd_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.Equals(Keys.Enter))
{
btnNext_Click(null, null);
}else if (e.KeyCode.Equals(Keys.Escape))
{
btnBack_Click(null, null);
}
}
private void FrmPwd_Shown(object sender, EventArgs e)
{
txtIP.Focus();
}
}
}