Beispiel #1
0
        /// <summary>
        /// Will check for an existing draft and will restore if the users wants.
        /// </summary>
        private async void CheckForAndPromptForDraft()
        {
            // If we already have info on the screen don't replace it.
            if (HasInfoToDraft())
            {
                return;
            }

            // See if we have something to restore
            if (await DraftManager.HasPostSubmitDraft())
            {
                // Make a message to show the user
                var restoreDraft = true;
                var message      = new MessageDialog("It looks like you have draft of a submission, would you like to restore it?", "Draft Restore");
                message.Commands.Add(new UICommand(
                                         "Restore Draft",
                                         (IUICommand command) => { restoreDraft = true; }));
                message.Commands.Add(new UICommand(
                                         "Discard Draft",
                                         (IUICommand command) => { restoreDraft = false; }));
                message.DefaultCommandIndex = 0;
                message.CancelCommandIndex  = 1;

                // Show the dialog
                await message.ShowAsync();

                if (restoreDraft)
                {
                    // Get the data
                    var data = await App.BaconMan.DraftMan.GetPostSubmissionDraft();

                    if (data != null)
                    {
                        // Restore it
                        ui_postTitleTextBox.Text        = data.Title;
                        ui_postUrlTextBox.Text          = data.UrlOrText;
                        ui_isSelfPostCheckBox.IsChecked = data.IsSelfText;
                        ui_subredditSuggestBox.Text     = data.Subreddit;

                        // If we are self text open the box
                        if (ui_isSelfPostCheckBox.IsChecked.Value)
                        {
                            IsSelfPostCheckBox_Click(null, null);
                        }
                    }
                }
                else
                {
                    // Delete the data.
                    ClearDraft();
                }
            }
        }