private void NewTagBtn_Click(object sender, RoutedEventArgs e) { var newTag = Interaction.InputBox( "Enter the name of a new tag:", "New Tag", "<new tag>" ); if (!string.IsNullOrWhiteSpace(newTag) && newTag != "<new tag>") { var ft = new EditTagItem { IsChecked = false, Status = EditingStatus.Available, Title = newTag }; this.Dispatcher.Invoke(() => { this.AllTags.Add(ft); this.AllFilterTags.Add(ft.Title); this.AllTags.Available.Refresh(); this.AllTags.Applied.Refresh(); }); } }
public EditTags(AppIconSetting chosenApp, HashSet <FilterTag> allTags) { this.AllTags = new HashSet <EditTagItem>(allTags.Count); this.Available = new HashSet <EditTagItem>(this.AllTags.Count); this.Applied = new HashSet <EditTagItem>(this.AllTags.Count); this.AppliedView = CollectionViewSource.GetDefaultView(this.AllTags); this.AppliedView.SortDescriptions.Add <EditTagItem, string>(ListSortDirection.Ascending, x => x.Title); this.AppliedView.Filter = x => x is EditTagItem eti && eti.Status == EditingStatus.Applied; this.AvailableView = CollectionViewSource.GetDefaultView(this.AllTags); this.AvailableView.SortDescriptions.Add <EditTagItem, string>(ListSortDirection.Ascending, x => x.Title); this.AvailableView.Filter = x => x is EditTagItem eti && eti.Status == EditingStatus.Available; foreach (EditTagItem ft in allTags) { this.AllTags.Add(ft); } for (int i = 0; i < this.AllTags.Count; i++) { EditTagItem eti = this.AllTags.ElementAt(i); if (chosenApp.Tags.Any(x => x.Tag.Equals(eti.Title))) { eti.Status = EditingStatus.Applied; } } }