HamBook – Diff between revs 15 and 16

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 15 Rev 16
Line 1... Line 1...
1 using Configuration; 1 using Configuration;
2 using HamBook.Properties; 2 using HamBook.Properties;
3 using HamBook.Radios; 3 using HamBook.Radios;
4 using HamBook.Radios.Generic; 4 using HamBook.Radios.Generic;
-   5 using HamBook.Utilities.Serialization;
5 using Serilog; 6 using Serilog;
6 using System; 7 using System;
7 using System.Collections; 8 using System.Collections;
8 using System.Collections.Concurrent; 9 using System.Collections.Concurrent;
9 using System.Collections.Generic; 10 using System.Collections.Generic;
Line 282... Line 283...
282 switch(rowProgress) 283 switch(rowProgress)
283 { 284 {
284 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess: 285 case DataGridViewRowProgressSuccess<MemoryChannel> rowProgressSuccess:
285 var result = rowProgressSuccess.Data; 286 var result = rowProgressSuccess.Data;
Line 286... Line -...
286   -  
287 //rowProgress.Row.Cells["LocationColumn"].Value = $"{rowProgressSuccess.Index + 1:000}"; 287  
288 rowProgress.Row.Cells["FrequencyColumn"].Value = result.Frequency; 288 rowProgress.Row.Cells["FrequencyColumn"].Value = result.Frequency;
289 rowProgress.Row.Cells["ClarifierDirectionColumn"].Value = (char)result.ClarifierDirection; 289 rowProgress.Row.Cells["ClarifierDirectionColumn"].Value = (char)result.ClarifierDirection;
290 rowProgress.Row.Cells["ClarifierOffsetColumn"].Value = result.ClarifierOffset; 290 rowProgress.Row.Cells["ClarifierOffsetColumn"].Value = result.ClarifierOffset;
291 rowProgress.Row.Cells["ClarColumn"].Value = result.Clar; 291 rowProgress.Row.Cells["ClarColumn"].Value = result.Clar;
292 rowProgress.Row.Cells["ModeColumn"].Value = (string)result.MemoryRadioMode; 292 rowProgress.Row.Cells["ModeColumn"].Value = (string)result.MemoryRadioMode;
293 rowProgress.Row.Cells["CtcssColumn"].Value = (string)result.CtcssMode; 293 rowProgress.Row.Cells["CtcssColumn"].Value = (string)result.CtcssMode;
294 rowProgress.Row.Cells["PhaseColumn"].Value = (string)result.Phase; 294 rowProgress.Row.Cells["PhaseColumn"].Value = (string)result.Phase;
295 rowProgress.Row.Cells["TagColumn"].Value = result.Tag; 295 rowProgress.Row.Cells["TagColumn"].Value = result.Tag;
-   296 rowProgress.Row.Cells["TextColumn"].Value = result.Text.Trim();
Line 296... Line 297...
296 rowProgress.Row.Cells["TextColumn"].Value = result.Text.Trim(); 297 rowProgress.Row.Tag = rowProgressSuccess.Data;
297   298  
298 break; 299 break;
Line 394... Line 395...
394 { 395 {
395 progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception)); 396 progress.Report(new DataGridViewRowProgressFailure(rows[i], i, exception));
396 } 397 }
397 } 398 }
398 } 399 }
-   400  
-   401 private void importToolStripMenuItem_Click(object sender, EventArgs e)
-   402 {
-   403 openFileDialog1.ShowDialog();
-   404 }
-   405  
-   406 private void exportToolStripMenuItem_Click(object sender, EventArgs e)
-   407 {
-   408 saveFileDialog1.ShowDialog();
-   409 }
-   410  
-   411 private async void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
-   412 {
-   413 if (e.Cancel)
-   414 {
-   415 return;
-   416 }
-   417  
-   418 var fileName = saveFileDialog1.FileName;
-   419 var list = new List<MemoryChannelOrganizerBank>();
-   420 foreach(var row in dataGridView1.Rows.OfType<DataGridViewRow>().OrderBy(row => row.Index))
-   421 {
-   422 if (row.Tag is MemoryChannel memoryChannel)
-   423 {
-   424 var memoryChannelOrganizerBanks = new MemoryChannelOrganizerBank(row.Index, memoryChannel);
-   425 list.Add(memoryChannelOrganizerBanks);
-   426 }
-   427 }
-   428  
-   429 var memoryBanks = list.ToArray();
-   430  
-   431 switch (await Serialization.Serialize(memoryBanks, fileName, "MemoryChannelOrganizerBank",
-   432 "<!ATTLIST MemoryChannelOrganizerBank xmlns:xsi CDATA #IMPLIED xsi:noNamespaceSchemaLocation CDATA #IMPLIED>",
-   433 CancellationToken.None))
-   434 {
-   435 case SerializationSuccess<MemoryChannelOrganizerBank[]> configuration:
-   436 Log.Information(Resources.Serialized_memory_banks);
-   437 break;
-   438 case SerializationFailure serializationFailure:
-   439 Log.Warning(serializationFailure.Exception.Message, Resources.Failed_to_serialize_memory_banks);
-   440 break;
-   441 }
-   442 }
-   443  
-   444 private async void openFileDialog1_FileOk(object sender, CancelEventArgs e)
-   445 {
-   446 if(e.Cancel)
-   447 {
-   448 return;
-   449 }
-   450  
-   451 var fileName = openFileDialog1.FileName;
-   452 MemoryChannelOrganizerBank[] memoryBanks = null;
-   453  
-   454 var deserializationResult =
-   455 await Serialization.Deserialize<MemoryChannelOrganizerBank[]>(fileName,
-   456 "urn:hambook-memorychannelorganizerbank-schema", "MemoryChannelOrganizerBanks.xsd", CancellationToken.None);
-   457  
-   458 switch (deserializationResult)
-   459 {
-   460 case SerializationSuccess<MemoryChannelOrganizerBank[]> serializationSuccess:
-   461 Log.Information(Resources.Deserialized_memory_banks);
-   462 memoryBanks = serializationSuccess.Result;
-   463 break;
-   464 case SerializationFailure serializationFailure:
-   465 Log.Warning(serializationFailure.Exception, Resources.Failed_to_deserialize_memory_banks);
-   466 return;
-   467 }
-   468  
-   469 toolStripProgressBar1.Minimum = 0;
-   470 toolStripProgressBar1.Maximum = 98;
-   471  
-   472 var memoryBankQueue = new ConcurrentQueue<MemoryChannelOrganizerBank>();
-   473 var snapshotsQueuedTaskCompletionSource = new TaskCompletionSource<object>();
-   474  
-   475 async void IdleHandler(object idleHandlerSender, EventArgs idleHandlerArgs)
-   476 {
-   477 await snapshotsQueuedTaskCompletionSource.Task;
-   478  
-   479 try
-   480 {
-   481 if (!memoryBankQueue.TryDequeue(out var memoryBank))
-   482 {
-   483 Application.Idle -= IdleHandler;
-   484  
-   485 dataGridView1.Sort(dataGridView1.Columns["LocationColumn"], ListSortDirection.Ascending);
-   486 toolStripStatusLabel1.Text = "Done.";
-   487  
-   488 return;
-   489 }
-   490
-   491 dataGridView1.Rows[memoryBank.Index].Cells["FrequencyColumn"].Value = memoryBank.MemoryChannel.Frequency;
-   492 dataGridView1.Rows[memoryBank.Index].Cells["ClarifierDirectionColumn"].Value = (char)memoryBank.MemoryChannel.ClarifierDirection;
-   493 dataGridView1.Rows[memoryBank.Index].Cells["ClarifierOffsetColumn"].Value = memoryBank.MemoryChannel.ClarifierOffset;
-   494 dataGridView1.Rows[memoryBank.Index].Cells["ClarColumn"].Value = memoryBank.MemoryChannel.Clar;
-   495 dataGridView1.Rows[memoryBank.Index].Cells["ModeColumn"].Value = (string)memoryBank.MemoryChannel.MemoryRadioMode;
-   496 dataGridView1.Rows[memoryBank.Index].Cells["CtcssColumn"].Value = (string)memoryBank.MemoryChannel.CtcssMode;
-   497 dataGridView1.Rows[memoryBank.Index].Cells["PhaseColumn"].Value = (string)memoryBank.MemoryChannel.Phase;
-   498 dataGridView1.Rows[memoryBank.Index].Cells["TagColumn"].Value = memoryBank.MemoryChannel.Tag;
-   499 dataGridView1.Rows[memoryBank.Index].Cells["TextColumn"].Value = memoryBank.MemoryChannel.Text;
-   500  
-   501 toolStripProgressBar1.Increment(1);
-   502  
-   503 statusStrip1.Update();
-   504 }
-   505 catch (Exception exception)
-   506 {
-   507 Log.Error(exception, Resources.Could_not_update_data_grid_view);
-   508 }
-   509 }
-   510  
-   511 Application.Idle += IdleHandler;
-   512 try
-   513 {
-   514 foreach (var memoryChannel in memoryBanks)
-   515 {
-   516 memoryBankQueue.Enqueue(memoryChannel);
-   517 }
-   518  
-   519 snapshotsQueuedTaskCompletionSource.TrySetResult(new { });
-   520 }
-   521 catch (Exception exception)
-   522 {
-   523 Application.Idle -= IdleHandler;
-   524  
-   525 Log.Error(exception, Resources.Unable_to_create_memory_banks);
-   526 }
-   527 }
399 } 528 }
400 } 529 }