HamBook – Blame information for rev 40
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
15 | office | 1 | using Configuration; |
2 | using HamBook.Properties; |
||
3 | using HamBook.Radios; |
||
4 | using HamBook.Radios.Generic; |
||
16 | office | 5 | using HamBook.Utilities.Serialization; |
15 | office | 6 | using Serilog; |
7 | using System; |
||
8 | using System.Collections; |
||
9 | using System.Collections.Concurrent; |
||
10 | using System.Collections.Generic; |
||
11 | using System.ComponentModel; |
||
12 | using System.Data; |
||
13 | using System.Diagnostics; |
||
14 | using System.Drawing; |
||
15 | using System.IO; |
||
16 | using System.Linq; |
||
17 | using System.Reflection; |
||
18 | using System.Text; |
||
19 | using System.Text.RegularExpressions; |
||
20 | using System.Threading; |
||
21 | using System.Threading.Tasks; |
||
22 | using System.Windows.Forms; |
||
23 | |||
24 | namespace HamBook |
||
25 | { |
||
26 | public partial class MemoryOrganizerForm : Form |
||
27 | { |
||
28 | private Configuration.Configuration Configuration { get; set; } |
||
29 | |||
30 | private CatAssemblies _catAssemblies; |
||
31 | private CancellationToken _cancellationToken; |
||
22 | office | 32 | private CancellationTokenSource _cancellationTokenSource; |
33 | private CancellationTokenSource _localCancellationTokenSource; |
||
34 | private CancellationToken _localCancellationToken; |
||
15 | office | 35 | |
36 | public MemoryOrganizerForm() |
||
37 | { |
||
38 | InitializeComponent(); |
||
22 | office | 39 | |
40 | _localCancellationTokenSource = new CancellationTokenSource(); |
||
41 | _localCancellationToken = _localCancellationTokenSource.Token; |
||
15 | office | 42 | } |
43 | |||
44 | public MemoryOrganizerForm(Configuration.Configuration configuration, CatAssemblies catAssemblies, CancellationToken cancellationToken) : this() |
||
45 | { |
||
46 | Configuration = configuration; |
||
47 | _catAssemblies = catAssemblies; |
||
22 | office | 48 | |
49 | _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken); |
||
50 | _cancellationToken = _cancellationTokenSource.Token; |
||
15 | office | 51 | } |
52 | |||
53 | /// <summary> |
||
54 | /// Clean up any resources being used. |
||
55 | /// </summary> |
||
56 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
57 | protected override void Dispose(bool disposing) |
||
58 | { |
||
59 | if (disposing && (components != null)) |
||
60 | { |
||
22 | office | 61 | if (_cancellationTokenSource != null) |
62 | { |
||
63 | _cancellationTokenSource.Cancel(); |
||
64 | } |
||
65 | |||
15 | office | 66 | components.Dispose(); |
67 | } |
||
68 | base.Dispose(disposing); |
||
69 | } |
||
70 | |||
71 | private async void button1_Click(object sender, EventArgs e) |
||
72 | { |
||
73 | var rows = GetSelectedDataGridViewRows(dataGridView1); |
||
22 | office | 74 | |
75 | var count = rows.Count; |
||
76 | |||
77 | toolStripProgressBar1.Minimum = 0; |
||
78 | toolStripProgressBar1.Maximum = count; |
||
79 | |||
80 | var progress = new Progress<DataGridViewRowProgress>(rowProgress => |
||
81 | { |
||
82 | try |
||
83 | { |
||
84 | switch (rowProgress) |
||
85 | { |
||
86 | case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess: |
||
87 | var result = rowProgressSuccess.Data; |
||
88 | |||
89 | rowProgress.Row.Cells["FrequencyColumn"].Value = result.Frequency; |
||
90 | rowProgress.Row.Cells["ClarifierDirectionColumn"].Value = (char)result.ClarifierDirection; |
||
91 | rowProgress.Row.Cells["ClarifierOffsetColumn"].Value = result.ClarifierOffset; |
||
92 | rowProgress.Row.Cells["ClarColumn"].Value = result.Clar; |
||
93 | rowProgress.Row.Cells["ModeColumn"].Value = (string)result.MemoryRadioMode; |
||
94 | rowProgress.Row.Cells["CtcssColumn"].Value = (string)result.CtcssMode; |
||
95 | rowProgress.Row.Cells["PhaseColumn"].Value = (string)result.Phase; |
||
96 | rowProgress.Row.Cells["TagColumn"].Value = result.Tag; |
||
26 | office | 97 | rowProgress.Row.Cells["TextColumn"].Value = result.Text; |
22 | office | 98 | rowProgress.Row.Tag = rowProgressSuccess.Data; |
99 | |||
100 | break; |
||
101 | case DataGridViewRowProgressFailure rowProgressFailure: |
||
102 | Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_read_memory_bank}"); |
||
103 | |||
104 | break; |
||
105 | } |
||
106 | |||
107 | toolStripStatusLabel1.Text = |
||
108 | $"{Resources.Read_memory_bank} {rowProgress.Index + 1}"; |
||
109 | toolStripProgressBar1.Increment(1); |
||
110 | |||
111 | statusStrip1.Update(); |
||
112 | } |
||
113 | catch(Exception) |
||
114 | { |
||
115 | |||
116 | } |
||
117 | }); |
||
118 | |||
119 | await Task.Run(() => ReadMemoryBanks(rows, progress, _cancellationToken), _cancellationToken); |
||
120 | |||
121 | if (!_cancellationToken.IsCancellationRequested) |
||
122 | { |
||
123 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
||
124 | toolStripStatusLabel1.Text = "Done."; |
||
125 | } |
||
15 | office | 126 | } |
127 | |||
128 | private async void button2_Click(object sender, EventArgs e) |
||
129 | { |
||
130 | var rows = GetSelectedDataGridViewRows(dataGridView1); |
||
22 | office | 131 | var count = rows.Count; |
132 | |||
133 | toolStripProgressBar1.Minimum = 0; |
||
134 | toolStripProgressBar1.Maximum = count; |
||
135 | |||
136 | var progress = new Progress<DataGridViewRowProgress>(rowProgress => |
||
137 | { |
||
138 | try |
||
139 | { |
||
140 | switch (rowProgress) |
||
141 | { |
||
142 | case DataGridViewRowProgressSuccess<bool> rowProgressSuccess: |
||
143 | var success = rowProgressSuccess.Data; |
||
144 | |||
145 | if (!success) |
||
146 | { |
||
147 | Log.Error($"{Resources.Could_not_write_memory_bank}"); |
||
148 | |||
149 | toolStripStatusLabel1.Text = |
||
150 | $"{Resources.Could_not_write_memory_bank} {rowProgress.Index + 1}"; |
||
151 | toolStripProgressBar1.Increment(1); |
||
152 | statusStrip1.Update(); |
||
153 | |||
154 | return; |
||
155 | } |
||
156 | |||
157 | toolStripStatusLabel1.Text = |
||
158 | $"{Resources.Wrote_memory_bank} {rowProgress.Index + 1}"; |
||
159 | toolStripProgressBar1.Increment(1); |
||
160 | statusStrip1.Update(); |
||
161 | break; |
||
162 | case DataGridViewRowProgressFailure rowProgressFailure: |
||
163 | Log.Error(rowProgressFailure.Exception, $"{Resources.Could_not_write_memory_bank}"); |
||
164 | |||
165 | toolStripStatusLabel1.Text = |
||
166 | $"{Resources.Could_not_write_memory_bank} {rowProgress.Index + 1}"; |
||
167 | toolStripProgressBar1.Increment(1); |
||
168 | statusStrip1.Update(); |
||
169 | break; |
||
170 | } |
||
171 | } |
||
172 | catch(Exception) |
||
173 | { |
||
174 | |||
175 | } |
||
176 | |||
177 | }); |
||
178 | |||
179 | await Task.Run(() => WriteMemoryBanks(rows, progress, _cancellationToken), _cancellationToken); |
||
180 | |||
181 | if (!_cancellationToken.IsCancellationRequested) |
||
182 | { |
||
183 | toolStripProgressBar1.Value = toolStripProgressBar1.Maximum; |
||
184 | toolStripStatusLabel1.Text = "Done."; |
||
185 | } |
||
15 | office | 186 | } |
187 | |||
188 | private void MemoryOrganizerForm_Load(object sender, EventArgs e) |
||
189 | { |
||
190 | toolStripProgressBar1.Minimum = 0; |
||
191 | toolStripProgressBar1.Maximum = 98; |
||
192 | |||
193 | var memoryBankQueue = new ConcurrentQueue<int>(); |
||
26 | office | 194 | var memoryBankReadTaskCompletionSource = new TaskCompletionSource<object>(); |
15 | office | 195 | |
196 | async void IdleHandler(object idleHandlerSender, EventArgs idleHandlerArgs) |
||
197 | { |
||
26 | office | 198 | await memoryBankReadTaskCompletionSource.Task; |
15 | office | 199 | |
200 | try |
||
201 | { |
||
202 | if (!memoryBankQueue.TryDequeue(out var memoryBank)) |
||
203 | { |
||
204 | Application.Idle -= IdleHandler; |
||
205 | |||
206 | dataGridView1.Sort(dataGridView1.Columns["LocationColumn"], ListSortDirection.Ascending); |
||
207 | toolStripStatusLabel1.Text = "Done."; |
||
208 | |||
209 | return; |
||
210 | } |
||
211 | |||
212 | var index = dataGridView1.Rows.Add(); |
||
213 | |||
214 | dataGridView1.Rows[index].Cells["LocationColumn"].Value = $"{memoryBank:000}"; |
||
215 | dataGridView1.Rows[index].Cells["FrequencyColumn"].Value = default; |
||
216 | dataGridView1.Rows[index].Cells["ClarifierDirectionColumn"].Value = default; |
||
217 | dataGridView1.Rows[index].Cells["ClarifierOffsetColumn"].Value = default; |
||
218 | dataGridView1.Rows[index].Cells["ClarColumn"].Value = default; |
||
219 | dataGridView1.Rows[index].Cells["ModeColumn"].Value = default; |
||
220 | dataGridView1.Rows[index].Cells["CtcssColumn"].Value = default; |
||
221 | dataGridView1.Rows[index].Cells["PhaseColumn"].Value = default; |
||
222 | dataGridView1.Rows[index].Cells["TagColumn"].Value = default; |
||
223 | dataGridView1.Rows[index].Cells["TextColumn"].Value = default; |
||
224 | |||
225 | toolStripStatusLabel1.Text = $"{Resources.Read_memory_bank} {memoryBank}"; |
||
226 | |||
227 | toolStripProgressBar1.Increment(1); |
||
228 | |||
229 | statusStrip1.Update(); |
||
230 | } |
||
231 | catch (Exception exception) |
||
232 | { |
||
233 | Log.Error(exception, Resources.Could_not_update_data_grid_view); |
||
234 | } |
||
235 | } |
||
236 | |||
237 | Application.Idle += IdleHandler; |
||
238 | try |
||
239 | { |
||
240 | foreach (var memoryBank in Enumerable.Range(1, 99)) |
||
241 | { |
||
242 | memoryBankQueue.Enqueue(memoryBank); |
||
243 | } |
||
244 | |||
26 | office | 245 | memoryBankReadTaskCompletionSource.TrySetResult(new { }); |
15 | office | 246 | } |
247 | catch (Exception exception) |
||
248 | { |
||
249 | Application.Idle -= IdleHandler; |
||
250 | |||
251 | Log.Error(exception, Resources.Unable_to_create_memory_banks); |
||
252 | } |
||
253 | } |
||
254 | |||
255 | private void DataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e) |
||
256 | { |
||
257 | var dataGridView = (DataGridView)sender; |
||
258 | |||
259 | if (dataGridView.CurrentCell is DataGridViewCheckBoxCell) |
||
260 | { |
||
261 | dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit); |
||
262 | } |
||
263 | } |
||
264 | |||
265 | private void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) |
||
266 | { |
||
267 | var dataGridView = (DataGridView)sender; |
||
268 | |||
269 | dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit); |
||
270 | } |
||
271 | |||
272 | private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) |
||
273 | { |
||
274 | var dataGridView = (DataGridView)sender; |
||
275 | |||
276 | if (dataGridView.CurrentCell is DataGridViewCheckBoxCell) |
||
277 | { |
||
278 | if (dataGridView.CurrentCell.IsInEditMode) |
||
279 | { |
||
280 | if (dataGridView.IsCurrentCellDirty) |
||
281 | { |
||
282 | dataGridView.EndEdit(); |
||
283 | } |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | |||
288 | private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) |
||
289 | { |
||
290 | var dataGridView = (DataGridView)sender; |
||
291 | |||
292 | if (e.RowIndex == -1 || e.ColumnIndex == -1) |
||
293 | { |
||
294 | return; |
||
295 | } |
||
296 | |||
297 | switch (dataGridView.Columns[e.ColumnIndex].Name) |
||
298 | { |
||
299 | case "EnableColumn": |
||
300 | //ProcessEnable(dataGridView.Rows[e.RowIndex]); |
||
301 | break; |
||
302 | } |
||
303 | } |
||
304 | |||
305 | private void DataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) |
||
306 | { |
||
307 | var dataGridView = (DataGridView)sender; |
||
308 | |||
309 | if (e.RowIndex == -1 || e.ColumnIndex == -1 || |
||
310 | !(dataGridView.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn)) |
||
311 | { |
||
312 | return; |
||
313 | } |
||
314 | |||
315 | dataGridView.EndEdit(); |
||
316 | } |
||
317 | |||
318 | private void DataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) |
||
319 | { |
||
320 | var dataGridView = (DataGridView)sender; |
||
321 | |||
322 | if (e.RowIndex == -1 || e.ColumnIndex == -1 || |
||
323 | !(dataGridView.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn)) |
||
324 | { |
||
325 | return; |
||
326 | } |
||
327 | |||
328 | dataGridView.EndEdit(); |
||
329 | } |
||
330 | |||
331 | private void DataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e) |
||
332 | { |
||
333 | // @(-.-)@ -(o.o)- @(o_o)@ |
||
334 | } |
||
335 | |||
336 | private static List<DataGridViewRow> GetSelectedDataGridViewRows(DataGridView dataGridView) |
||
337 | { |
||
338 | return dataGridView.SelectedRows.OfType<DataGridViewRow>().OrderBy(row => row.Index).ToList(); |
||
339 | } |
||
340 | |||
341 | private async Task ReadMemoryBanks(IReadOnlyList<DataGridViewRow> rows, IProgress<DataGridViewRowProgress> progress, |
||
342 | CancellationToken cancellationToken) |
||
343 | { |
||
344 | var count = rows.Count; |
||
345 | |||
346 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
||
347 | { |
||
348 | try |
||
349 | { |
||
350 | var location = int.Parse($"{rows[i].Cells["LocationColumn"].Value}"); |
||
351 | |||
352 | var memoryBank = $"{location:000}"; |
||
353 | |||
354 | var result = await _catAssemblies.CatReadAsync<MemoryChannel>("MT", new object[] { memoryBank }, _cancellationToken); |
||
355 | |||
356 | progress.Report(new DataGridViewRowProgressSuccess<MemoryChannel>(rows[i], i, result)); |
||
357 | } |
||
358 | catch (UnexpectedRadioResponseException exception) |
||
359 | { |
||
360 | progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception)); |
||
361 | } |
||
362 | catch (Exception exception) |
||
363 | { |
||
364 | progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception)); |
||
365 | } |
||
366 | } |
||
367 | } |
||
368 | |||
369 | private async Task WriteMemoryBanks(IReadOnlyList<DataGridViewRow> rows, IProgress<DataGridViewRowProgress> progress, |
||
370 | CancellationToken cancellationToken) |
||
371 | { |
||
372 | var count = rows.Count; |
||
373 | |||
374 | for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) |
||
375 | { |
||
376 | try |
||
377 | { |
||
378 | var location = int.Parse($"{rows[i].Cells["LocationColumn"].Value}"); |
||
379 | |||
380 | var currentLocation = $"{location:000}"; |
||
381 | var frequency = int.Parse($"{rows[i].Cells["FrequencyColumn"].Value}"); |
||
382 | var clarifierDirection = char.Parse($"{rows[i].Cells["ClarifierDirectionColumn"].Value}"); |
||
383 | var clarifierOffset = int.Parse($"{rows[i].Cells["ClarifierOffsetColumn"].Value}"); |
||
40 | office | 384 | var clar = Convert.ToBoolean(rows[i].Cells["ClarColumn"].Value); |
15 | office | 385 | var radioMode = new MemoryRadioMode($"{rows[i].Cells["ModeColumn"].Value}"); |
386 | var ctcssMode = new CtcssMode($"{rows[i].Cells["CtcssColumn"].Value}"); |
||
387 | var phase = new RadioPhase($"{rows[i].Cells["PhaseColumn"].Value}"); |
||
40 | office | 388 | var tag = Convert.ToBoolean(rows[i].Cells["TagColumn"].Value); |
17 | office | 389 | var text = $"{rows[i].Cells["TextColumn"].Value, -12}"; |
15 | office | 390 | |
391 | var memoryChannel = new MemoryChannel |
||
392 | { |
||
393 | CurrentLocation = currentLocation, |
||
394 | Frequency = frequency, |
||
395 | ClarifierDirection = clarifierDirection, |
||
396 | ClarifierOffset = clarifierOffset, |
||
397 | Clar = clar, |
||
398 | MemoryRadioMode = radioMode, |
||
399 | CtcssMode = ctcssMode, |
||
400 | Phase = phase, |
||
401 | Tag = tag, |
||
402 | Text = text |
||
403 | }; |
||
404 | |||
405 | var result = await _catAssemblies.CatSetAsync<MemoryChannel, bool>("MT", new object[] { memoryChannel }, _cancellationToken); |
||
406 | |||
407 | progress.Report(new DataGridViewRowProgressSuccess<bool>(rows[i], i, result)); |
||
408 | } |
||
409 | catch (UnexpectedRadioResponseException exception) |
||
410 | { |
||
411 | progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception)); |
||
412 | } |
||
413 | catch (Exception exception) |
||
414 | { |
||
415 | progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception)); |
||
416 | } |
||
417 | } |
||
418 | } |
||
16 | office | 419 | |
420 | private void importToolStripMenuItem_Click(object sender, EventArgs e) |
||
421 | { |
||
422 | openFileDialog1.ShowDialog(); |
||
423 | } |
||
424 | |||
425 | private void exportToolStripMenuItem_Click(object sender, EventArgs e) |
||
426 | { |
||
427 | saveFileDialog1.ShowDialog(); |
||
428 | } |
||
429 | |||
430 | private async void saveFileDialog1_FileOk(object sender, CancelEventArgs e) |
||
431 | { |
||
432 | if (e.Cancel) |
||
433 | { |
||
434 | return; |
||
435 | } |
||
436 | |||
437 | var fileName = saveFileDialog1.FileName; |
||
26 | office | 438 | var list = new List<MemoryChannelIndexed>(); |
16 | office | 439 | foreach(var row in dataGridView1.Rows.OfType<DataGridViewRow>().OrderBy(row => row.Index)) |
440 | { |
||
441 | if (row.Tag is MemoryChannel memoryChannel) |
||
442 | { |
||
26 | office | 443 | var memoryChannelOrganizerBanks = new MemoryChannelIndexed(row.Index, memoryChannel); |
16 | office | 444 | list.Add(memoryChannelOrganizerBanks); |
445 | } |
||
446 | } |
||
447 | |||
448 | var memoryBanks = list.ToArray(); |
||
449 | |||
450 | switch (await Serialization.Serialize(memoryBanks, fileName, "MemoryChannelOrganizerBank", |
||
451 | "<!ATTLIST MemoryChannelOrganizerBank xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>", |
||
452 | CancellationToken.None)) |
||
453 | { |
||
26 | office | 454 | case SerializationSuccess<MemoryChannelIndexed[]> configuration: |
16 | office | 455 | Log.Information(Resources.Serialized_memory_banks); |
456 | break; |
||
457 | case SerializationFailure serializationFailure: |
||
458 | Log.Warning(serializationFailure.Exception.Message, Resources.Failed_to_serialize_memory_banks); |
||
459 | break; |
||
460 | } |
||
461 | } |
||
462 | |||
463 | private async void openFileDialog1_FileOk(object sender, CancelEventArgs e) |
||
464 | { |
||
465 | if(e.Cancel) |
||
466 | { |
||
467 | return; |
||
468 | } |
||
469 | |||
470 | var fileName = openFileDialog1.FileName; |
||
26 | office | 471 | MemoryChannelIndexed[] memoryBanks = null; |
16 | office | 472 | |
473 | var deserializationResult = |
||
26 | office | 474 | await Serialization.Deserialize<MemoryChannelIndexed[]>(fileName, |
16 | office | 475 | "urn:hambook-memorychannelorganizerbank-schema", "MemoryChannelOrganizerBanks.xsd", CancellationToken.None); |
476 | |||
477 | switch (deserializationResult) |
||
478 | { |
||
26 | office | 479 | case SerializationSuccess<MemoryChannelIndexed[]> serializationSuccess: |
16 | office | 480 | Log.Information(Resources.Deserialized_memory_banks); |
481 | memoryBanks = serializationSuccess.Result; |
||
482 | break; |
||
483 | case SerializationFailure serializationFailure: |
||
484 | Log.Warning(serializationFailure.Exception, Resources.Failed_to_deserialize_memory_banks); |
||
485 | return; |
||
486 | } |
||
487 | |||
488 | toolStripProgressBar1.Minimum = 0; |
||
489 | toolStripProgressBar1.Maximum = 98; |
||
490 | |||
26 | office | 491 | var memoryBankQueue = new ConcurrentQueue<MemoryChannelIndexed>(); |
16 | office | 492 | var snapshotsQueuedTaskCompletionSource = new TaskCompletionSource<object>(); |
493 | |||
494 | async void IdleHandler(object idleHandlerSender, EventArgs idleHandlerArgs) |
||
495 | { |
||
496 | await snapshotsQueuedTaskCompletionSource.Task; |
||
497 | |||
498 | try |
||
499 | { |
||
500 | if (!memoryBankQueue.TryDequeue(out var memoryBank)) |
||
501 | { |
||
502 | Application.Idle -= IdleHandler; |
||
503 | |||
504 | dataGridView1.Sort(dataGridView1.Columns["LocationColumn"], ListSortDirection.Ascending); |
||
505 | toolStripStatusLabel1.Text = "Done."; |
||
506 | |||
507 | return; |
||
508 | } |
||
509 | |||
510 | dataGridView1.Rows[memoryBank.Index].Cells["FrequencyColumn"].Value = memoryBank.MemoryChannel.Frequency; |
||
511 | dataGridView1.Rows[memoryBank.Index].Cells["ClarifierDirectionColumn"].Value = (char)memoryBank.MemoryChannel.ClarifierDirection; |
||
512 | dataGridView1.Rows[memoryBank.Index].Cells["ClarifierOffsetColumn"].Value = memoryBank.MemoryChannel.ClarifierOffset; |
||
513 | dataGridView1.Rows[memoryBank.Index].Cells["ClarColumn"].Value = memoryBank.MemoryChannel.Clar; |
||
514 | dataGridView1.Rows[memoryBank.Index].Cells["ModeColumn"].Value = (string)memoryBank.MemoryChannel.MemoryRadioMode; |
||
515 | dataGridView1.Rows[memoryBank.Index].Cells["CtcssColumn"].Value = (string)memoryBank.MemoryChannel.CtcssMode; |
||
516 | dataGridView1.Rows[memoryBank.Index].Cells["PhaseColumn"].Value = (string)memoryBank.MemoryChannel.Phase; |
||
517 | dataGridView1.Rows[memoryBank.Index].Cells["TagColumn"].Value = memoryBank.MemoryChannel.Tag; |
||
518 | dataGridView1.Rows[memoryBank.Index].Cells["TextColumn"].Value = memoryBank.MemoryChannel.Text; |
||
519 | |||
520 | toolStripProgressBar1.Increment(1); |
||
521 | |||
522 | statusStrip1.Update(); |
||
523 | } |
||
524 | catch (Exception exception) |
||
525 | { |
||
526 | Log.Error(exception, Resources.Could_not_update_data_grid_view); |
||
527 | } |
||
528 | } |
||
529 | |||
530 | Application.Idle += IdleHandler; |
||
531 | try |
||
532 | { |
||
533 | foreach (var memoryChannel in memoryBanks) |
||
534 | { |
||
535 | memoryBankQueue.Enqueue(memoryChannel); |
||
536 | } |
||
537 | |||
538 | snapshotsQueuedTaskCompletionSource.TrySetResult(new { }); |
||
539 | } |
||
540 | catch (Exception exception) |
||
541 | { |
||
542 | Application.Idle -= IdleHandler; |
||
543 | |||
544 | Log.Error(exception, Resources.Unable_to_create_memory_banks); |
||
545 | } |
||
546 | } |
||
22 | office | 547 | |
548 | private void MemoryOrganizerForm_FormClosing(object sender, FormClosingEventArgs e) |
||
549 | { |
||
550 | if(_cancellationTokenSource != null) |
||
551 | { |
||
552 | _cancellationTokenSource.Cancel(); |
||
553 | } |
||
554 | } |
||
40 | office | 555 | |
556 | private void DataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e) |
||
557 | { |
||
558 | var a = e.Row; |
||
559 | } |
||
15 | office | 560 | } |
561 | } |