using System.ComponentModel; using Avalonia.Media; using Nonemm.Contests; using Nonemm.Core; using Nonemm.Session; namespace Nonemm.App.Windows; /// One line of the log window. The grid reaches the fields through the indexer, /// so the columns can follow the contest exchange and the operator's choice /// instead of being fixed in the XAML. The colour comes from the same scorer as /// the entry window and the bandmap. public sealed class LogRow : INotifyPropertyChanged { public LogRow(Qso qso, Verdict? verdict) { Qso = qso; Verdict = verdict; } public event PropertyChangedEventHandler? PropertyChanged; public Qso Qso { get; private set; } public Verdict? Verdict { get; private set; } /// Takes the contact again after it was edited. The grid redraws the line /// it is already showing, so the view stays where it was. "Item" is the /// name the indexer below has in the metadata, and the name the binding /// listens for; any other name is ignored. public void Show(Qso qso, Verdict? verdict) { Qso = qso; Verdict = verdict; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item")); } /// `name` is a `QsoField` name. Read only: an edited cell is written back by /// `LogWindow.TakeCellEdit` when the operator takes the edit, not as the /// text is typed. public string this[string name] => QsoEditor.Read(Qso, Enum.Parse(name)); public IBrush Colour => Verdicts.Colour(Verdict); }