HamBook – Blame information for rev 5

Subversion Repositories:
Rev:
Rev Author Line No. Line
5 office 1 using Configuration.Annotations;
2 using System;
3 using System.Collections.Generic;
4 using System.Collections.ObjectModel;
5 using System.ComponentModel;
6 using System.Linq;
7 using System.Runtime.CompilerServices;
8 using System.Text;
9 using System.Threading.Tasks;
10  
11 namespace Configuration
12 {
13 public class Definitions : INotifyPropertyChanged
14 {
15 public ObservableCollection<Band> Bands
16 {
17 get => _bands;
18 set
19 {
20 if (value == _bands)
21 {
22 return;
23 }
24  
25 _metersToBand.Clear();
26 foreach (var band in value)
27 {
28 _metersToBand.Add(band.Meters, band);
29 }
30  
31 _bands = value;
32  
33 OnPropertyChanged();
34 }
35 }
36  
37 public Definitions()
38 {
39 if(_metersToBand.Count == 0)
40 {
41 foreach(var band in _bands)
42 {
43 _metersToBand.Add(band.Meters, band);
44 }
45 }
46 }
47  
48 private Dictionary<int, Band> _metersToBand = new Dictionary<int, Band>();
49  
50 private ObservableCollection<Band> _bands = new ObservableCollection<Band>
51 {
52 new Band { Meters = 6, Min = 050000000, Max = 054000000 },
53 new Band { Meters = 10, Min = 028000000, Max = 029700000 },
54 new Band { Meters = 11, Min = 026965000, Max = 027405000 },
55 new Band { Meters = 12, Min = 024920000, Max = 024990000 },
56 new Band { Meters = 15, Min = 021000000, Max = 021450000 },
57 new Band { Meters = 17, Min = 018068000, Max = 018168000 },
58 new Band { Meters = 20, Min = 014000000, Max = 014350000 },
59 new Band { Meters = 30, Min = 010100000, Max = 010150000 },
60 new Band { Meters = 40, Min = 007000000, Max = 007300000 },
61 };
62  
63 /// <summary>
64 /// Retrieve the minimum and maximum frequency from meters.
65 /// </summary>
66 /// <param name="meters">meters corresponding to a band</param>
67 /// <param name="band">the band</param>
68 /// <returns>true upon a band definition existing</returns>
69 public bool TryGetBand(int meters, out Band band)
70 {
71 return _metersToBand.TryGetValue(meters, out band);
72 }
73  
74 public event PropertyChangedEventHandler PropertyChanged;
75  
76 [NotifyPropertyChangedInvocator]
77 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
78 {
79 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
80 }
81 }
82 }