| | 1 | | using MUNity.Base; |
| | 2 | | using MUNityBase.Interfances; |
| | 3 | | using System; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.ComponentModel; |
| | 6 | | using System.Runtime.CompilerServices; |
| | 7 | | using System.Text; |
| | 8 | | using System.Text.Json.Serialization; |
| | 9 | |
|
| | 10 | | namespace MUNity.ViewModels.ListOfSpeakers |
| | 11 | | { |
| | 12 | |
|
| | 13 | | /// <summary> |
| | 14 | | /// A Speaker is someone who can be added to the Speakers or Questions inside a List of Speakers. |
| | 15 | | /// You can give any time of name, so you could set it to a person a Country or Delegation. |
| | 16 | | /// </summary> |
| | 17 | | public class SpeakerViewModel : INotifyPropertyChanged, IComparable<SpeakerViewModel>, ISpeaker |
| | 18 | | { |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// The Id of the Speaker. This can and should change every time |
| | 22 | | /// even if the same person is in one of the lists twice to be able to identify it exact. |
| | 23 | | /// The Id has nothing to do with the Paricipant, Delegation, Country etc. |
| | 24 | | /// </summary> |
| 0 | 25 | | public string Id { get; set; } |
| | 26 | |
|
| | 27 | | private string _name; |
| | 28 | | /// <summary> |
| | 29 | | /// The Name that will be displayed. |
| | 30 | | /// </summary> |
| | 31 | | public string Name |
| | 32 | | { |
| 0 | 33 | | get => _name; |
| | 34 | | set |
| 0 | 35 | | { |
| 0 | 36 | | if (value != _name) |
| 0 | 37 | | { |
| 0 | 38 | | _name = value; |
| 0 | 39 | | NotifyPropertyChanged(); |
| 0 | 40 | | } |
| 0 | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| | 44 | | private string _iso; |
| | 45 | | /// <summary> |
| | 46 | | /// An Iso code because mostly Counties will be used in this list. You could use the |
| | 47 | | /// Iso to identify an icon. |
| | 48 | | /// </summary> |
| | 49 | | public string Iso |
| | 50 | | { |
| 0 | 51 | | get => _iso; |
| | 52 | | set |
| 0 | 53 | | { |
| 0 | 54 | | if (value != _iso) |
| 0 | 55 | | { |
| 0 | 56 | | _iso = value; |
| 0 | 57 | | NotifyPropertyChanged(); |
| 0 | 58 | | } |
| 0 | 59 | | } |
| | 60 | | } |
| | 61 | |
|
| | 62 | | private SpeakerModes _mode; |
| | 63 | | /// <summary> |
| | 64 | | /// The Mode if the Speaker is on the List of Speakers or asking a question |
| | 65 | | /// </summary> |
| | 66 | | public SpeakerModes Mode |
| | 67 | | { |
| 0 | 68 | | get => _mode; |
| | 69 | | set |
| 0 | 70 | | { |
| 0 | 71 | | if (_mode != value) |
| 0 | 72 | | { |
| 0 | 73 | | _mode = value; |
| 0 | 74 | | NotifyPropertyChanged(); |
| 0 | 75 | | } |
| 0 | 76 | | } |
| | 77 | | } |
| | 78 | |
|
| 0 | 79 | | private int _orderIndex = 0; |
| | 80 | | /// <summary> |
| | 81 | | /// The Index of the Speaker. |
| | 82 | | /// </summary> |
| | 83 | | public int OrdnerIndex |
| | 84 | | { |
| 0 | 85 | | get => _orderIndex; |
| | 86 | | set |
| 0 | 87 | | { |
| 0 | 88 | | if (_orderIndex != value) |
| 0 | 89 | | { |
| 0 | 90 | | _orderIndex = value; |
| 0 | 91 | | NotifyPropertyChanged(); |
| 0 | 92 | | } |
| 0 | 93 | | } |
| | 94 | | } |
| | 95 | |
|
| | 96 | | /// <summary> |
| | 97 | | /// The Parent SpeakerlistId |
| | 98 | | /// </summary> |
| | 99 | | [JsonIgnore] |
| 0 | 100 | | public ListOfSpeakersViewModel ListOfSpeakers { get; set; } |
| | 101 | |
|
| | 102 | | /// <summary> |
| | 103 | | /// Gets called when a proeprty has been changed. This does not inclide the SpeakerlistId or the Id. |
| | 104 | | /// </summary> |
| | 105 | | public event PropertyChangedEventHandler PropertyChanged; |
| | 106 | | private void NotifyPropertyChanged([CallerMemberName]string name = "") |
| 0 | 107 | | { |
| 0 | 108 | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); |
| 0 | 109 | | } |
| | 110 | |
|
| | 111 | | /// <summary> |
| | 112 | | /// Compares this Speaker to another Speaker by its values. |
| | 113 | | /// </summary> |
| | 114 | | /// <param name="other"></param> |
| | 115 | | /// <returns></returns> |
| | 116 | | public int CompareTo(SpeakerViewModel other) |
| 0 | 117 | | { |
| 0 | 118 | | if (this.Id != other.Id) return 1; |
| 0 | 119 | | if (this.Iso != other.Iso) return 1; |
| 0 | 120 | | if (this.Name != other.Name) return 1; |
| 0 | 121 | | if (this.OrdnerIndex != other.OrdnerIndex) return 1; |
| 0 | 122 | | return 0; |
| 0 | 123 | | } |
| | 124 | |
|
| | 125 | | public int CompareTo(ISpeaker other) |
| 0 | 126 | | { |
| 0 | 127 | | if (this.Id != other.Id) return 1; |
| 0 | 128 | | if (this.Iso != other.Iso) return 1; |
| 0 | 129 | | if (this.Name != other.Name) return 1; |
| 0 | 130 | | if (this.OrdnerIndex != other.OrdnerIndex) return 1; |
| 0 | 131 | | return 0; |
| 0 | 132 | | } |
| | 133 | | } |
| | 134 | | } |