public void RemoveSearch(int tagId, int pageIndex) { int index = -1; if (TagsModel.AllTags.Any(x => x.Id == tagId)) { TagInfo tagInfo = TagsModel.AllTags.First(x => x.Id == tagId); string queryString1 = string.Format(CultureInfo.InvariantCulture, "tagged:{0}:{1}:{2}", tagInfo.Type.ToString().ToLowerInvariant(), tagInfo.Name, pageIndex); index = Searches.IndexOf(queryString1); } if (index == -1) { string queryString2 = string.Format(CultureInfo.InvariantCulture, "tagged:{0}:{1}", tagId, pageIndex); index = Searches.IndexOf(queryString2); } if (index == -1) { return; } Searches.RemoveAt(index); SearchesChanged.Invoke(this, EventArgs.Empty); }
/// <summary> /// Inserts a new empty searcher after the specified search. /// </summary> /// <param name="search">Search after which a new search should be added.</param> private void InsertEmptySearchAfter(Search search) { var newSearch = CreateAndBindEmptySearch(); int indexOfSearch = Searches.IndexOf(search) + 1; Searches.Insert(indexOfSearch, newSearch); }
public void RemoveSearch(string queryString) { int index = Searches.IndexOf(queryString); if (index == -1) { return; } Searches.RemoveAt(index); SearchesChanged.Invoke(this, EventArgs.Empty); }
protected virtual void OnSearchItemAdded(int galleryId) { int itemIndex = Searches.IndexOf(galleryId); if (itemIndex != -1) { Searches.RemoveAt(itemIndex); } Searches.Insert(0, galleryId); SearchesChanged.Invoke(this, EventArgs.Empty); }
public void RemoveSearch(string query, int pageIndex) { string queryString = string.Format(CultureInfo.InvariantCulture, "search:{0}:{1}", query, pageIndex); int index = Searches.IndexOf(queryString); if (index == -1) { return; } Searches.RemoveAt(index); SearchesChanged.Invoke(this, EventArgs.Empty); }
protected virtual void OnSearchItemAdded(int pageIndex) { string queryString = string.Format(CultureInfo.InvariantCulture, "recent:{0}", pageIndex); int itemIndex = Searches.IndexOf(queryString); if (itemIndex != -1) { Searches.RemoveAt(itemIndex); } Searches.Insert(0, queryString); //Searches.Add(queryString); SearchesChanged.Invoke(this, EventArgs.Empty); }
protected virtual void OnSearchItemAdded(int tagId, int pageIndex) { string queryString1 = null; // match alternate syntaxes and remove them as necessary. // (e.g., "tag:" instead of "tagged:", "tag:name" instead of "tag:type:name", "tag:name:1" instead of "tag:name", etc.) if (TagsModel.AllTags.Any(x => x.Id == tagId)) { TagInfo tagInfo = TagsModel.AllTags.First(x => x.Id == tagId); queryString1 = string.Format(CultureInfo.InvariantCulture, "tagged:{0}:{1}:{2}", tagInfo.Type.ToString().ToLowerInvariant(), QueryParser.SanitizeTagName(tagInfo.Name), pageIndex); int itemIndex1 = Searches.IndexOf(queryString1); if (itemIndex1 != -1) { Searches.RemoveAt(itemIndex1); } } string queryString2 = string.Format(CultureInfo.InvariantCulture, "tagged:{0}:{1}", tagId, pageIndex); int itemIndex2 = Searches.IndexOf(queryString2); if (itemIndex2 != -1) { Searches.RemoveAt(itemIndex2); } // prefer keeping the named syntax if (!string.IsNullOrEmpty(queryString1)) { Searches.Insert(0, queryString1); //Searches.Add(queryString1); } else { Searches.Insert(0, queryString2); //Searches.Add(queryString2); } SearchesChanged.Invoke(this, EventArgs.Empty); }