private async void PerformLoginAsync(IUICommand command)
        {
            try
            {
                System.Uri StartUri = new Uri(PusherUtils.GetPushbulletLoginURL());
                System.Uri EndUri   = new Uri(PusherUtils.REDIRECT_URI);

                WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                    WebAuthenticationOptions.None, StartUri, EndUri);

                if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
                {
                    PusherUtils.StoreAccessToken(WebAuthenticationResult.ResponseData.ToString());
                }
                else if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
                {
                    System.Diagnostics.Debug.WriteLine("HTTP Error returned by AuthenticateAsync() : " +
                                                       WebAuthenticationResult.ResponseErrorDetail.ToString());
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Error returned by AuthenticateAsync() : " +
                                                       WebAuthenticationResult.ResponseStatus.ToString());
                }
            }
            catch (Exception Error)
            {
                System.Diagnostics.Debug.WriteLine(Error.ToString());
            }

            SetupAsync();
        }
        private void pageRoot_Loaded(object sender, RoutedEventArgs e)
        {
            if (!PusherUtils.IsUserLoggedIn())
            {
                CreateLoginDialogAsync();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("I'm in");
                SetupAsync();
            }

            PusherUtils.GetNotesListAsync();
        }
        private async void SendSimplePushButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox simplePushTextBox = FindChildControl <TextBox>(this, "SimplePushTextBox") as TextBox;
            string  message           = simplePushTextBox.Text;

            if (message.Length > 0)
            {
                PusherUtils.PushNoteAsync(message);
                simplePushTextBox.Text = "";
            }
            else
            {
                var messageDialog = new Windows.UI.Popups.MessageDialog("Hey, at least one character!");
                messageDialog.DefaultCommandIndex = 1;
                await messageDialog.ShowAsync();
            }
        }
        private async void SetupAsync()
        {
            TextBlock UserNameTextBlock = FindChildControl <TextBlock>(this, "UserNameTextBlock") as TextBlock;
            Image     UserProfileImage  = FindChildControl <Image>(this, "UserProfileImage") as Image;

            if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey(PusherUtils.USER_NAME_KEY))
            {
                UserNameTextBlock.Text = (string)
                                         Windows.Storage.ApplicationData.Current.LocalSettings.Values[PusherUtils.USER_NAME_KEY];
                UserProfileImage.Source = new BitmapImage(new Uri(
                                                              (string)Windows.Storage.ApplicationData.Current.LocalSettings.Values[PusherUtils.USER_PIC_URL_KEY]));
            }
            else
            {
                Dictionary <string, string> info = await PusherUtils.GetUserInfoAsync();

                UserNameTextBlock.Text  = info[PusherUtils.USER_NAME_KEY];
                UserProfileImage.Source = new BitmapImage(new Uri(info[PusherUtils.USER_PIC_URL_KEY]));
            }
        }