HamBook – Rev 56
?pathlinks?
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Xml.Serialization;
using HamBook.Radios.Generic;
namespace HamBook
{
[XmlRoot(Namespace = "urn:hambook-radiomenu-schema", ElementName = "RadioMenu")]
public class RadioMenu : INotifyPropertyChanged
{
private List<RadioMenuItem> _radioMenuItem = new List<RadioMenuItem>();
[XmlElement(ElementName = "RadioMenuItem")]
public List<RadioMenuItem> RadioMenuItem
{
get => _radioMenuItem;
set
{
if (Equals(value, _radioMenuItem))
{
return;
}
_radioMenuItem = value;
foreach (var item in _radioMenuItem)
{
MenuValueToIndex.Add(item.Value, item.Index);
MenuIndexToValue.Add(item.Index, item.Value);
}
OnPropertyChanged();
}
}
[XmlIgnore] public Dictionary<string, int> MenuValueToIndex = new Dictionary<string, int>();
[XmlIgnore] public Dictionary<int, string> MenuIndexToValue = new Dictionary<int, string>();
public RadioMenu()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
{
return false;
}
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
}
Generated by GNU Enscript 1.6.5.90.