HamBook – Blame information for rev 56
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
56 | office | 1 | using System.Collections.Generic; |
2 | using System.ComponentModel; |
||
3 | using System.Runtime.CompilerServices; |
||
4 | using System.Xml.Serialization; |
||
5 | using HamBook.Radios.Generic; |
||
6 | |||
7 | namespace HamBook |
||
8 | { |
||
9 | [XmlRoot(Namespace = "urn:hambook-radiomenu-schema", ElementName = "RadioMenu")] |
||
10 | public class RadioMenu : INotifyPropertyChanged |
||
11 | { |
||
12 | private List<RadioMenuItem> _radioMenuItem = new List<RadioMenuItem>(); |
||
13 | |||
14 | [XmlElement(ElementName = "RadioMenuItem")] |
||
15 | public List<RadioMenuItem> RadioMenuItem |
||
16 | { |
||
17 | get => _radioMenuItem; |
||
18 | set |
||
19 | { |
||
20 | if (Equals(value, _radioMenuItem)) |
||
21 | { |
||
22 | return; |
||
23 | } |
||
24 | |||
25 | _radioMenuItem = value; |
||
26 | foreach (var item in _radioMenuItem) |
||
27 | { |
||
28 | MenuValueToIndex.Add(item.Value, item.Index); |
||
29 | MenuIndexToValue.Add(item.Index, item.Value); |
||
30 | } |
||
31 | |||
32 | OnPropertyChanged(); |
||
33 | } |
||
34 | } |
||
35 | |||
36 | [XmlIgnore] public Dictionary<string, int> MenuValueToIndex = new Dictionary<string, int>(); |
||
37 | [XmlIgnore] public Dictionary<int, string> MenuIndexToValue = new Dictionary<int, string>(); |
||
38 | |||
39 | public RadioMenu() |
||
40 | { |
||
41 | |||
42 | } |
||
43 | |||
44 | public event PropertyChangedEventHandler PropertyChanged; |
||
45 | |||
46 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||
47 | { |
||
48 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
49 | } |
||
50 | |||
51 | protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null) |
||
52 | { |
||
53 | if (EqualityComparer<T>.Default.Equals(field, value)) |
||
54 | { |
||
55 | return false; |
||
56 | } |
||
57 | |||
58 | field = value; |
||
59 | OnPropertyChanged(propertyName); |
||
60 | return true; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | |||
65 | } |