using System; using System.Collections.Generic; using System.Windows; using System.Windows.Data; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using Juick.ViewModels; using RestSharp; namespace Juick { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { // Holds the push channel that is created or found. InitializeComponent(); DataContext = App.AppContext; Loaded += (o, args) => { var progressIndicator = SystemTray.ProgressIndicator; if (progressIndicator != null) { return; } progressIndicator = new ProgressIndicator(); SystemTray.SetProgressIndicator(this, progressIndicator); Binding binding = new Binding("IsDataLoading") { Source = DataContext }; BindingOperations.SetBinding( progressIndicator, ProgressIndicator.IsVisibleProperty, binding); binding = new Binding("IsDataLoading") { Source = DataContext }; BindingOperations.SetBinding( progressIndicator, ProgressIndicator.IsIndeterminateProperty, binding); if (App.AppContext.Account.IsAuthenticated) { App.AppContext.Pages[0].RefreshData(); } }; } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { App.AppContext.Client.Authenticator = new HttpBasicAuthenticator(App.AppContext.Account.UserName, App.AppContext.Account.Password); } private void ApplicationBarIconButtonClick(object sender, EventArgs e) { App.AppContext.Pages[Pages.SelectedIndex].Items.Clear(); App.AppContext.Pages[Pages.SelectedIndex].RefreshData(); } private void ApplicationBarMenuItemClick(object sender, EventArgs e) { App.AppContext.Account.SignOut(this); } private void ApplicationBarIconButtonClick1(object sender, EventArgs e) { NavigationService.Navigate(new Uri("/NewPostView.xaml", UriKind.Relative)); } } }