diff options
author | Vitaly Takmazov | 2012-03-10 22:31:11 +0400 |
---|---|---|
committer | Vitaly Takmazov | 2012-03-10 22:31:11 +0400 |
commit | bbd71073a1a21ba281ce63b67529aab64866bc7d (patch) | |
tree | dcfce0bb5c1981a72646850e8cc2f12c34c0d5c9 | |
parent | 2b387fb5626a57e3a6473eed66816df80152cd49 (diff) |
small fixes
-rw-r--r-- | Juick/ThreadView.xaml | 39 | ||||
-rw-r--r-- | Juick/ViewModels/MainViewModel.cs | 125 |
2 files changed, 23 insertions, 141 deletions
diff --git a/Juick/ThreadView.xaml b/Juick/ThreadView.xaml index 2decd6e..407b90d 100644 --- a/Juick/ThreadView.xaml +++ b/Juick/ThreadView.xaml @@ -9,7 +9,7 @@ FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
+ SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
shell:SystemTray.IsVisible="True">
@@ -37,29 +37,36 @@ <DataTemplate>
<Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1">
<Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <!-- RowDefinition Height="Auto" / -->
+ </Grid.RowDefinitions>
<Image Source="{Binding UserAvatar}" Grid.Row="0" Grid.Column="0" Margin="3" />
-
<TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1"
Margin="5,0,5,5" VerticalAlignment="Top"
+ HorizontalAlignment="Left"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
FontSize="{StaticResource PhoneFontSizeLarge}"
- Style="{StaticResource PhoneTextAccentStyle}" HorizontalAlignment="Left"/>
+ Style="{StaticResource PhoneTextAccentStyle}" />
<TextBlock Text="{Binding MessageText}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
- Foreground="{StaticResource PhoneForegroundBrush}"
- HorizontalAlignment="Left"
+ Foreground="{StaticResource PhoneForegroundBrush}"
Style="{StaticResource PhoneTextNormalStyle}"
Margin="5,0,5,5" VerticalAlignment="Top"
- TextWrapping="Wrap" />
- </Grid>
+ TextWrapping="Wrap" HorizontalAlignment="Left"/>
+ <Image Source="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" Grid.ColumnSpan="2" />
+ <!-- TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
+ Foreground="{StaticResource PhoneForegroundBrush}"
+ Style="{StaticResource PhoneTextAccentStyle}"
+ FontSize="{StaticResource PhoneFontSizeSmall}"
+ Margin="5,0,5,5" VerticalAlignment="Top"
+ TextWrapping="Wrap" HorizontalAlignment="Left"/ -->
+ </Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
diff --git a/Juick/ViewModels/MainViewModel.cs b/Juick/ViewModels/MainViewModel.cs deleted file mode 100644 index 3ee4a16..0000000 --- a/Juick/ViewModels/MainViewModel.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System;
-using System.ComponentModel;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Runtime.Serialization.Json;
-using System.Collections.ObjectModel;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media.Imaging;
-using Juick.Api;
-using RestSharp;
-
-namespace Juick.ViewModels
-{
- public class MainViewModel : INotifyPropertyChanged
- {
- public MainViewModel()
- {
- this.MyFeed = new ObservableCollection<MessageViewModel>();
- this.Last = new ObservableCollection<MessageViewModel>();
- }
-
- /// <summary>
- /// A collection for MessageViewModel objects.
- /// </summary>
- public ObservableCollection<MessageViewModel> MyFeed { get; private set; }
-
- /// <summary>
- /// A collection for MessageViewModel objects.
- /// </summary>
- public ObservableCollection<MessageViewModel> Last { get; private set; }
-
- public bool IsDataLoaded
- {
- get;
- private set;
- }
-
- /// <summary>
- /// Creates and adds a few MessageViewModel objects into the MyFeed collection.
- /// </summary>
- public void LoadData()
- {
- var request = new RestRequest("/home?1=1" + "&rnd=" + Environment.TickCount);
- App.Client.Authenticator = new HttpBasicAuthenticator(App.Account.Credentials.UserName, App.Account.Credentials.Password);
- App.Client.ExecuteAsync<List<Message>>(request, response =>
- {
- if (response.StatusCode != HttpStatusCode.OK)
- {
- MessageBox.Show(response.StatusCode.ToString());
- return;
- }
-
- var messages = response.Data;
- MyFeed.Clear();
- messages.ForEach(post =>
- {
- var item = new MessageViewModel(post)
- {
- Status =
- string.Format(
- "Posted on: {0}, replies: {1}",
- post.Timestamp,
- post.Replies)
- };
- MyFeed.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");
-
- });
- NotifyPropertyChanged("MyFeed");
-
- });
- var lastrequest = new RestRequest("/messages?1=1&media=all" + "&rnd=" + Environment.TickCount);
- App.Client.ExecuteAsync<List<Message>>(lastrequest, response =>
- {
-
- var messages = response.Data;
- if (messages.Count == 0) return;
- Last.Clear();
- messages.ForEach(post =>
- {
- var item = new MessageViewModel(post)
- {
- Status =
- string.Format(
- "Posted on: {0}, replies: {1}",
- post.Timestamp,
- post.Replies)
- };
- Last.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");
-
- if (post.Photo != null)
- {
- item.Attachment = new BitmapImage {UriSource = new Uri(post.Photo.Small, UriKind.Absolute)};
- item.NotifyPropertyChanged("Attachment");
- }
-
- });
- NotifyPropertyChanged("Last");
-
- });
- }
-
-
- public event PropertyChangedEventHandler PropertyChanged;
- public void NotifyPropertyChanged(String propertyName)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (null != handler)
- {
- handler(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
-}
\ No newline at end of file |