コード例 #1
0
 public void NextNote()
 {
     if (CanGoForward)
     {
         CurrentNote = Notes[CurrentNoteIndex + 1];
     }
 }
コード例 #2
0
 public void PreviousNote()
 {
     if (CanGoBack)
     {
         CurrentNote = Notes[CurrentNoteIndex - 1];
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void AddNote(object parameter)
 {
     if (parameter is NoteType noteType)
     {
         BaseNoteViewModel newNote = noteType.NewInstance();
         Notes.Add(newNote);
         CurrentNote = newNote;
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: NoteListViewModel.cs プロジェクト: spitfirex86/VSN
        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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: NoteListViewModel.cs プロジェクト: spitfirex86/VSN
 public void ChangeCurrentNote(BaseNoteViewModel note) => ViewModel.CurrentNote = note;