|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.ComponentModel; |
| 4 | +using System.IO; |
| 5 | +using System.Linq; |
| 6 | +using System.Runtime.InteropServices.WindowsRuntime; |
| 7 | +using Signal_Windows.Models; |
| 8 | +using Windows.Foundation; |
| 9 | +using Windows.Foundation.Collections; |
| 10 | +using Windows.UI.Xaml; |
| 11 | +using Windows.UI.Xaml.Controls; |
| 12 | +using Windows.UI.Xaml.Controls.Primitives; |
| 13 | +using Windows.UI.Xaml.Data; |
| 14 | +using Windows.UI.Xaml.Input; |
| 15 | +using Windows.UI.Xaml.Media; |
| 16 | +using Windows.UI.Xaml.Navigation; |
| 17 | + |
| 18 | +// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 |
| 19 | + |
| 20 | +namespace Signal_Windows.Controls |
| 21 | +{ |
| 22 | + public sealed partial class AddContactListElement : UserControl, INotifyPropertyChanged |
| 23 | + { |
| 24 | + public event PropertyChangedEventHandler PropertyChanged; |
| 25 | + |
| 26 | + public AddContactListElement() |
| 27 | + { |
| 28 | + this.InitializeComponent(); |
| 29 | + this.DataContextChanged += AddContactListElement_DataContextChanged; |
| 30 | + } |
| 31 | + |
| 32 | + public string _DisplayName; |
| 33 | + public string DisplayName |
| 34 | + { |
| 35 | + get { return _DisplayName; } |
| 36 | + set |
| 37 | + { |
| 38 | + _DisplayName = value; |
| 39 | + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DisplayName))); |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + public string _PhoneNumber; |
| 44 | + public string PhoneNumber |
| 45 | + { |
| 46 | + get { return _PhoneNumber; } |
| 47 | + set |
| 48 | + { |
| 49 | + _PhoneNumber = value; |
| 50 | + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PhoneNumber))); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + public ImageSource _ContactPhoto = null; |
| 55 | + public ImageSource ContactPhoto |
| 56 | + { |
| 57 | + get { return _ContactPhoto; } |
| 58 | + set |
| 59 | + { |
| 60 | + _ContactPhoto = value; |
| 61 | + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ContactPhoto))); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + public bool _OnSignal; |
| 66 | + public bool OnSignal |
| 67 | + { |
| 68 | + get { return _OnSignal; } |
| 69 | + set |
| 70 | + { |
| 71 | + _OnSignal = value; |
| 72 | + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OnSignal))); |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + public PhoneContact Model |
| 77 | + { |
| 78 | + get |
| 79 | + { |
| 80 | + return DataContext as PhoneContact; |
| 81 | + } |
| 82 | + set |
| 83 | + { |
| 84 | + DataContext = value; |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + private void AddContactListElement_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) |
| 89 | + { |
| 90 | + if (Model != null) |
| 91 | + { |
| 92 | + Model.View = this; |
| 93 | + DisplayName = Model.Name; |
| 94 | + PhoneNumber = Model.PhoneNumber; |
| 95 | + ContactPhoto = Model.Photo; |
| 96 | + OnSignal = Model.OnSignal; |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments