/// <summary> /// Get the selected simple and Genre tags and determine if there has been any changes /// </summary> private void OnOk(MultiSpinner genreSpinner, Spinner tagSpinner) { // Get the selected record from the Genre spinner. If not all of the items are selected then add an entry for each selected item to a new TagGroup List <TagGroup> selectedGroups = new List <TagGroup>(); if (genreSpinner.SelectionRecord.All(genre => genre) == false) { TagGroup group = new TagGroup() { Name = FilterManagementModel.GenreTags.Name }; selectedGroups.Add(group); // Merge the Spinner's selection record and the Genre tags into a single list and then add to the new group any tags that are selected IEnumerable <Tuple <bool, Tag> > merged = genreSpinner.SelectionRecord.Zip(FilterManagementModel.GenreTags.Tags, (x, y) => Tuple.Create(x, y)); group.Tags.AddRange(merged.Where(t => (t.Item1 == true)).Select(t => t.Item2)); } // Get the simple tag Tag newTag = (tagSpinner.SelectedItemPosition == 0) ? null : Tags.GetTagByName(tagSpinner.SelectedItem.ToString()); // Check for simple or group tag changes if ((newTag != CurrentlySelectedFilter) || (selectedGroups.Count != CurrentlySelectedTagGroups.Count) || (selectedGroups.Any(group => GroupChanged(group)) == true)) { // Update the FilterManagementModel TagGroups with the possibly updated data from the Adapter CurrentlySelectedTagGroups.Clear(); CurrentlySelectedTagGroups.AddRange(selectedGroups); SelectionDelegate?.Invoke(newTag); } }