summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick.sln9
-rw-r--r--Juick/App.xaml.cs4
-rw-r--r--Juick/Classes/DelegateCommand.cs16
-rw-r--r--Juick/MainPage.xaml12
-rw-r--r--Juick/ThreadView.xaml20
-rw-r--r--Juick/ViewModels/AppViewModel.cs22
-rw-r--r--Juick/ViewModels/PageViewModel.cs40
-rw-r--r--Juick/ViewModels/PostItem.cs2
-rw-r--r--Juick/ViewModels/ViewModelBase.cs13
9 files changed, 48 insertions, 90 deletions
diff --git a/Juick.sln b/Juick.sln
index 83cc7a9..91623ef 100644
--- a/Juick.sln
+++ b/Juick.sln
@@ -1,8 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2010 Express for Windows Phone
+# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Juick", "Juick\Juick.csproj", "{324D7F67-600D-4239-90D9-07C9CA17A4F3}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6A493B4A-FF0A-420F-A47B-CEB4DB1D2DBA}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\NuGet.Config = .nuget\NuGet.Config
+ .nuget\NuGet.exe = .nuget\NuGet.exe
+ .nuget\NuGet.targets = .nuget\NuGet.targets
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/Juick/App.xaml.cs b/Juick/App.xaml.cs
index e9fd258..8662972 100644
--- a/Juick/App.xaml.cs
+++ b/Juick/App.xaml.cs
@@ -5,15 +5,13 @@ using Juick.Classes;
using Juick.ViewModels;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
-using RestSharp;
namespace Juick
{
public partial class App : Application
{
public void NavigateTo(Uri param) {
- var current = ((App)App.Current).RootFrame;
- current.Navigate(param);
+ RootFrame.Navigate(param);
}
private static AppViewModel context = null;
diff --git a/Juick/Classes/DelegateCommand.cs b/Juick/Classes/DelegateCommand.cs
index 40256e5..b9ee13a 100644
--- a/Juick/Classes/DelegateCommand.cs
+++ b/Juick/Classes/DelegateCommand.cs
@@ -3,27 +3,27 @@ using System.Windows.Input;
namespace Juick.Classes
{
- public class DelegateCommand : ICommand
+ public class DelegateCommand<T> : ICommand
{
- readonly Action<object> action;
- readonly Func<bool> canExecute;
+ readonly Action<T> _action;
+ readonly Func<bool> _canExecute;
- public DelegateCommand(Action<object> execute, Func<bool> canExecute)
+ public DelegateCommand(Action<T> execute, Func<bool> canExecute)
{
- this.action = execute;
- this.canExecute = canExecute;
+ _action = execute;
+ _canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
- return canExecute();
+ return _canExecute();
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
- action(parameter);
+ _action((T)parameter);
}
public void NotifyCanExecuteChanged()
diff --git a/Juick/MainPage.xaml b/Juick/MainPage.xaml
index c6d6a3a..2e40d0f 100644
--- a/Juick/MainPage.xaml
+++ b/Juick/MainPage.xaml
@@ -7,8 +7,6 @@
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
- xmlns:bindings="clr-namespace:Juick.Classes"
xmlns:usercontrols="clr-namespace:Juick.Controls"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
@@ -23,18 +21,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
- <phoneshell:SystemTray.ProgressIndicator>
- <phoneshell:ProgressIndicator IsIndeterminate="{Binding IsDataLoading}"
- IsVisible="{Binding IsDataLoading}"
- Text="Loading..." />
- </phoneshell:SystemTray.ProgressIndicator>
<controls:Pivot Title="juick" Grid.Row="1">
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="SelectionChanged">
-
- </i:EventTrigger>
- </i:Interaction.Triggers>
<controls:PivotItem Header="My feed" Margin="0, -5, 0, 0">
<usercontrols:MessageList x:Name="Home" />
</controls:PivotItem>
diff --git a/Juick/ThreadView.xaml b/Juick/ThreadView.xaml
index efab81a..0665055 100644
--- a/Juick/ThreadView.xaml
+++ b/Juick/ThreadView.xaml
@@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
+ xmlns:phoneshell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Juick.Controls" xmlns:bindings="clr-namespace:Juick.Classes"
@@ -12,7 +12,7 @@
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
+ phoneshell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
@@ -78,14 +78,14 @@
<!--Sample code showing usage of ApplicationBar-->
<!-- phone:PhoneApplicationPage.ApplicationBar>
- <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
- <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
- <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
- <shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
- <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
- </shell:ApplicationBar.MenuItems>
- </shell:ApplicationBar>
+ <phoneshell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
+ <phoneshell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
+ <phoneshell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
+ <phoneshell:ApplicationBar.MenuItems>
+ <phoneshell:ApplicationBarMenuItem Text="MenuItem 1"/>
+ <phoneshell:ApplicationBarMenuItem Text="MenuItem 2"/>
+ </phoneshell:ApplicationBar.MenuItems>
+ </phoneshell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar -->
</phone:PhoneApplicationPage>
diff --git a/Juick/ViewModels/AppViewModel.cs b/Juick/ViewModels/AppViewModel.cs
index 5d22cab..50b95b8 100644
--- a/Juick/ViewModels/AppViewModel.cs
+++ b/Juick/ViewModels/AppViewModel.cs
@@ -1,13 +1,4 @@
using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
using System.Collections.ObjectModel;
using Juick.Classes;
using RestSharp;
@@ -19,23 +10,18 @@ namespace Juick.ViewModels
private ObservableCollection<PageViewModel> _pages;
public ObservableCollection<PageViewModel> Pages
{
- get
- {
- if (_pages == null)
- _pages = new ObservableCollection<PageViewModel>();
- return _pages;
- }
+ get { return _pages ?? (_pages = new ObservableCollection<PageViewModel>()); }
}
static readonly string IsDataLoadingPropertyName = ExpressionHelper.GetPropertyName<AppViewModel>(x => x.IsDataLoading);
- bool isDataLoading;
+ bool _isDataLoading;
public bool IsDataLoading
{
- get { return isDataLoading; }
+ get { return _isDataLoading; }
set
{
- isDataLoading = value;
+ _isDataLoading = value;
NotifyPropertyChanged(IsDataLoadingPropertyName);
foreach (var page in Pages)
{
diff --git a/Juick/ViewModels/PageViewModel.cs b/Juick/ViewModels/PageViewModel.cs
index 9b9cae5..ff64dac 100644
--- a/Juick/ViewModels/PageViewModel.cs
+++ b/Juick/ViewModels/PageViewModel.cs
@@ -2,15 +2,11 @@
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.Net;
using System.Windows;
-using System.Windows.Media.Imaging;
using Juick.Classes;
using JuickApi;
using RestSharp;
-using System.Diagnostics;
-using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using System.Windows.Controls;
@@ -20,13 +16,13 @@ namespace Juick.ViewModels
{
public PageViewModel(AppViewModel context)
{
- this.context = context;
+ _context = context;
Items = new ObservableCollection<PostItem>();
- LoadMessagesPageCommand = new DelegateCommand(LoadData, () => !context.IsDataLoading);
- NavigateNextCommand = new DelegateCommand(NavigateToThread, () => true);
+ LoadMessagesPageCommand = new DelegateCommand<LinkUnlinkEventArgs>(LoadData, () => !context.IsDataLoading);
+ NavigateNextCommand = new DelegateCommand<SelectionChangedEventArgs>(NavigateToThread, () => true);
}
- private AppViewModel context;
+ private readonly AppViewModel _context;
public string RestUri { get; set; }
public virtual string Caption { get { return "juick"; } }
@@ -36,16 +32,15 @@ namespace Juick.ViewModels
/// </summary>
public ObservableCollection<PostItem> Items { get; private set; }
- public DelegateCommand LoadMessagesPageCommand { get; private set; }
+ public DelegateCommand<LinkUnlinkEventArgs> LoadMessagesPageCommand { get; private set; }
- public DelegateCommand NavigateNextCommand { get; private set; }
+ public DelegateCommand<SelectionChangedEventArgs> NavigateNextCommand { get; private set; }
- public void NavigateToThread(object param)
+ public void NavigateToThread(SelectionChangedEventArgs param)
{
- var selectionChangedEventArgs = param as SelectionChangedEventArgs;
if (param != null)
{
- ((App)App.Current).NavigateTo(new Uri(string.Format("/ThreadView.xaml?mid={0}", ((PostItem)selectionChangedEventArgs.AddedItems[0]).MID), UriKind.Relative));
+ ((App)App.Current).NavigateTo(new Uri(string.Format("/ThreadView.xaml?mid={0}", ((PostItem)param.AddedItems[0]).MID), UriKind.Relative));
}
}
@@ -53,24 +48,21 @@ namespace Juick.ViewModels
/// <summary>
/// Creates and adds a few MessageViewModel objects into the Items collection.
/// </summary>
- public void LoadData(object EventArgs)
+ public void LoadData(LinkUnlinkEventArgs e)
{
const int offset = 5;
- if (context.IsDataLoading)
+ if (_context.IsDataLoading)
{
return;
}
- if (EventArgs != null)
+ if (e != null)
{
- var item = (EventArgs as LinkUnlinkEventArgs).ContentPresenter.Content;
+ var item = e.ContentPresenter.Content;
if (!item.Equals(Items[Items.Count - offset])) {
return;
}
}
- int count = Items.Count;
-
-
if (string.IsNullOrEmpty(RestUri))
{
RestUri = "/home?1=1";
@@ -90,14 +82,14 @@ namespace Juick.ViewModels
}
var request = new RestRequest(RestUri + "&rnd=" + Environment.TickCount);
- context.Client.Authenticator = new HttpBasicAuthenticator(context.Account.Credentials.UserName, context.Account.Credentials.Password);
- context.Client.ExecuteAsync<List<Message>>(request, ProcessResponse);
- context.IsDataLoading = true;
+ _context.Client.Authenticator = new HttpBasicAuthenticator(_context.Account.Credentials.UserName, _context.Account.Credentials.Password);
+ _context.Client.ExecuteAsync<List<Message>>(request, ProcessResponse);
+ _context.IsDataLoading = true;
}
void ProcessResponse(IRestResponse<List<Message>> response)
{
- context.IsDataLoading = false;
+ _context.IsDataLoading = false;
if (response.StatusCode != HttpStatusCode.OK)
{
MessageBox.Show(response.StatusCode.ToString());
diff --git a/Juick/ViewModels/PostItem.cs b/Juick/ViewModels/PostItem.cs
index 2072cf5..97935b3 100644
--- a/Juick/ViewModels/PostItem.cs
+++ b/Juick/ViewModels/PostItem.cs
@@ -1,7 +1,5 @@
using System;
-using System.ComponentModel;
using System.Net;
-using System.Windows.Media.Imaging;
using JuickApi;
namespace Juick.ViewModels
diff --git a/Juick/ViewModels/ViewModelBase.cs b/Juick/ViewModels/ViewModelBase.cs
index 9ac3023..1c864db 100644
--- a/Juick/ViewModels/ViewModelBase.cs
+++ b/Juick/ViewModels/ViewModelBase.cs
@@ -1,15 +1,4 @@
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using System.ComponentModel;
-using Juick.Classes;
+using System.ComponentModel;
namespace Juick.ViewModels
{