summaryrefslogtreecommitdiff
path: root/Juick/MainPage.xaml.cs
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2012-02-11 22:22:50 +0400
committerGravatar Vitaly Takmazov2012-02-11 22:22:50 +0400
commit49eb44f852ab21e72c17bbc436ffa79525a1aba3 (patch)
tree249cd1d69dc8078104dc2bc35cfcbbce98cd85f4 /Juick/MainPage.xaml.cs
v 0.999 :)
Diffstat (limited to 'Juick/MainPage.xaml.cs')
-rw-r--r--Juick/MainPage.xaml.cs84
1 files changed, 84 insertions, 0 deletions
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