-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormComSelect.cs
More file actions
55 lines (42 loc) · 1.29 KB
/
FormComSelect.cs
File metadata and controls
55 lines (42 loc) · 1.29 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
namespace UM_Monitor
{
using System;
using System.IO.Ports;
using System.Windows.Forms;
public partial class FormComSelect : Form
{
public FormComSelect()
{
InitializeComponent();
updateConnectStatus();
this.button1_Click(null, null);
}
private void updateConnectStatus()
{
this.button2.Enabled = !SerialCom.IsConnected;
this.button3.Enabled = SerialCom.IsConnected;
}
private void button1_Click(object sender, EventArgs e)
{
// Get a list of serial port names.
string[] ports = SerialPort.GetPortNames();
this.listBox1.DataSource = ports;
}
private void button2_Click(object sender, EventArgs e)
{
bool res = SerialCom.Connect((string)this.listBox1.SelectedItem);
updateConnectStatus();
if (res)
{
Properties.Settings.Default.port = (string)this.listBox1.SelectedItem;
Properties.Settings.Default.Save();
this.Close();
}
}
private void button3_Click(object sender, EventArgs e)
{
SerialCom.Disconnect();
updateConnectStatus();
}
}
}