private void ReloadNoteList(NoteViewModel selected = null) { ReloadNoteMenuList message = new ReloadNoteMenuList(null); List <Note> notes = new List <Note>(); if (SelectedTag != null) { message = new ReloadNoteMenuList(SelectedTag); } else if (SelectedNotebook != null) { message = new ReloadNoteMenuList(SelectedNotebook.Notebook, selected?.Note); } else if (SelectedMenuItem is AutoFilterViewModel) { var menuItem = SelectedMenuItem as AutoFilterViewModel; message = new ReloadNoteMenuList(menuItem.MenuItemType); } if (!message.IsEmpty()) { MessengerInstance.Send(message); } }
private void DoReloadNoteList(ReloadNoteMenuList obj) { List <Note> notes = new List <Note>(); if (obj.Tag != null) { var tempNotes = Hub.Instance.Storage.GetAllNotes(); notes = tempNotes.Where(n => n.Tags.Contains(obj.Tag.Name)).Where(n => !n.InTrashCan).ToList(); } else if (obj.Notebook != null) { notes = Hub.Instance.Storage.GetNotes(obj.Notebook).Where(n => !n.InTrashCan).ToList(); } else if (obj.LibraryType != MenuItemType.Undefined) { if (obj.LibraryType == MenuItemType.Trashcan) { var tempNotes = Hub.Instance.Storage.GetAllNotes(); notes = tempNotes.Where(n => n.InTrashCan).ToList(); } else if (obj.LibraryType == MenuItemType.Favorites) { var tempNotes = Hub.Instance.Storage.GetAllNotes(); notes = tempNotes.Where(n => n.Favourite).Where(n => !n.InTrashCan).ToList(); } else if (obj.LibraryType == MenuItemType.All) { notes = Hub.Instance.Storage.GetAllNotes().Where(n => !n.InTrashCan).OrderBy(n => n.Name).ToList(); } else if (obj.LibraryType == MenuItemType.Recent) { notes = Hub.Instance.Storage.GetAllNotes().Where(n => !n.InTrashCan).OrderBy(n => n.Changed).Take(15).ToList(); } } var models = ViewModelLocator.Instance.GetNoteViewModels(notes); SelectedNote = null; UpdateDataSource(models); if (obj.SelectedNote != null) { var selected = ViewModelLocator.Instance.GetNoteViewModel(obj.SelectedNote); SelectedNote = selected; } else { SelectedNote = models.Any() ? models[0] : null; } }