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 @@ + + + + + + + + + + + + + + + + + + + + +