HamBook – Diff between revs 54 and 56

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 54 Rev 56
Line 12... Line 12...
12 using HamBook.Properties; 12 using HamBook.Properties;
13 using HamBook.Radios; 13 using HamBook.Radios;
14 using HamBook.Radios.Generic; 14 using HamBook.Radios.Generic;
15 using HamBook.Utilities.Serialization; 15 using HamBook.Utilities.Serialization;
16 using Serilog; 16 using Serilog;
17 using MemoryRadioMode = HamBook.Radios.Yaesu.FT_891.MemoryRadioMode; -  
Line 18... Line 17...
18   17  
19 namespace HamBook 18 namespace HamBook
20 { 19 {
21 public partial class MemoryOrganizerForm : Form 20 public partial class MemoryOrganizerForm : Form
Line 24... Line 23...
24   23  
25 private readonly CatAssemblies _catAssemblies; 24 private readonly CatAssemblies _catAssemblies;
26 private readonly CancellationToken _localCancellationToken; 25 private readonly CancellationToken _localCancellationToken;
27 private readonly CancellationTokenSource _localCancellationTokenSource; 26 private readonly CancellationTokenSource _localCancellationTokenSource;
-   27 private readonly MemoryBanks _memoryBanks;
28 private readonly MemoryBanks _memoryBanks; 28 private readonly MemoryRadioMode _memoryRadioMode;
29 private CancellationToken _cancellationToken; 29 private CancellationToken _cancellationToken;
30 private List<DataGridViewRow> _clipboardRows; -  
31 private CancellationTokenSource _writeCancellationTokenSource; -  
32 private CancellationTokenSource _writeLinkedCancellationTokenSource; -  
33 private Task _writeMemoryBanksTask; 30 private List<DataGridViewRow> _clipboardRows;
34 private CancellationTokenSource _readCancellationTokenSource; 31 private CancellationTokenSource _readCancellationTokenSource;
35 private CancellationTokenSource _readLinkedCancellationTokenSource; 32 private CancellationTokenSource _readLinkedCancellationTokenSource;
-   33 private Task _readMemoryBanksTask;
-   34 private CancellationTokenSource _writeCancellationTokenSource;
-   35 private CancellationTokenSource _writeLinkedCancellationTokenSource;
Line 36... Line 36...
36 private Task _readMemoryBanksTask; 36 private Task _writeMemoryBanksTask;
37   37  
38 public MemoryOrganizerForm() 38 public MemoryOrganizerForm()
39 { 39 {
Line 53... Line 53...
53 _cancellationTokenSource = 53 _cancellationTokenSource =
54 CancellationTokenSource.CreateLinkedTokenSource(_localCancellationToken, cancellationToken); 54 CancellationTokenSource.CreateLinkedTokenSource(_localCancellationToken, cancellationToken);
55 _cancellationToken = _cancellationTokenSource.Token; 55 _cancellationToken = _cancellationTokenSource.Token;
Line 56... Line 56...
56   56  
-   57 _memoryBanks = MemoryBanks.Create(Configuration.Radio);
57 _memoryBanks = MemoryBanks.Create(Configuration.Radio); 58 _memoryRadioMode = MemoryRadioMode.Create(Configuration.Radio);
Line 58... Line 59...
58 } 59 }
Line 59... Line 60...
59   60  
Line 220... Line 221...
220 { Name = "ClarifierOffsetColumn", HeaderText = "Offset" }); 221 { Name = "ClarifierOffsetColumn", HeaderText = "Offset" });
221 dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn 222 dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn
222 { Name = "ClarColumn", HeaderText = "Clar" }); 223 { Name = "ClarColumn", HeaderText = "Clar" });
223 var modeComboBoxColumn = new DataGridViewComboBoxColumn 224 var modeComboBoxColumn = new DataGridViewComboBoxColumn
224 { Name = "ModeColumn", HeaderText = "Mode" }; 225 { Name = "ModeColumn", HeaderText = "Mode" };
225 foreach (var name in MemoryRadioMode.Names) 226 foreach (var name in _memoryRadioMode.Names)
226 modeComboBoxColumn.Items.Add( 227 modeComboBoxColumn.Items.Add(
227 name 228 name
228 ); 229 );
Line 229... Line 230...
229   230  
Line 282... Line 283...
282 switch (Configuration.Radio) 283 switch (Configuration.Radio)
283 { 284 {
284 case "Yaesu FT-891": 285 case "Yaesu FT-891":
285 dataGridView1.Rows[index].Cells["LocationColumn"].Value = memoryBank; 286 dataGridView1.Rows[index].Cells["LocationColumn"].Value = memoryBank;
286 dataGridView1.Rows[index].Cells["FrequencyColumn"].Value = default; 287 dataGridView1.Rows[index].Cells["FrequencyColumn"].Value = default;
287 dataGridView1.Rows[index].Cells["ClarifierDirectionColumn"].Value = default; 288 dataGridView1.Rows[index].Cells["ClarifierDirectionColumn"].Value = "+";
288 dataGridView1.Rows[index].Cells["ClarifierOffsetColumn"].Value = default; 289 dataGridView1.Rows[index].Cells["ClarifierOffsetColumn"].Value = 0;
289 dataGridView1.Rows[index].Cells["ClarColumn"].Value = default; 290 dataGridView1.Rows[index].Cells["ClarColumn"].Value = default;
290 dataGridView1.Rows[index].Cells["ModeColumn"].Value = default; 291 dataGridView1.Rows[index].Cells["ModeColumn"].Value = default;
291 dataGridView1.Rows[index].Cells["CtcssColumn"].Value = default; 292 dataGridView1.Rows[index].Cells["CtcssColumn"].Value = "Off";
292 dataGridView1.Rows[index].Cells["PhaseColumn"].Value = default; 293 dataGridView1.Rows[index].Cells["PhaseColumn"].Value = "Simplex";
293 dataGridView1.Rows[index].Cells["TagColumn"].Value = default; 294 dataGridView1.Rows[index].Cells["TagColumn"].Value = default;
294 dataGridView1.Rows[index].Cells["TextColumn"].Value = default; 295 dataGridView1.Rows[index].Cells["TextColumn"].Value = default;
295 break; 296 break;
296 } 297 }
Line 434... Line 435...
434 memoryChannel.ClarifierDirection = 435 memoryChannel.ClarifierDirection =
435 char.Parse($"{rows[i].Cells["ClarifierDirectionColumn"].Value}"); 436 char.Parse($"{rows[i].Cells["ClarifierDirectionColumn"].Value}");
436 memoryChannel.ClarifierOffset = 437 memoryChannel.ClarifierOffset =
437 int.Parse($"{rows[i].Cells["ClarifierOffsetColumn"].Value}"); 438 int.Parse($"{rows[i].Cells["ClarifierOffsetColumn"].Value}");
438 memoryChannel.Clar = Convert.ToBoolean(rows[i].Cells["ClarColumn"].Value); 439 memoryChannel.Clar = Convert.ToBoolean(rows[i].Cells["ClarColumn"].Value);
439 memoryChannel.MemoryRadioMode = Radios.Generic.MemoryRadioMode.Create(Configuration.Radio, 440 memoryChannel.MemoryRadioMode = MemoryRadioMode.Create(Configuration.Radio,
440 $"{rows[i].Cells["ModeColumn"].Value}"); 441 $"{rows[i].Cells["ModeColumn"].Value}");
441 memoryChannel.Ctcss = new Ctcss($"{rows[i].Cells["CtcssColumn"].Value}"); 442 memoryChannel.Ctcss = new Ctcss($"{rows[i].Cells["CtcssColumn"].Value}");
442 memoryChannel.Phase = new Phase($"{rows[i].Cells["PhaseColumn"].Value}"); 443 memoryChannel.Phase = new Phase($"{rows[i].Cells["PhaseColumn"].Value}");
443 memoryChannel.Tag = Convert.ToBoolean(rows[i].Cells["TagColumn"].Value); 444 memoryChannel.Tag = Convert.ToBoolean(rows[i].Cells["TagColumn"].Value);
444 memoryChannel.Text = $"{rows[i].Cells["TextColumn"].Value,-12}"; 445 memoryChannel.Text = $"{rows[i].Cells["TextColumn"].Value,-12}";
Line 470... Line 471...
470 saveFileDialog1.ShowDialog(); 471 saveFileDialog1.ShowDialog();
471 } 472 }
Line 472... Line 473...
472   473  
473 private async void saveFileDialog1_FileOk(object sender, CancelEventArgs e) 474 private async void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
474 { 475 {
-   476 if (e.Cancel)
-   477 {
-   478 return;
Line 475... Line -...
475 if (e.Cancel) return; -  
476   479 }
477 var fileName = saveFileDialog1.FileName; 480  
478 var list = new List<MemoryChannelIndexed>(); 481 var list = new List<MemoryChannelIndexed>();
479 foreach (var row in dataGridView1.Rows.OfType<DataGridViewRow>().OrderBy(row => row.Index)) 482 foreach (var row in dataGridView1.Rows.OfType<DataGridViewRow>().OrderBy(row => row.Index))
480 if (row.Tag is MemoryChannel memoryChannel) 483 if (row.Tag is MemoryChannel memoryChannel)
481 { 484 {
482 var memoryChannelOrganizerBanks = new MemoryChannelIndexed(row.Index, memoryChannel); 485 var memoryChannelOrganizerBanks = new MemoryChannelIndexed(row.Index, memoryChannel);
Line 483... Line 486...
483 list.Add(memoryChannelOrganizerBanks); 486 list.Add(memoryChannelOrganizerBanks);
Line -... Line 487...
-   487 }
484 } 488  
485   489 var memoryBanks = list.ToArray();
486 var memoryBanks = list.ToArray(); 490  
487   491 var fileName = saveFileDialog1.FileName;
488 switch (await Serialization.Serialize(memoryBanks, fileName, "MemoryChannelOrganizerBank", 492 switch (await Serialization.Serialize(memoryBanks, fileName, "MemoryChannelOrganizerBank",
Line 498... Line 502...
498 } 502 }
499 } 503 }
Line 500... Line 504...
500   504  
501 private async void openFileDialog1_FileOk(object sender, CancelEventArgs e) 505 private async void openFileDialog1_FileOk(object sender, CancelEventArgs e)
502 { 506 {
-   507 if (e.Cancel)
-   508 {
-   509 return;
Line 503... Line -...
503 if (e.Cancel) return; -  
504   510 }
Line -... Line 511...
-   511  
505 var fileName = openFileDialog1.FileName; 512 MemoryChannelIndexed[] memoryBanks = null;
506 MemoryChannelIndexed[] memoryBanks = null; 513  
507   514 var fileName = openFileDialog1.FileName;
508 var deserializationResult = 515 var deserializationResult =
Line 509... Line 516...
509 await Serialization.Deserialize<MemoryChannelIndexed[]>(fileName, 516 await Serialization.Deserialize<MemoryChannelIndexed[]>(fileName,
510 "urn:hambook-memorychannelorganizerbank-schema", "MemoryChannelIndexed.xsd", 517 "urn:hambook-memorychannelorganizerbank-schema", "MemoryChannelIndexed.xsd",
511 CancellationToken.None); 518 _localCancellationToken);
512   519  
Line 1014... Line 1021...
1014 color1.R + (color2.R - color1.R) / steps * position, 1021 color1.R + (color2.R - color1.R) / steps * position,
1015 color1.G + (color2.G - color1.G) / steps * position, 1022 color1.G + (color2.G - color1.G) / steps * position,
1016 color1.B + (color2.B - color1.B) / steps * position 1023 color1.B + (color2.B - color1.B) / steps * position
1017 ); 1024 );
1018 } 1025 }
-   1026  
-   1027 private void DataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
-   1028 {
-   1029 switch (Configuration.Radio)
-   1030 {
-   1031 case "Yaesu FT-891":
-   1032 e.Row.Cells["LocationColumn"].Value = default;
-   1033 e.Row.Cells["FrequencyColumn"].Value = default;
-   1034 e.Row.Cells["ClarifierDirectionColumn"].Value = "+";
-   1035 e.Row.Cells["ClarifierOffsetColumn"].Value = 0;
-   1036 e.Row.Cells["ClarColumn"].Value = default;
-   1037 e.Row.Cells["ModeColumn"].Value = default;
-   1038 e.Row.Cells["CtcssColumn"].Value = "Off";
-   1039 e.Row.Cells["PhaseColumn"].Value = "Simplex";
-   1040 e.Row.Cells["TagColumn"].Value = default;
-   1041 e.Row.Cells["TextColumn"].Value = default;
-   1042 break;
-   1043 }
-   1044 }
1019 } 1045 }
1020 } 1046 }
1021   1047