-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatters.cs
238 lines (215 loc) · 6.53 KB
/
formatters.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System.Globalization;
using Microsoft.UI;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
namespace T41_UI.Views;
public class FreqFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
NumberFormatInfo format = new() {
NumberDecimalDigits = 0,
NumberGroupSeparator = parameter != null ? (string)parameter : "."
};
return ((long)value).ToString("N", format);
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class BandFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
string band = "";
switch((int)value) {
case 0: // BAND_80M:
band = "80m";
break;
case 1: // BAND_40M:
band = "40m";
break;
case 2: // BAND_20M:
band = "20m";
break;
case 3: // BAND_17M:
band = "17m";
break;
case 4: // BAND_15M:
band = "15m";
break;
case 5: // BAND_12M:
band = "12m";
break;
case 6: // BAND_10M:
band = "10m";
break;
default:
band = "40m";
break;
}
return band;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class ModeFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
string mode = "";
switch((int)value) {
case 0: // SSB_MODE:
mode = "SSB";
break;
case 1: // CW_MODE:
mode = "CW";
break;
case 2: // DATA_MODE:
mode = "DATA";
break;
default:
mode = "SSB";
break;
}
return mode;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class DemodFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
string demod = "";
switch((int)value) {
case 0: // DEMOD_USB:
demod = "(USB)";
break;
case 1: // DEMOD_LSB:
demod = "(LSB)";
break;
case 2: // DEMOD_AM:
demod = "(AM)";
break;
case 3: // DEMOD_NFM:
demod = "(NFM)";
break;
case 4: // DEMOD_PSK31_WAV:
demod = "(PSK31.wav)";
break;
case 5: // DEMOD_PSK31:
demod = "(PSK31)";
break;
case 6: // DEMOD_FT8_WAV:
demod = "(FT8.wav)";
break;
case 7: // DEMOD_FT8:
demod = "(FT8)";
break;
case 8: // DEMOD_SAM:
demod = "(SAM)";
break;
default:
demod = "(LSB)";
break;
}
return demod;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class AgcFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
// const char *agcOpts[] = { "Off", "L", "S", "M", "F" };
string mode = "";
switch((int)value) {
case 0:
mode = "Off";
break;
case 1:
mode = "L";
break;
case 2:
mode = "S";
break;
case 3:
mode = "M";
break;
case 4:
mode = "F";
break;
default:
mode = "Off";
break;
}
return mode;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class PwrFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
return ((int)value).ToString("D") + " Watts";
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class NfFlagColorFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
//return (SolidColorBrush)new SolidColorBrush((int)value == 1 ? Colors.Lime : Colors.White);
return new SolidColorBrush((int)value == 1 ? Colors.Lime : Colors.White);
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class NfFlagTextFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
return (int)value == 1 ? "On" : "Off";
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
/*
public class NcoFreqBWFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
return ; // 360 for 3k filter, 0 NCOFreq
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class BWFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
return 24;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
public class NcoFreqFormatter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, string language) {
return 384;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) {
throw new NotImplementedException();
}
}
*/
//public class TimeFormatter : IValueConverter {
// public object Convert(object value, Type targetType, object parameter, string language) {
// return "PST: " + DateTime.Now.ToString("H:mm:ss");
// }
//
// public object ConvertBack(object value, Type targetType, object parameter, string language) {
// throw new NotImplementedException();
// }
//}
//public class Formatter : IValueConverter {
// public object Convert(object value, Type targetType, object parameter, string language) {
// return ;
// }
//
// public object ConvertBack(object value, Type targetType, object parameter, string language) {
// throw new NotImplementedException();
// }
//}