Example #1
0
        /// <summary>
        /// The async task for deleting all the notes in the application
        /// Also asks for validation from the user before deleting
        /// </summary>
        /// <returns>A task to delete all the notes</returns>
        private async Task DeleteAllNotes()
        {
            await DisplayPopupHelpers
            .ShowOKDialogAsync("Are you sure?",
                               "You are about to delete ALL your notes. This CANNOT be reversed!");

            string promptResult = await DisplayPopupHelpers
                                  .ShowPromptAsync("Are you sure?",
                                                   "Please enter 'DELETE ALL MY NOTES' into the box below to confirm");

            if (promptResult == null)
            {
                return;
            }

            if (promptResult != "DELETE ALL MY NOTES")
            {
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Incorrect",
                                   "Your notes have NOT been deleted");

                return;
            }

            await Task.Run(() => IOHelpers.DeleteAllNotes());

            await DisplayPopupHelpers
            .ShowOKDialogAsync("Deleted",
                               "All your notes have now been deleted");
        }
Example #2
0
        /// <summary>
        /// The save async method
        /// Saves/updates the note and closes the edit note page
        /// </summary>
        /// <returns>A task to save/update the note and close the edit note page</returns>
        private async Task SaveAsync()
        {
            if (Title.Contains(":"))
            {
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Invalid Title",
                                   "Title cannot include special character ':'");

                return;
            }

            string noteData = Title + ':' + Text;
            string color    = Color.ToHex();

            IOHelpers.SaveNoteData(CurrentNote.Filename, noteData, color);

            await NavigationHelpers.PopCurrentPageAsync();
        }
Example #3
0
        /// <summary>
        /// The delete async method
        /// Deletes the current note following validation and closes the note page
        /// </summary>
        /// <returns>A task to delete the current note following validation and close the note page</returns>
        private async Task DeleteAsync()
        {
            //Bypass the validation check if set by the AppSettings
            if (AppSettings.RequireDeleteCheck)
            {
                string promptResult = await DisplayPopupHelpers
                                      .ShowPromptAsync("Validation",
                                                       "To delete this note, enter it's title");

                if (promptResult == null)
                {
                    return;
                }

                if (promptResult != Title)
                {
                    await DisplayPopupHelpers
                    .ShowOKDialogAsync("Incorrect",
                                       "Your note has not been deleted");

                    return;
                }
            }

            if (IOHelpers.NoteExists(CurrentNote.Filename))
            {
                IOHelpers.DeleteNote(CurrentNote.Filename);
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Deleted",
                                   "Your note has been deleted");
            }
            else
            {
                await DisplayPopupHelpers
                .ShowOKDialogAsync("Error",
                                   "The file could not be found; your note has not been deleted");
            }

            await NavigationHelpers.PopCurrentPageAsync();
        }