public void NextNote() { if (CanGoForward) { CurrentNote = Notes[CurrentNoteIndex + 1]; } }
public void PreviousNote() { if (CanGoBack) { CurrentNote = Notes[CurrentNoteIndex - 1]; } }
public static ObservableCollection <BaseNoteViewModel> LoadNotesFromXml(string filename) { if (!File.Exists(filename)) { return(null); } ObservableCollection <BaseNoteViewModel> notes = new ObservableCollection <BaseNoteViewModel>(); var xml = XDocument.Load(filename); foreach (XElement element in xml.Element("Notes").Elements()) { if (NoteFactory.NoteTypesByName.TryGetValue(element.Name.LocalName, out NoteType noteType)) { BaseNoteViewModel note = noteType.NewInstance(); note.Name = element.Attribute("Name").Value; note.SetContentFromXml(element.Elements().First()); notes.Add(note); } } return(notes); }
public void AddNote(object parameter) { if (parameter is NoteType noteType) { BaseNoteViewModel newNote = noteType.NewInstance(); Notes.Add(newNote); CurrentNote = newNote; } }
public void OpenPath(string filePath, string fileName = null) { CurrentNote = null; FilePath = filePath; FileName = fileName ?? Path.GetFileName(filePath); Notes = XmlUtils.LoadNotesFromXml(FilePath); Notes.CollectionChanged += NotesOnCollectionChanged; JumpList.AddToRecentCategory(FilePath); }
public void InsertNote(object parameter) { if (!(parameter is NoteType noteType)) { return; } BaseNoteViewModel newNote = noteType.NewInstance(); if (IsItemSelected) { ViewModel.Notes.Insert(SelectedNoteIndex + 1, newNote); } else { ViewModel.Notes.Add(newNote); } ViewModel.CurrentNote = newNote; }
public void DeleteNoteAtIndex(int noteIndex) { if (noteIndex <= -1) { return; } if (StaticObjects.Settings.Dictionary["AskBeforeDelete"].Value) { var result = MessageBox.Show($"Are you sure you want to delete '{Notes[noteIndex].Name}'?", "VSN", MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) { return; } } if (CurrentNote == Notes[noteIndex]) { CurrentNote = noteIndex - 1 > -1 ? Notes[noteIndex - 1] : null; } Notes.RemoveAt(noteIndex); }
public void ChangeCurrentNote(BaseNoteViewModel note) => ViewModel.CurrentNote = note;