HamBook – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using Configuration; |
2 | using System; |
||
3 | using System.Collections.Generic; |
||
4 | using System.ComponentModel; |
||
5 | using System.Data; |
||
6 | using System.Drawing; |
||
7 | using System.IO.Ports; |
||
8 | using System.Linq; |
||
9 | using System.Text; |
||
10 | using System.Threading; |
||
11 | using System.Threading.Tasks; |
||
12 | using System.Windows.Forms; |
||
13 | |||
14 | namespace HamBook |
||
15 | { |
||
16 | public partial class SettingsForm : Form |
||
17 | { |
||
18 | public bool SaveOnClose { get; private set; } |
||
19 | |||
20 | private Configuration.Configuration _configuration; |
||
21 | |||
22 | public SettingsForm() |
||
23 | { |
||
24 | InitializeComponent(); |
||
25 | } |
||
26 | public SettingsForm(Configuration.Configuration configuration, CancellationToken cancellationToken) : this() |
||
27 | { |
||
28 | _configuration = configuration; |
||
29 | } |
||
30 | |||
31 | private void SettingsForm_Load(object sender, EventArgs e) |
||
32 | { |
||
33 | var ports = SerialPort.GetPortNames(); |
||
34 | |||
35 | if (ports != null && ports.Length != 0) |
||
36 | { |
||
37 | foreach (var port in ports) |
||
38 | { |
||
39 | comboBox1.Items.Add(port); |
||
40 | } |
||
41 | |||
42 | comboBox1.Text = ports[0]; |
||
43 | } |
||
44 | |||
45 | // Create data bindings. |
||
46 | comboBox1.DataBindings.Add(nameof(comboBox1.Text), _configuration, nameof(_configuration.Port), true, DataSourceUpdateMode.OnPropertyChanged); |
||
47 | comboBox2.DataBindings.Add(nameof(comboBox2.Text), _configuration, nameof(_configuration.Speed), true, DataSourceUpdateMode.OnPropertyChanged); |
||
48 | comboBox3.DataBindings.Add(nameof(comboBox3.Text), _configuration, nameof(_configuration.DataBits), true, DataSourceUpdateMode.OnPropertyChanged); |
||
49 | comboBox4.DataBindings.Add(nameof(comboBox4.Text), _configuration, nameof(_configuration.Parity), true, DataSourceUpdateMode.OnPropertyChanged); |
||
50 | comboBox5.DataBindings.Add(nameof(comboBox5.Text), _configuration, nameof(_configuration.StopBits), true, DataSourceUpdateMode.OnPropertyChanged); |
||
51 | |||
52 | comboBox7.DataBindings.Add(nameof(comboBox7.Text), _configuration, nameof(_configuration.Radio), true, DataSourceUpdateMode.OnPropertyChanged); |
||
53 | } |
||
54 | |||
55 | private void button1_Click(object sender, EventArgs e) |
||
56 | { |
||
57 | SaveOnClose = true; |
||
58 | Close(); |
||
59 | } |
||
60 | |||
61 | private void button2_Click(object sender, EventArgs e) |
||
62 | { |
||
63 | SaveOnClose = false; |
||
64 | Close(); |
||
65 | } |
||
66 | } |
||
67 | } |