public TodoViewModel(Todo todo) { MessengerInstance.Register <TagAddedMessage>(this, OnTagAdded); MessengerInstance.Register <TagRemovedMessage>(this, OnTagRemoved); TodoRepo = new TodoRepository(App.Session); Model = todo; _Done = Model.Done; if (Model?.Project?.Tags != null) { AllTags = new ObservableCollection <TodoTagViewModel>(Model.Project.Tags.Select(t => new TodoTagViewModel(t) { IsSelected = Model.Tags.Contains(t) })); } else { AllTags = new ObservableCollection <TodoTagViewModel>(); } foreach (var t in AllTags) { t.Selected += Tag_Selected; t.Deselected += Tag_Deselected; } Tags = new ObservableCollection <TodoTagViewModel>(AllTags.Where(t => t.IsSelected)); }
public IList <Note> GetNotesByTags(params string[] args) { var tags = AllTags.Where(m => args.Contains(m.Name)).Select(m => m.Guid).ToList(); var filter = new NoteFilter { TagGuids = tags }; var notes = Note.FindNotes(filter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX); return(notes.Notes.OrderBy(m => m.Title).ToList()); }
private void UpdateFiltered() { if (searchBox.Text.Any()) { var list = AllTags.Where(i => i.Contains(searchBox.Text, StringComparison.OrdinalIgnoreCase)).ToList(); var sorted = list.OrderByDescending(i => i.StartsWith(searchBox.Text, StringComparison.OrdinalIgnoreCase)).ToList(); PopulateFiltered(sorted); } else { PopulateFiltered(AllTags); } }
/// <summary> /// Get Unity tagPaths by logic and tags. /// </summary> /// <param name="tagLogic">The tag logic.</param> /// <param name="tags">The tags.</param> public IEnumerable <IEnumerable <string> > GetTagPathMatches(TagLogic tagLogic, params string[] tags) { IEnumerable <IEnumerable <string> > baseTagPaths = AllTagPaths; IEnumerable <string> splitTags = tags.SelectMany(t => t.Split('/')); IEnumerable <string> regexTagPatterns = splitTags.Where(p => Regex.Match(p, @"[*+?^\\{}\[\]$<>:]").Success); IEnumerable <string> regexTags = regexTagPatterns.SelectMany(p => AllTags.Where(t => Regex.Match(t, p).Success)); IEnumerable <string> findTags = splitTags.Except(regexTagPatterns).Concat(regexTags).Distinct(); IEnumerable <IEnumerable <string> > resultTagPaths = null; // Enumerable.Empty<IEnumerable<string>>(); foreach (IEnumerable <IEnumerable <string> > tagPaths in findTags.Select(t => AllTagPaths.Where(p => ExpandTagGroups(p).Contains(t)))) { resultTagPaths = GetTagPathMatches(tagLogic, tagPaths, resultTagPaths); } return(resultTagPaths ?? Enumerable.Empty <IEnumerable <string> >()); }