blob: 4468f6ad99d166fb84da3ee9c4fe697861d37947 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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));
}
}
}
|