summaryrefslogtreecommitdiff
path: root/Juick/ViewModels/ThreadViewModel.cs
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2012-03-10 22:14:25 +0400
committerGravatar Vitaly Takmazov2012-03-10 22:14:25 +0400
commit2b387fb5626a57e3a6473eed66816df80152cd49 (patch)
tree0b2f2ede5dcc79c1adbb8b64c2296aaeed1416fb /Juick/ViewModels/ThreadViewModel.cs
parent4a664984f58b00493a61cb19fafc0ca01d35b930 (diff)
refactoring, tags
Diffstat (limited to 'Juick/ViewModels/ThreadViewModel.cs')
-rw-r--r--Juick/ViewModels/ThreadViewModel.cs72
1 files changed, 8 insertions, 64 deletions
diff --git a/Juick/ViewModels/ThreadViewModel.cs b/Juick/ViewModels/ThreadViewModel.cs
index a929700..e1f8152 100644
--- a/Juick/ViewModels/ThreadViewModel.cs
+++ b/Juick/ViewModels/ThreadViewModel.cs
@@ -1,73 +1,17 @@
using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.IO;
-using System.Net;
-using System.Net.Browser;
-using System.Runtime.Serialization.Json;
-using System.Windows.Media.Imaging;
-using Juick.Api;
-using RestSharp;
namespace Juick.ViewModels
{
- public class ThreadViewModel : INotifyPropertyChanged
+ public class ThreadViewModel : MessageListViewModelBase
{
- public ThreadViewModel()
+ private int _mid;
+ public int Mid
{
- this.Items = new ObservableCollection<MessageViewModel>();
- }
-
- /// <summary>
- /// A collection for MessageViewModel objects.
- /// </summary>
- public ObservableCollection<MessageViewModel> Items { get; private set; }
-
- public bool IsDataLoaded
- {
- get;
- private set;
- }
-
- public MessageViewModel Root { get; set; }
-
- /// <summary>
- /// Creates and adds a few MessageViewModel objects into the MyFeed collection.
- /// </summary>
- public void LoadData()
- {
- var request = new RestRequest("/thread?mid={mid}" + "&rnd=" + Environment.TickCount);
- request.AddUrlSegment("mid", string.Format("{0}",Root.MID));
- App.Client.Authenticator = new HttpBasicAuthenticator(App.Account.Credentials.UserName, App.Account.Credentials.Password);
- App.Client.ExecuteAsync<List<Message>>(request, response =>
- {
- var messages = response.Data;
- Items.Clear();
- messages.ForEach(post =>
- {
- var item = new MessageViewModel(post);
- Items.Add(item);
- var imageUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", post.User.Uid), UriKind.Absolute);
- item.UserAvatar = new BitmapImage
- {
- UriSource = imageUri
- };
- item.NotifyPropertyChanged("UserAvatar");
- });
- IsDataLoaded = true;
- NotifyPropertyChanged("Items");
-
- });
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
- private void NotifyPropertyChanged(String propertyName)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (null != handler)
- {
- handler(this, new PropertyChangedEventArgs(propertyName));
+ get { return _mid; }
+ set
+ {
+ _mid = value;
+ RestUri = string.Format("/thread?mid={0}", _mid) + "&rnd=" + Environment.TickCount;
}
}
}