summaryrefslogtreecommitdiff
path: root/Juick/ViewModels/MessageViewModel.cs
blob: e120c5d8c10079bda8d804a13c32d98ae92a5885 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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;
        /// <summary>
        /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public int MID
        {
            get
            {
                return _mid;
            }
            set
            {
                if (value != _mid)
                {
                    _mid = value;
                    NotifyPropertyChanged("MID");
                }
            }
        }

        private int _rid;
        /// <summary>
        /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public int RID
        {
            get
            {
                return _rid;
            }
            set
            {
                if (value != _rid)
                {
                    _rid = value;
                    NotifyPropertyChanged("RID");
                }
            }
        }
        private string _username;
        /// <summary>
        /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        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;
        /// <summary>
        /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        public string MessageText
        {
            get
            {
                return _messageText;
            }
            set
            {
                if (value != _messageText)
                {
                    _messageText = value;
                    NotifyPropertyChanged("MessageText");
                }
            }
        }

        private string _status;
        /// <summary>
        /// Sample _viewModelBase property; this property is used in the view to display its value using a Binding.
        /// </summary>
        /// <returns></returns>
        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));
            }
        }
    }
}