public void Execute(object parameter)
        {
            // Try to delete the file, both from the file system, and the active memory.
            try
            {
                NotesRepo.DeleteNoteFile(notesViewModel.SelectedNote.Title + ".txt");

                notesViewModel.AllNotes.Remove(notesViewModel.SelectedNote);
                notesViewModel.FilterNotes();
                notesViewModel.SelectedNote = null;
            }
            catch (Exception)
            {
                Debug.Fail("Error deleting note file from file system.");
            }
        }
예제 #2
0
        public async void Execute(object parameter)
        {
            SaveDialog          saveDialog = new SaveDialog();
            ContentDialogResult result     = await saveDialog.ShowAsync();

            // Creates an error message and returns.
            if (result != ContentDialogResult.Primary)
            {
                new ContentDialog()
                {
                    Title = "Cancelled Creation.", PrimaryButtonText = "Okay."
                };
                return;
            }

            TextBox box = (TextBox)parameter;

            Models.NoteModel newNote = new Models.NoteModel(saveDialog.NoteTitle, box.Text);

            // Trys to save the new note to the file system.
            try
            {
                Repository.NotesRepo.SaveNotesToFile(newNote);
            }
            catch (Exception)
            {
                Debug.WriteLine("Error saving new note to folder.");
                return;
            }

            // Adds note to the list, changes the selected node, and refreshes the list visually.
            notesViewModel.AllNotes.Add(newNote);
            notesViewModel.SelectedNote = newNote;
            notesViewModel.FilterNotes();

            new ContentDialog()
            {
                Title = "Saved Note Sucessfully.", PrimaryButtonText = "Okay."
            };
        }