From 49eb44f852ab21e72c17bbc436ffa79525a1aba3 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 11 Feb 2012 22:22:50 +0400
Subject: v 0.999 :)
---
.gitignore | 27 ++++
Juick.sln | 22 ++++
Juick.vsmdi | 6 +
Juick/Api/Message.cs | 27 ++++
Juick/Api/User.cs | 21 ++++
Juick/App.xaml | 20 +++
Juick/App.xaml.cs | 171 ++++++++++++++++++++++++++
Juick/ApplicationIcon.png | Bin 0 -> 1881 bytes
Juick/Background.png | Bin 0 -> 3521 bytes
Juick/Classes/AccountManager.cs | 65 ++++++++++
Juick/Juick.csproj | 142 +++++++++++++++++++++
Juick/LoginView.xaml | 52 ++++++++
Juick/LoginView.xaml.cs | 35 ++++++
Juick/MainPage.xaml | 118 ++++++++++++++++++
Juick/MainPage.xaml.cs | 84 +++++++++++++
Juick/NewPostView.xaml | 51 ++++++++
Juick/NewPostView.xaml.cs | 95 ++++++++++++++
Juick/PanoramaBackground.png | Bin 0 -> 96017 bytes
Juick/Properties/AppManifest.xml | 6 +
Juick/Properties/AssemblyInfo.cs | 37 ++++++
Juick/Properties/WMAppManifest.xml | 35 ++++++
Juick/SampleData/MainViewModelSampleData.xaml | 16 +++
Juick/SplashScreenImage.jpg | Bin 0 -> 9417 bytes
Juick/SubmissionInfo/ManualTestResults.xml | 54 ++++++++
Juick/SubmissionInfo/Settings.xml | 9 ++
Juick/ThreadView.xaml | 75 +++++++++++
Juick/ThreadView.xaml.cs | 56 +++++++++
Juick/ViewModels/MainViewModel.cs | 101 +++++++++++++++
Juick/ViewModels/MessageViewModel.cs | 159 ++++++++++++++++++++++++
Juick/ViewModels/ThreadViewModel.cs | 70 +++++++++++
30 files changed, 1554 insertions(+)
create mode 100644 .gitignore
create mode 100644 Juick.sln
create mode 100644 Juick.vsmdi
create mode 100644 Juick/Api/Message.cs
create mode 100644 Juick/Api/User.cs
create mode 100644 Juick/App.xaml
create mode 100644 Juick/App.xaml.cs
create mode 100644 Juick/ApplicationIcon.png
create mode 100644 Juick/Background.png
create mode 100644 Juick/Classes/AccountManager.cs
create mode 100644 Juick/Juick.csproj
create mode 100644 Juick/LoginView.xaml
create mode 100644 Juick/LoginView.xaml.cs
create mode 100644 Juick/MainPage.xaml
create mode 100644 Juick/MainPage.xaml.cs
create mode 100644 Juick/NewPostView.xaml
create mode 100644 Juick/NewPostView.xaml.cs
create mode 100644 Juick/PanoramaBackground.png
create mode 100644 Juick/Properties/AppManifest.xml
create mode 100644 Juick/Properties/AssemblyInfo.cs
create mode 100644 Juick/Properties/WMAppManifest.xml
create mode 100644 Juick/SampleData/MainViewModelSampleData.xaml
create mode 100644 Juick/SplashScreenImage.jpg
create mode 100644 Juick/SubmissionInfo/ManualTestResults.xml
create mode 100644 Juick/SubmissionInfo/Settings.xml
create mode 100644 Juick/ThreadView.xaml
create mode 100644 Juick/ThreadView.xaml.cs
create mode 100644 Juick/ViewModels/MainViewModel.cs
create mode 100644 Juick/ViewModels/MessageViewModel.cs
create mode 100644 Juick/ViewModels/ThreadViewModel.cs
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2170ecb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+Thumbs.db
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.sln.docstates
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
\ No newline at end of file
diff --git a/Juick.sln b/Juick.sln
new file mode 100644
index 0000000..868fde2
--- /dev/null
+++ b/Juick.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Juick", "Juick\Juick.csproj", "{324D7F67-600D-4239-90D9-07C9CA17A4F3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Juick.vsmdi b/Juick.vsmdi
new file mode 100644
index 0000000..b212917
--- /dev/null
+++ b/Juick.vsmdi
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Juick/Api/Message.cs b/Juick/Api/Message.cs
new file mode 100644
index 0000000..b4d4ddc
--- /dev/null
+++ b/Juick/Api/Message.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+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.Runtime.Serialization;
+using System.Runtime.Serialization.Json;
+
+namespace Juick.Api
+{
+ [DataContract]
+ public class Message
+ {
+ [DataMember] public int mid;
+ [DataMember] public int rid;
+ [DataMember] public string body;
+ [DataMember] public User user;
+ [DataMember] public DateTime timestamp;
+ [DataMember] public int replies;
+ }
+}
diff --git a/Juick/Api/User.cs b/Juick/Api/User.cs
new file mode 100644
index 0000000..f7bd6eb
--- /dev/null
+++ b/Juick/Api/User.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Net;
+using System.Runtime.Serialization;
+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;
+
+namespace Juick.Api
+{
+ [DataContract]
+ public class User
+ {
+ [DataMember] public int uid;
+ [DataMember] public string uname;
+ }
+}
diff --git a/Juick/App.xaml b/Juick/App.xaml
new file mode 100644
index 0000000..0c60cc0
--- /dev/null
+++ b/Juick/App.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Juick/App.xaml.cs b/Juick/App.xaml.cs
new file mode 100644
index 0000000..54abe20
--- /dev/null
+++ b/Juick/App.xaml.cs
@@ -0,0 +1,171 @@
+using System;
+using System.Windows;
+using System.Windows.Navigation;
+using Juick.Classes;
+using Juick.ViewModels;
+using Microsoft.Phone.Controls;
+using Microsoft.Phone.Shell;
+using RestSharp;
+
+namespace Juick
+{
+ public partial class App : Application
+ {
+ private static MainViewModel viewModel = null;
+
+ ///
+ /// A static ViewModel used by the views to bind against.
+ ///
+ /// The MainViewModel object.
+ public static MainViewModel ViewModel
+ {
+ get
+ {
+ // Delay creation of the view model until necessary
+ return viewModel ?? (viewModel = new MainViewModel());
+ }
+ }
+
+ private static AccountManager _acc;
+
+ public static AccountManager Account
+ {
+ get { return _acc ?? (_acc = new AccountManager()); }
+ }
+
+ private static RestClient _cl;
+ public static RestClient Client
+ {
+ get { return _cl ?? (_cl = new RestClient("http://api.juick.com") {UserAgent = "Juick 0.999/Windows Phone " + Environment.OSVersion.Version}); }
+ }
+
+ ///
+ /// Provides easy access to the root frame of the Phone Application.
+ ///
+ /// The root frame of the Phone Application.
+ public PhoneApplicationFrame RootFrame { get; private set; }
+
+ ///
+ /// Constructor for the Application object.
+ ///
+ public App()
+ {
+ // Global handler for uncaught exceptions.
+ UnhandledException += Application_UnhandledException;
+
+ // Standard Silverlight initialization
+ InitializeComponent();
+
+ // Phone-specific initialization
+ InitializePhoneApplication();
+
+ // Show graphics profiling information while debugging.
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ // Display the current frame rate counters.
+ Current.Host.Settings.EnableFrameRateCounter = true;
+
+ // Show the areas of the app that are being redrawn in each frame.
+ //Application.Current.Host.Settings.EnableRedrawRegions = true;
+
+ // Enable non-production analysis visualization mode,
+ // which shows areas of a page that are handed off to GPU with a colored overlay.
+ //Application.Current.Host.Settings.EnableCacheVisualization = true;
+
+ // Disable the application idle detection by setting the UserIdleDetectionMode property of the
+ // application's PhoneApplicationService object to Disabled.
+ // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
+ // and consume battery power when the user is not using the phone.
+ PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
+ }
+
+ }
+
+ // Code to execute when the application is launching (eg, from Start)
+ // This code will not execute when the application is reactivated
+ private void Application_Launching(object sender, LaunchingEventArgs e)
+ {
+
+ }
+
+ // Code to execute when the application is activated (brought to foreground)
+ // This code will not execute when the application is first launched
+ private void Application_Activated(object sender, ActivatedEventArgs e)
+ {
+ // Ensure that application state is restored appropriately
+ if (!App.ViewModel.IsDataLoaded)
+ {
+ App.ViewModel.LoadData();
+ }
+ }
+
+ // Code to execute when the application is deactivated (sent to background)
+ // This code will not execute when the application is closing
+ private void Application_Deactivated(object sender, DeactivatedEventArgs e)
+ {
+ // Ensure that required application state is persisted here.
+ }
+
+ // Code to execute when the application is closing (eg, user hit Back)
+ // This code will not execute when the application is deactivated
+ private void Application_Closing(object sender, ClosingEventArgs e)
+ {
+ }
+
+ // Code to execute if a navigation fails
+ private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ // A navigation has failed; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ // Code to execute on Unhandled Exceptions
+ private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
+ {
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ // An unhandled exception has occurred; break into the debugger
+ System.Diagnostics.Debugger.Break();
+ }
+ }
+
+ #region Phone application initialization
+
+ // Avoid double-initialization
+ private bool phoneApplicationInitialized = false;
+
+ // Do not add any additional code to this method
+ private void InitializePhoneApplication()
+ {
+ if (phoneApplicationInitialized)
+ return;
+
+ // Create the frame but don't set it as RootVisual yet; this allows the splash
+ // screen to remain active until the application is ready to render.
+ RootFrame = new PhoneApplicationFrame();
+ RootFrame.Navigated += CompleteInitializePhoneApplication;
+
+ // Handle navigation failures
+ RootFrame.NavigationFailed += RootFrame_NavigationFailed;
+
+ // Ensure we don't initialize again
+ phoneApplicationInitialized = true;
+ }
+
+ // Do not add any additional code to this method
+ private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
+ {
+ // Set the root visual to allow the application to render
+ if (RootVisual != RootFrame)
+ RootVisual = RootFrame;
+
+ // Remove this handler since it is no longer needed
+ RootFrame.Navigated -= CompleteInitializePhoneApplication;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Juick/ApplicationIcon.png b/Juick/ApplicationIcon.png
new file mode 100644
index 0000000..5859393
Binary files /dev/null and b/Juick/ApplicationIcon.png differ
diff --git a/Juick/Background.png b/Juick/Background.png
new file mode 100644
index 0000000..e46f21d
Binary files /dev/null and b/Juick/Background.png differ
diff --git a/Juick/Classes/AccountManager.cs b/Juick/Classes/AccountManager.cs
new file mode 100644
index 0000000..f7fcc75
--- /dev/null
+++ b/Juick/Classes/AccountManager.cs
@@ -0,0 +1,65 @@
+using System;
+using System.IO;
+using System.IO.IsolatedStorage;
+using System.Linq;
+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.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace Juick.Classes
+{
+ public class AccountManager
+ {
+ const string FileName = "account.xml";
+ public NetworkCredential Credentials
+ {
+ get
+ {
+ return new NetworkCredential
+ {
+ UserName = IsolatedStorageSettings.ApplicationSettings.Contains("user") ?
+ IsolatedStorageSettings.ApplicationSettings["user"] as string : null,
+ Password = IsolatedStorageSettings.ApplicationSettings.Contains("password") ?
+ IsolatedStorageSettings.ApplicationSettings["password"] as string : null,
+ };
+ }
+ set
+ {
+ var creds = value;
+ if (creds != null)
+ {
+ IsolatedStorageSettings.ApplicationSettings["user"] = value.UserName;
+ IsolatedStorageSettings.ApplicationSettings["password"] = value.Password;
+ } else
+ {
+ IsolatedStorageSettings.ApplicationSettings["user"] = null;
+ IsolatedStorageSettings.ApplicationSettings["password"] = null;
+ }
+ }
+ }
+
+ public void SignIn(Page page, string login, string pass)
+ {
+ Credentials = new NetworkCredential(login, pass);
+ page.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
+ page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
+ }
+
+ public void SignOut(Page page)
+ {
+ Credentials = null;
+ page.NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative));
+ page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
+ }
+ }
+}
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
new file mode 100644
index 0000000..e550947
--- /dev/null
+++ b/Juick/Juick.csproj
@@ -0,0 +1,142 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {324D7F67-600D-4239-90D9-07C9CA17A4F3}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ Juick
+ Juick
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone71
+ Silverlight
+ true
+
+
+ true
+ true
+ Juick.xap
+ Properties\AppManifest.xml
+ Juick.App
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ App.xaml
+
+
+
+ LoginView.xaml
+
+
+ MainPage.xaml
+
+
+ NewPostView.xaml
+
+
+
+ ThreadView.xaml
+
+
+
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Juick/LoginView.xaml b/Juick/LoginView.xaml
new file mode 100644
index 0000000..6f47b72
--- /dev/null
+++ b/Juick/LoginView.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Juick/LoginView.xaml.cs b/Juick/LoginView.xaml.cs
new file mode 100644
index 0000000..d653932
--- /dev/null
+++ b/Juick/LoginView.xaml.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Juick.Classes;
+using Microsoft.Phone.Controls;
+
+namespace Juick
+{
+ public partial class LoginView : PhoneApplicationPage
+ {
+ public LoginView()
+ {
+ InitializeComponent();
+ DataContext = App.Account.Credentials;
+ }
+
+ private void button1_Click(object sender, RoutedEventArgs e)
+ {
+ App.Account.SignIn(this, textBox1.Text, textBox2.Password);
+ }
+
+ private void button2_Click(object sender, RoutedEventArgs e)
+ {
+ App.Account.SignOut(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/MainPage.xaml b/Juick/MainPage.xaml
new file mode 100644
index 0000000..3d7245c
--- /dev/null
+++ b/Juick/MainPage.xaml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Juick/MainPage.xaml.cs b/Juick/MainPage.xaml.cs
new file mode 100644
index 0000000..4468f6a
--- /dev/null
+++ b/Juick/MainPage.xaml.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Juick.Classes;
+using Microsoft.Phone.Controls;
+
+namespace Juick
+{
+ public partial class MainPage : PhoneApplicationPage
+ {
+ // Constructor
+ public MainPage()
+ {
+ InitializeComponent();
+
+ // Set the data context of the listbox control to the sample data
+ DataContext = App.ViewModel;
+ Loaded += MainPage_Loaded;
+ }
+
+ // Load data for the ViewModel MyFeed
+ private void MainPage_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (!App.ViewModel.IsDataLoaded)
+ {
+ if (string.IsNullOrEmpty(App.Account.Credentials.UserName))
+ NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative));
+ else
+ App.ViewModel.LoadData();
+ }
+ }
+
+ private void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // If selected index is -1 (no selection) do nothing
+ if (((ListBox)sender).SelectedIndex == -1)
+ return;
+
+ // Navigate to the new page
+ NavigationService.Navigate(new Uri("/ThreadView.xaml?mid=" + App.ViewModel.MyFeed[((ListBox)sender).SelectedIndex].MID, UriKind.Relative));
+
+ // Reset selected index to -1 (no selection)
+ ((ListBox)sender).SelectedIndex = -1;
+ }
+
+ private void LastBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // If selected index is -1 (no selection) do nothing
+ if (((ListBox)sender).SelectedIndex == -1)
+ return;
+
+ // Navigate to the new page
+ NavigationService.Navigate(new Uri(string.Format("/ThreadView.xaml?mid={0}&last=true", App.ViewModel.Last[((ListBox)sender).SelectedIndex].MID), UriKind.Relative));
+
+ // Reset selected index to -1 (no selection)
+ ((ListBox)sender).SelectedIndex = -1;
+ }
+
+ private void ApplicationBarIconButton_Click(object sender, EventArgs e)
+ {
+ App.ViewModel.MyFeed.Clear();
+ App.ViewModel.Last.Clear();
+ App.ViewModel.LoadData();
+ }
+
+ private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
+ {
+ App.Account.SignOut(this);
+ }
+
+ private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
+ {
+ NavigationService.Navigate(new Uri("/NewPostView.xaml", UriKind.Relative));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/NewPostView.xaml b/Juick/NewPostView.xaml
new file mode 100644
index 0000000..caa2b4f
--- /dev/null
+++ b/Juick/NewPostView.xaml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Juick/NewPostView.xaml.cs b/Juick/NewPostView.xaml.cs
new file mode 100644
index 0000000..68b7efb
--- /dev/null
+++ b/Juick/NewPostView.xaml.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Browser;
+using System.Reflection;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Resources;
+using System.Windows.Shapes;
+using Juick.Classes;
+using Microsoft.Phone.Controls;
+using Microsoft.Phone.Tasks;
+using Microsoft.Xna.Framework.Media;
+using RestSharp;
+
+namespace Juick
+{
+ public partial class NewPostView : PhoneApplicationPage
+ {
+ private PhotoChooserTask chooser;
+ public NewPostView()
+ {
+ InitializeComponent();
+ }
+
+ // When page is navigated to set data context to selected item in list
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ string _rid, _mid;
+ if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
+ {
+ PageTitle.Text = "reply";
+ button1.Content = "reply";
+ textBox1.Text = "#" + _mid;
+ }
+ if (NavigationContext.QueryString.TryGetValue("rid", out _rid))
+ {
+ textBox1.Text += "/" + _rid;
+ }
+ }
+
+ private void button1_Click(object sender, RoutedEventArgs e)
+ {
+
+ var request = new RestRequest("/post", Method.POST);
+ request.AddParameter("body", textBox1.Text);
+ if (image1.Source != null)
+ {
+ using (var ms = new MemoryStream())
+ {
+ var wb = new WriteableBitmap(image1, null);
+ wb.SaveJpeg(ms, (int) image1.Width, (int) image1.Height, 0, 100);
+ request.AddFile("attach", ms.ToArray(), "file.jpg");
+ }
+ }
+
+ App.Client.ExecuteAsync(request, response =>
+ {
+ if (response.StatusCode != HttpStatusCode.OK)
+ {
+ MessageBox.Show(response.StatusCode.ToString());
+ }
+ });
+
+ NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
+ Dispatcher.BeginInvoke(() => NavigationService.RemoveBackEntry());
+ }
+
+
+ private void button2_Click(object sender, RoutedEventArgs e)
+ {
+ chooser = new PhotoChooserTask {ShowCamera = true};
+ chooser.Completed += (o, result) =>
+ {
+ if (result.TaskResult == TaskResult.OK)
+ {
+
+ BinaryReader reader = new BinaryReader(result.ChosenPhoto);
+ image1.Source = new BitmapImage(new Uri(result.OriginalFileName));
+
+ }
+ };
+ chooser.Show();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/PanoramaBackground.png b/Juick/PanoramaBackground.png
new file mode 100644
index 0000000..691d2dc
Binary files /dev/null and b/Juick/PanoramaBackground.png differ
diff --git a/Juick/Properties/AppManifest.xml b/Juick/Properties/AppManifest.xml
new file mode 100644
index 0000000..a955232
--- /dev/null
+++ b/Juick/Properties/AppManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/Juick/Properties/AssemblyInfo.cs b/Juick/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d3496e2
--- /dev/null
+++ b/Juick/Properties/AssemblyInfo.cs
@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Juick")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Juick")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("22b71975-113b-4746-92ee-48b2d7aa377b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
diff --git a/Juick/Properties/WMAppManifest.xml b/Juick/Properties/WMAppManifest.xml
new file mode 100644
index 0000000..3bf3f96
--- /dev/null
+++ b/Juick/Properties/WMAppManifest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ ApplicationIcon.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Background.png
+ 0
+ Juick
+
+
+
+
+
diff --git a/Juick/SampleData/MainViewModelSampleData.xaml b/Juick/SampleData/MainViewModelSampleData.xaml
new file mode 100644
index 0000000..736a16e
--- /dev/null
+++ b/Juick/SampleData/MainViewModelSampleData.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Juick/SplashScreenImage.jpg b/Juick/SplashScreenImage.jpg
new file mode 100644
index 0000000..353b192
Binary files /dev/null and b/Juick/SplashScreenImage.jpg differ
diff --git a/Juick/SubmissionInfo/ManualTestResults.xml b/Juick/SubmissionInfo/ManualTestResults.xml
new file mode 100644
index 0000000..241b27c
--- /dev/null
+++ b/Juick/SubmissionInfo/ManualTestResults.xml
@@ -0,0 +1,54 @@
+
+
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+ Pending
+
+
\ No newline at end of file
diff --git a/Juick/SubmissionInfo/Settings.xml b/Juick/SubmissionInfo/Settings.xml
new file mode 100644
index 0000000..f140d85
--- /dev/null
+++ b/Juick/SubmissionInfo/Settings.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+ ;;;;;;;;
+
\ No newline at end of file
diff --git a/Juick/ThreadView.xaml b/Juick/ThreadView.xaml
new file mode 100644
index 0000000..20529c2
--- /dev/null
+++ b/Juick/ThreadView.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Juick/ThreadView.xaml.cs b/Juick/ThreadView.xaml.cs
new file mode 100644
index 0000000..c984dd1
--- /dev/null
+++ b/Juick/ThreadView.xaml.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows.Navigation;
+using Juick.ViewModels;
+using Microsoft.Phone.Controls;
+
+namespace Juick
+{
+ public partial class ThreadView : PhoneApplicationPage
+ {
+ public ThreadView()
+ {
+ InitializeComponent();
+ model = new ThreadViewModel();
+ DataContext = model;
+ }
+
+ public ThreadViewModel model;
+
+ // When page is navigated to set data context to selected item in list
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ string _mid = "";
+ string _last = "";
+ bool last = false;
+ if (NavigationContext.QueryString.TryGetValue("last", out _last))
+ {
+ last = bool.Parse(_last);
+ }
+ if (NavigationContext.QueryString.TryGetValue("mid", out _mid))
+ {
+ int MID = int.Parse(_mid);
+ model.Root = last ? App.ViewModel.Last.Single(i => i.MID == MID) : App.ViewModel.MyFeed.Single(i => i.MID == MID);
+ model.LoadData();
+ }
+ }
+
+ private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
+ {
+ // If selected index is -1 (no selection) do nothing
+ if (((ListBox)sender).SelectedIndex == -1)
+ return;
+
+ // Navigate to the new page
+ var item = model.Items[((ListBox) sender).SelectedIndex];
+ var destUri = string.Format("/NewPostView.xaml?mid={0}", item.MID);
+ if (item.RID > 0)
+ destUri += string.Format("&rid={0}", item.RID);
+ NavigationService.Navigate(new Uri(destUri , UriKind.Relative));
+
+ // Reset selected index to -1 (no selection)
+ ((ListBox)sender).SelectedIndex = -1;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/ViewModels/MainViewModel.cs b/Juick/ViewModels/MainViewModel.cs
new file mode 100644
index 0000000..a504658
--- /dev/null
+++ b/Juick/ViewModels/MainViewModel.cs
@@ -0,0 +1,101 @@
+using System;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Runtime.Serialization.Json;
+using System.Collections.ObjectModel;
+using System.Windows;
+using Juick.Api;
+using RestSharp;
+
+namespace Juick.ViewModels
+{
+ public class MainViewModel : INotifyPropertyChanged
+ {
+ public MainViewModel()
+ {
+ this.MyFeed = new ObservableCollection();
+ this.Last = new ObservableCollection();
+ }
+
+ ///
+ /// A collection for MessageViewModel objects.
+ ///
+ public ObservableCollection MyFeed { get; private set; }
+
+ ///
+ /// A collection for MessageViewModel objects.
+ ///
+ public ObservableCollection Last { get; private set; }
+
+ public bool IsDataLoaded
+ {
+ get;
+ private set;
+ }
+
+ ///
+ /// Creates and adds a few MessageViewModel objects into the MyFeed collection.
+ ///
+ 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(request, response =>
+ {
+ if (response.StatusCode != HttpStatusCode.OK)
+ {
+ MessageBox.Show(response.StatusCode.ToString());
+ return;
+ }
+ var ser = new DataContractJsonSerializer(typeof (List));
+
+ var messages =
+ (List)ser.ReadObject(new MemoryStream(response.RawBytes));
+ MyFeed.Clear();
+ messages.ForEach(post => MyFeed.Add(new MessageViewModel(post)
+ {
+ Status =
+ string.Format(
+ "Posted on: {0}, replies: {1}",
+ post.timestamp,
+ post.replies)
+ }));
+ NotifyPropertyChanged("MyFeed");
+
+ });
+ var lastrequest = new RestRequest("/messages?1=1" + "&rnd=" + Environment.TickCount);
+ App.Client.ExecuteAsync(lastrequest, response =>
+ {
+ var ser = new DataContractJsonSerializer(typeof(List));
+ using (var ms = new MemoryStream(response.RawBytes))
+ {
+ var messages =
+ (List)ser.ReadObject(ms);
+ if (messages == null) return;
+ Last.Clear();
+ messages.ForEach(post => Last.Add(new MessageViewModel(post)
+ {
+ Status = string.Format(
+ "Posted on: {0}, replies: {1}",
+ post.timestamp, post.replies
+ )
+ }));
+ NotifyPropertyChanged("Last");
+ }
+ });
+ }
+
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void NotifyPropertyChanged(String propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (null != handler)
+ {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/ViewModels/MessageViewModel.cs b/Juick/ViewModels/MessageViewModel.cs
new file mode 100644
index 0000000..32da0aa
--- /dev/null
+++ b/Juick/ViewModels/MessageViewModel.cs
@@ -0,0 +1,159 @@
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+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 Juick.Api;
+
+namespace Juick
+{
+ 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);
+ }
+ private int _mid;
+ ///
+ /// Sample ViewModel 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 ViewModel 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 ViewModel 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 Image _avatar;
+ public Image UserAvatar
+ {
+ get { return _avatar; }
+ set
+ {
+ if (value != _avatar)
+ {
+ _avatar = value;
+ NotifyPropertyChanged("Useravatar");
+ }
+ }
+ }
+
+ private string _messageText;
+ ///
+ /// Sample ViewModel 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 ViewModel 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;
+ private void NotifyPropertyChanged(String propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (null != handler)
+ {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Juick/ViewModels/ThreadViewModel.cs b/Juick/ViewModels/ThreadViewModel.cs
new file mode 100644
index 0000000..48ebe65
--- /dev/null
+++ b/Juick/ViewModels/ThreadViewModel.cs
@@ -0,0 +1,70 @@
+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 Juick.Api;
+using RestSharp;
+
+namespace Juick.ViewModels
+{
+ public class ThreadViewModel : INotifyPropertyChanged
+ {
+ public ThreadViewModel()
+ {
+ this.Items = new ObservableCollection();
+ }
+
+ ///
+ /// A collection for MessageViewModel objects.
+ ///
+ public ObservableCollection Items { get; private set; }
+
+ public bool IsDataLoaded
+ {
+ get;
+ private set;
+ }
+
+ public MessageViewModel Root { get; set; }
+
+ ///
+ /// Creates and adds a few MessageViewModel objects into the MyFeed collection.
+ ///
+ 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(request, response =>
+ {
+ using (var responseStream = new MemoryStream(response.RawBytes))
+ {
+ var ser = new DataContractJsonSerializer(typeof (List));
+ var messages = (List) ser.ReadObject(responseStream);
+ Items.Clear();
+ messages.ForEach(post =>
+ {
+ this.Items.Add(
+ new MessageViewModel(post));
+ });
+ IsDataLoaded = true;
+ NotifyPropertyChanged("Items");
+ }
+ });
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void NotifyPropertyChanged(String propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (null != handler)
+ {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
--
cgit v1.2.3