using System; using System.ComponentModel; using System.Net; using System.Windows.Media.Imaging; using System.Linq; using Juick.Api; namespace Juick.ViewModels { public class MessageViewModel : INotifyPropertyChanged { public MessageViewModel() { } public MessageViewModel(Message message) { MID = message.Mid; RID = message.Rid; Username = message.User.UName; MessageText = HttpUtility.HtmlDecode(message.Body); if (message.Tags != null) { MessageText = string.Join(", ", message.Tags) + Environment.NewLine + MessageText; } } private int _mid; /// /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding. /// /// public int MID { get { return _mid; } set { if (value != _mid) { _mid = value; NotifyPropertyChanged("MID"); } } } private int _rid; /// /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding. /// /// public int RID { get { return _rid; } set { if (value != _rid) { _rid = value; NotifyPropertyChanged("RID"); } } } private string _username; /// /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding. /// /// public string Username { get { return _username; } set { if (value != _username) { _username = value; NotifyPropertyChanged("Username"); } } } private BitmapImage _avatar; public BitmapImage UserAvatar { get { return _avatar; } set { if (value != _avatar) { _avatar = value; NotifyPropertyChanged("Useravatar"); } } } private BitmapImage _attach; public BitmapImage Attachment { get { return _attach; } set { if (value != _attach) { _attach = value; NotifyPropertyChanged("Attachment"); } } } private string _messageText; /// /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding. /// /// public string MessageText { get { return _messageText; } set { if (value != _messageText) { _messageText = value; NotifyPropertyChanged("MessageText"); } } } private string _status; /// /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding. /// /// public string Status { get { return _status; } set { if (value != _status) { _status = value; NotifyPropertyChanged("Status"); } } } public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } } }