|
| 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 Attachment : UserControl, INotifyPropertyChanged |
| 23 | + { |
| 24 | + public event PropertyChangedEventHandler PropertyChanged; |
| 25 | + |
| 26 | + private string fileName; |
| 27 | + public string FileName |
| 28 | + { |
| 29 | + get { return fileName; } |
| 30 | + set { fileName = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FileName))); } |
| 31 | + } |
| 32 | + |
| 33 | + private string fileSize; |
| 34 | + public string FileSize |
| 35 | + { |
| 36 | + get { return fileSize; } |
| 37 | + set { fileSize = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FileSize))); } |
| 38 | + } |
| 39 | + |
| 40 | + public SignalAttachment Model |
| 41 | + { |
| 42 | + get { return DataContext as SignalAttachment; } |
| 43 | + set { DataContext = value; } |
| 44 | + } |
| 45 | + |
| 46 | + public Attachment() |
| 47 | + { |
| 48 | + this.InitializeComponent(); |
| 49 | + DataContextChanged += Attachment_DataContextChanged; |
| 50 | + } |
| 51 | + |
| 52 | + private void Attachment_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) |
| 53 | + { |
| 54 | + if (Model != null) |
| 55 | + { |
| 56 | + FileName = Model.FileName; |
| 57 | + FileSize = Utils.BytesToString(Model.Size); |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments