HamBook – Diff between revs 3 and 5
?pathlinks?
Rev 3 | Rev 5 | |||
---|---|---|---|---|
Line 16... | Line 16... | |||
16 | using System.Threading.Tasks; |
16 | using System.Threading.Tasks; |
|
17 | using System.Windows.Forms; |
17 | using System.Windows.Forms; |
|
18 | using HamBook.Properties; |
18 | using HamBook.Properties; |
|
19 | using HamBook.Radios.Generic; |
19 | using HamBook.Radios.Generic; |
|
20 | using PowerState = HamBook.Radios.Generic.PowerState; |
20 | using PowerState = HamBook.Radios.Generic.PowerState; |
|
- | 21 | using System.Media; |
||
Line 21... | Line 22... | |||
21 | |
22 | |
|
22 | namespace HamBook |
23 | namespace HamBook |
|
23 | { |
24 | { |
|
24 | public partial class Form1 : Form |
25 | public partial class Form1 : Form |
|
Line 327... | Line 328... | |||
327 | } |
328 | } |
|
328 | } |
329 | } |
|
Line 329... | Line 330... | |||
329 | |
330 | |
|
330 | private void toolStripComboBox2_MouseWheel(object sender, MouseEventArgs e) |
331 | private void toolStripComboBox2_MouseWheel(object sender, MouseEventArgs e) |
|
331 | { |
- | ||
332 | var toolStripComboBox = (ToolStripComboBox)sender; |
332 | { |
|
333 | if (int.TryParse(toolStripComboBox.Text, out var frequency)) |
333 | using (var soundPlayer = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("HamBook.Effects.pot.wav"))) |
|
334 | { |
- | ||
335 | switch(Math.Sign(e.Delta)) |
- | ||
336 | { |
- | ||
337 | case -1: |
334 | { |
|
338 | frequency = frequency - 100; |
- | ||
339 | break; |
- | ||
340 | case 1: |
335 | var toolStripComboBox = (ToolStripComboBox)sender; |
|
341 | frequency = frequency + 100; |
- | ||
342 | break; |
- | ||
343 | } |
- | ||
344 | |
- | ||
345 | try |
336 | if (int.TryParse(toolStripComboBox.Text, out var frequency)) |
|
- | 337 | { |
||
- | 338 | switch (Math.Sign(e.Delta)) |
||
- | 339 | { |
||
- | 340 | case -1: |
||
- | 341 | frequency = frequency - 100; |
||
- | 342 | break; |
||
- | 343 | case 1: |
||
- | 344 | frequency = frequency + 100; |
||
- | 345 | break; |
||
- | 346 | } |
||
- | 347 | |
||
- | 348 | soundPlayer.Play(); |
||
- | 349 | |
||
- | 350 | try |
||
346 | { |
351 | { |
|
347 | _catAssemblies.CatSet<int>("FA", new object[] { frequency }); |
352 | _catAssemblies.CatSet<int>("FA", new object[] { frequency }); |
|
348 | toolStripComboBox.Text = $"{frequency}"; |
353 | toolStripComboBox.Text = $"{frequency}"; |
|
349 | } |
354 | } |
|
350 | catch (Exception exception) |
355 | catch (Exception exception) |
|
351 | { |
356 | { |
|
- | 357 | Log.Error(exception, Resources.Failed_to_set_VFO_A_frequency); |
||
352 | Log.Error(exception, Resources.Failed_to_set_VFO_A_frequency); |
358 | } |
|
353 | } |
359 | } |
|
354 | } |
360 | } |
|
Line 355... | Line 361... | |||
355 | } |
361 | } |
|
356 | |
362 | |
|
357 | private void scrollableToolStripComboBox1_MouseWheel(object sender, MouseEventArgs e) |
- | ||
358 | { |
363 | private void scrollableToolStripComboBox1_MouseWheel(object sender, MouseEventArgs e) |
|
359 | var toolStripComboBox = (ToolStripComboBox)sender; |
364 | { |
|
360 | if (int.TryParse(toolStripComboBox.Text, out var frequency)) |
- | ||
361 | { |
- | ||
362 | switch (Math.Sign(e.Delta)) |
- | ||
363 | { |
365 | using (var soundPlayer = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("HamBook.Effects.pot.wav"))) |
|
364 | case -1: |
- | ||
365 | frequency = frequency - 100; |
- | ||
366 | break; |
- | ||
367 | case 1: |
- | ||
368 | frequency = frequency + 100; |
- | ||
369 | break; |
- | ||
370 | } |
- | ||
371 | |
- | ||
372 | try |
- | ||
373 | { |
366 | { |
|
374 | _catAssemblies.CatSet<int>("FB", new object[] { frequency }); |
- | ||
375 | toolStripComboBox.Text = $"{frequency}"; |
- | ||
376 | } |
367 | var toolStripComboBox = (ToolStripComboBox)sender; |
|
- | 368 | if (int.TryParse(toolStripComboBox.Text, out var frequency)) |
||
- | 369 | { |
||
- | 370 | switch (Math.Sign(e.Delta)) |
||
- | 371 | { |
||
- | 372 | case -1: |
||
- | 373 | frequency = frequency - 100; |
||
- | 374 | break; |
||
- | 375 | case 1: |
||
- | 376 | frequency = frequency + 100; |
||
- | 377 | break; |
||
- | 378 | } |
||
- | 379 | |
||
- | 380 | try |
||
- | 381 | { |
||
- | 382 | _catAssemblies.CatSet<int>("FB", new object[] { frequency }); |
||
- | 383 | toolStripComboBox.Text = $"{frequency}"; |
||
- | 384 | } |
||
377 | catch (Exception exception) |
385 | catch (Exception exception) |
|
- | 386 | { |
||
378 | { |
387 | Log.Error(exception, Resources.Failed_to_set_VFO_B_frequency); |
|
379 | Log.Error(exception, Resources.Failed_to_set_VFO_B_frequency); |
388 | } |
|
380 | } |
389 | } |
|
Line 381... | Line 390... | |||
381 | } |
390 | } |
|
Line 422... | Line 431... | |||
422 | |
431 | |
|
423 | _bandScan.Stop(); |
432 | _bandScan.Stop(); |
|
424 | _bandScan = null; |
433 | _bandScan = null; |
|
Line 425... | Line 434... | |||
425 | } |
434 | } |
|
426 | |
435 | |
|
427 | private void metersToolStripMenuItem1_Click(object sender, EventArgs e) |
436 | private void scanToolStripMenuItem_Click(object sender, EventArgs e) |
|
- | 437 | { |
||
428 | { |
438 | if (!(sender is ToolStripMenuItem toolStripMenuItem) || |
|
429 | if(_bandScan != null) |
439 | !int.TryParse(toolStripMenuItem.Tag.ToString(), out var meters)) |
|
430 | { |
- | ||
431 | _bandScan.Stop(); |
- | ||
432 | } |
- | ||
433 | |
- | ||
434 | _bandScan = new BandScan(_catAssemblies, 028000000, 029700000, _serialPort); |
- | ||
435 | _bandScan.Start(); |
- | ||
436 | } |
- | ||
437 | |
- | ||
438 | private void metersToolStripMenuItem_Click(object sender, EventArgs e) |
- | ||
439 | { |
- | ||
440 | if (_bandScan != null) |
- | ||
441 | { |
- | ||
442 | _bandScan.Stop(); |
- | ||
443 | } |
- | ||
444 | |
- | ||
445 | _bandScan = new BandScan(_catAssemblies, 026965000, 027405000, _serialPort); |
- | ||
446 | _bandScan.Start(); |
- | ||
447 | } |
- | ||
448 | |
- | ||
449 | private void metersToolStripMenuItem2_Click(object sender, EventArgs e) |
- | ||
450 | { |
- | ||
451 | if (_bandScan != null) |
- | ||
452 | { |
440 | { |
|
Line 453... | Line -... | |||
453 | _bandScan.Stop(); |
- | ||
454 | } |
- | ||
455 | |
- | ||
456 | _bandScan = new BandScan(_catAssemblies, 024920000, 024990000, _serialPort); |
- | ||
457 | _bandScan.Start(); |
441 | return; |
|
458 | } |
- | ||
459 | |
- | ||
460 | private void metersToolStripMenuItem3_Click(object sender, EventArgs e) |
442 | } |
|
461 | { |
443 | |
|
462 | if (_bandScan != null) |
444 | if (!int.TryParse(scrollableToolStripComboBox3.Text, out var pause)) |
|
Line 463... | Line -... | |||
463 | { |
- | ||
464 | _bandScan.Stop(); |
- | ||
465 | } |
- | ||
466 | |
- | ||
467 | _bandScan = new BandScan(_catAssemblies, 021000000, 021450000, _serialPort); |
445 | { |
|
468 | _bandScan.Start(); |
- | ||
469 | } |
- | ||
470 | |
446 | pause = 5; |
|
471 | private void metersToolStripMenuItem4_Click(object sender, EventArgs e) |
447 | } |
|
472 | { |
448 | |
|
Line 473... | Line -... | |||
473 | if (_bandScan != null) |
- | ||
474 | { |
- | ||
475 | _bandScan.Stop(); |
- | ||
476 | } |
- | ||
477 | |
449 | if(!int.TryParse(scrollableToolStripComboBox4.Text, out var step)) |
|
478 | _bandScan = new BandScan(_catAssemblies, 018068000, 018168000, _serialPort); |
- | ||
479 | _bandScan.Start(); |
- | ||
480 | } |
450 | { |
|
481 | |
451 | step = 5000; |
|
482 | private void metersToolStripMenuItem5_Click(object sender, EventArgs e) |
- | ||
483 | { |
- | ||
484 | if (_bandScan != null) |
- | ||
485 | { |
- | ||
486 | _bandScan.Stop(); |
- | ||
487 | } |
- | ||
488 | |
- | ||
489 | _bandScan = new BandScan(_catAssemblies, 014000000, 014350000, _serialPort); |
- | ||
490 | _bandScan.Start(); |
- | ||
491 | } |
- | ||
492 | |
- | ||
493 | private void metersToolStripMenuItem6_Click(object sender, EventArgs e) |
452 | } |
|
Line 494... | Line -... | |||
494 | { |
- | ||
495 | if (_bandScan != null) |
- | ||
496 | { |
- | ||
497 | _bandScan.Stop(); |
- | ||
498 | } |
- | ||
499 | |
- | ||
500 | _bandScan = new BandScan(_catAssemblies, 010100000, 010150000, _serialPort); |
453 | |
|
501 | _bandScan.Start(); |
454 | if (!Configuration.Definitions.TryGetBand(meters, out var band)) |
|
502 | } |
455 | { |
|
503 | |
456 | return; |
|
Line 504... | Line 457... | |||
504 | private void metersToolStripMenuItem7_Click(object sender, EventArgs e) |
457 | } |
|
- | 458 | |
||
505 | { |
459 | if (_bandScan != null) |
|
- | 460 | { |
||
506 | if (_bandScan != null) |
461 | _bandScan.Stop(); |
|
Line 507... | Line 462... | |||
507 | { |
462 | } |
|
508 | _bandScan.Stop(); |
463 | |
|
509 | } |
- | ||
510 | |
- | ||
511 | _bandScan = new BandScan(_catAssemblies, 007000000, 007300000, _serialPort); |
- | ||
512 | _bandScan.Start(); |
- | ||
513 | } |
- | ||
514 | |
- | ||
515 | private void metersToolStripMenuItem8_Click(object sender, EventArgs e) |
464 | _bandScan = new BandScan(_catAssemblies, band.Min, band.Max, _serialPort); |
|
516 | { |
465 | #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
|
517 | if (_bandScan != null) |
466 | _bandScan.Start(step, pause); |
|
518 | { |
467 | #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |