/// <summary>Removes a tag from the tag filter and refreshes the results.</summary> public void RemoveTagFromFilter(string tagName) { MatchesArrayFilter <string> tagFilter = this.tagMatchFieldFilter; // early out if (tagFilter == null || tagFilter.filterArray == null || tagFilter.filterArray.Length == 0) { return; } // remove List <string> tagFilterValues = new List <string>(tagFilter.filterArray); if (tagFilterValues.Contains(tagName)) { tagFilterValues.Remove(tagName); if (tagFilterValues.Count == 0) { tagFilter = null; } else { tagFilter.filterArray = tagFilterValues.ToArray(); } // set this.SetFieldFilters(ModIO.API.GetAllModsFilterFields.tags, tagFilter); } }
// ---------[ UI FUNCTIONALITY ]--------- /// <summary>Displays the tags for a given RequestFilter.</summary> public void DisplayInArrayFilterTags(RequestFilter filter) { List <IRequestFieldFilter> tagsFilterList = null; if (filter != null) { filter.fieldFilterMap.TryGetValue(ModIO.API.GetAllModsFilterFields.tags, out tagsFilterList); } string[] tags = null; if (tagsFilterList != null) { MatchesArrayFilter <string> tagsFilter = null; for (int i = 0; i < tagsFilterList.Count && tagsFilter == null; ++i) { IRequestFieldFilter f = tagsFilterList[i]; if (f.filterMethod == FieldFilterMethod.EquivalentCollection) { tagsFilter = f as MatchesArrayFilter <string>; } } if (tagsFilter != null) { tags = tagsFilter.filterValue; } } this.container.DisplayTags(tags); }
/// <summary>Gets the tag filter.</summary> public string[] GetTagFilter() { MatchesArrayFilter <string> filter = this.tagMatchFieldFilter; if (filter == null) { return(null); } else { return(filter.filterArray); } }
/// <summary>Sets the tag filter and refreshes the results.</summary> public void SetTagFilter(IList <string> tagFilter) { MatchesArrayFilter <string> oldFilter = this.tagMatchFieldFilter; // null-checks if (tagFilter == null) { tagFilter = new string[0]; } string[] oldFilterValue = new string[0]; if (oldFilter != null) { oldFilterValue = oldFilter.filterArray; } // check if same and copy bool isSame = (oldFilterValue.Length == tagFilter.Count); string[] newFilterValue = new string[tagFilter.Count]; if (tagFilter != oldFilterValue) { for (int i = 0; i < newFilterValue.Length; ++i) { newFilterValue[i] = tagFilter[i]; isSame = isSame && (oldFilterValue[i] == newFilterValue[i]); } } // apply if (!isSame) { // set MatchesArrayFilter <string> fieldFilter = null; if (newFilterValue.Length > 0) { fieldFilter = new MatchesArrayFilter <string>() { filterArray = newFilterValue, }; } this.SetFieldFilters(ModIO.API.GetAllModsFilterFields.tags, fieldFilter); } }
/// <summary>Removes a tag from the tag filter and refreshes the results.</summary> public void RemoveTagFromFilter(string tagName) { MatchesArrayFilter <string> tagFilter = this.tagMatchFieldFilter; // early out if (tagFilter == null || tagFilter.filterArray == null || tagFilter.filterArray.Length == 0) { return; } // create list List <string> tagFilterValues = new List <string>(tagFilter.filterArray); if (tagFilterValues.Contains(tagName)) { tagFilterValues.Remove(tagName); if (tagFilterValues.Count == 0) { this.tagMatchFieldFilter = null; } else { tagFilter.filterArray = tagFilterValues.ToArray(); } // refresh if (this.isActiveAndEnabled) { this.Refresh(); } // notify if (this.onRequestFilterChanged != null) { this.onRequestFilterChanged.Invoke(this.m_requestFilter); } } }
/// <summary>Adds a tag to the tag filter and refreshes the results.</summary> public void AddTagToFilter(string tagName) { // get existing MatchesArrayFilter <string> tagFilter = this.tagMatchFieldFilter; if (tagFilter == null) { tagFilter = new MatchesArrayFilter <string>(); tagFilter.filterValue = new string[0]; } List <string> tagFilterValues = new List <string>(); tagFilterValues.AddRange(tagFilter.filterArray); // add if (!tagFilterValues.Contains(tagName)) { tagFilterValues.Add(tagName); tagFilter.filterArray = tagFilterValues.ToArray(); this.tagMatchFieldFilter = tagFilter; // refresh if (this.isActiveAndEnabled) { this.Refresh(); } // notify if (this.onRequestFilterChanged != null) { this.onRequestFilterChanged.Invoke(this.m_requestFilter); } } }
/// <summary>Adds a tag to the tag filter and refreshes the results.</summary> public void AddTagToFilter(string tagName) { // get existing MatchesArrayFilter <string> tagFilter = this.tagMatchFieldFilter; if (tagFilter == null) { tagFilter = new MatchesArrayFilter <string>(); tagFilter.filterValue = new string[0]; } // add List <string> tagFilterValues = new List <string>(tagFilter.filterArray); if (!tagFilterValues.Contains(tagName)) { tagFilterValues.Add(tagName); tagFilter.filterArray = tagFilterValues.ToArray(); // set this.SetFieldFilters(ModIO.API.GetAllModsFilterFields.tags, tagFilter); } }
/// <summary>Sets the tag filter and refreshes the results.</summary> public void SetTagFilter(IList <string> tagFilter) { MatchesArrayFilter <string> oldFilter = this.tagMatchFieldFilter; // null-checks if (tagFilter == null) { tagFilter = new string[0]; } string[] oldFilterValue = new string[0]; if (oldFilter != null) { oldFilterValue = oldFilter.filterArray; } // check if same and copy bool isSame = (oldFilterValue.Length == tagFilter.Count); string[] newFilterValue = new string[tagFilter.Count]; if (tagFilter != oldFilterValue) { for (int i = 0; i < newFilterValue.Length; ++i) { newFilterValue[i] = tagFilter[i]; isSame = isSame && (oldFilterValue[i] == newFilterValue[i]); } } // apply if (!isSame) { // set if (newFilterValue.Length == 0) { this.tagMatchFieldFilter = null; } else { MatchesArrayFilter <string> newFilter = new MatchesArrayFilter <string>() { filterArray = newFilterValue, }; this.tagMatchFieldFilter = newFilter; } // refresh if (this.isActiveAndEnabled) { this.Refresh(); } // notify if (this.onRequestFilterChanged != null) { this.onRequestFilterChanged.Invoke(this.m_requestFilter); } } }