-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfrequencyManagerForm.cs
135 lines (110 loc) · 4.73 KB
/
frequencyManagerForm.cs
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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 opentuner
{
public partial class frequencyManagerForm : Form
{
private List<StoredFrequency> stored_frequencies = null;
public frequencyManagerForm(List<StoredFrequency> _stored_frequencies)
{
InitializeComponent();
stored_frequencies = _stored_frequencies;
load_frequencies();
}
public void load_frequencies()
{
listFreq.Items.Clear();
lblFreq.Text = "";
lblName.Text = "";
lblOffset.Text = "";
lblSymbolRate.Text = "";
lblRFInput.Text = "";
for (int c = 0; c < stored_frequencies.Count; c++)
{
listFreq.Items.Add(stored_frequencies[c].Name);
}
if (listFreq.Items.Count > 0)
listFreq.SelectedIndex = 0;
}
public void show_frequency(int index)
{
if (index < stored_frequencies.Count)
{
lblFreq.Text = stored_frequencies[index].Frequency.ToString();
lblName.Text = stored_frequencies[index].Name.ToString();
lblOffset.Text = stored_frequencies[index].Offset.ToString();
lblSymbolRate.Text = stored_frequencies[index].SymbolRate.ToString();
if (stored_frequencies[index].RFInput == 1)
lblRFInput.Text = "A";
else
lblRFInput.Text = "B";
}
}
private void listFreq_SelectedIndexChanged(object sender, EventArgs e)
{
show_frequency(listFreq.SelectedIndex);
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (listFreq.SelectedIndex > -1)
{
if (MessageBox.Show("Are you sure you want to delete '" + stored_frequencies[listFreq.SelectedIndex].Name + "'?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
stored_frequencies.RemoveAt(listFreq.SelectedIndex);
load_frequencies();
}
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (listFreq.SelectedIndex > -1)
{
int index = listFreq.SelectedIndex;
editStoredFrequencyForm editForm = new editStoredFrequencyForm();
editForm.txtName.Text = stored_frequencies[index].Name;
editForm.txtFreq.Text = stored_frequencies[index].Frequency.ToString();
editForm.txtOffset.Text = stored_frequencies[index].Offset.ToString();
editForm.txtSR.Text = stored_frequencies[index].SymbolRate.ToString();
editForm.comboRFInput.SelectedIndex = stored_frequencies[index].RFInput - 1;
if (editForm.ShowDialog() == DialogResult.OK)
{
stored_frequencies[index].Name = editForm.txtName.Text;
stored_frequencies[index].Frequency = Convert.ToUInt32(editForm.txtFreq.Text);
stored_frequencies[index].Offset = Convert.ToUInt32(editForm.txtOffset.Text);
stored_frequencies[index].SymbolRate = Convert.ToUInt32(editForm.txtSR.Text);
stored_frequencies[index].RFInput = Convert.ToByte(editForm.comboRFInput.SelectedIndex + 1);
load_frequencies();
}
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
editStoredFrequencyForm editForm = new editStoredFrequencyForm();
if (editForm.ShowDialog() == DialogResult.OK)
{
StoredFrequency sf = new StoredFrequency();
sf.Name = editForm.txtName.Text;
sf.Frequency = Convert.ToUInt32(editForm.txtFreq.Text);
sf.Offset = Convert.ToUInt32(editForm.txtOffset.Text);
sf.SymbolRate = Convert.ToUInt32(editForm.txtSR.Text);
sf.RFInput = Convert.ToByte(editForm.comboRFInput.SelectedIndex + 1);
stored_frequencies.Add(sf);
load_frequencies();
}
}
private void frequencyManagerForm_Load(object sender, EventArgs e)
{
}
}
}