/// <summary> /// Modifies the list of packs when the user selects Paid, Free, or All Packs. /// </summary> /// <param name="sender">Tab selecting the packs to display.</param> /// <param name="e"><see cref="RoutedEventArgs"/> from the event</param> private void PaidOrFreeFilterSelected(object sender, RoutedEventArgs e) { // Reset Search and then Change the Population of the List SearchString = string.Empty; SearchTextBox.Text = string.Empty; switch ((sender as TabItem).Name) { case "AllPacks": PopulateCommunityManagementPackListFromGitHub(communityManagementPackIndex.ManagementPacks.Values.ToArray()); break; case "FreePacks": PopulateCommunityManagementPackListFromGitHub(communityManagementPackIndex.ManagementPacks.Values.Where(pack => pack.IsFree).ToArray()); break; case "PaidPacks": PopulateCommunityManagementPackListFromGitHub(communityManagementPackIndex.ManagementPacks.Values.Where(pack => !pack.IsFree).ToArray()); break; } // Update our search and display after the catalog change ManagementPackSearchChanged?.Invoke(this, SearchString); VerifyIfAllPacksAreCollapsed(); }
/// <summary> /// Triggered by the change of the text in the search box, this starts the process of updating the management packs in the list. /// </summary> /// <param name="sender">The sending TextBox</param> /// <param name="e"><see cref="TextChangedEventArgs"/> from the event</param> private void SearchText_TextChanged(object sender, TextChangedEventArgs e) { // Text Box is Selected, Update the SearchString SearchString = SearchTextBox.Text; ManagementPackSearchChanged?.Invoke(this, SearchString); VerifyIfAllPacksAreCollapsed(); }
/// <summary> /// One of the <see cref="CommunityPackRowTemplate"/> instances has raised an event /// indicating the search should be filtered to an Author. /// </summary> /// <param name="sender">The Sending Object</param> /// <param name="selectedAuthor">Author to filter to</param> private void FilterAuthorSelected(object sender, string selectedAuthor) { // When an author is selected the search is cleared and set to only the author. SearchString = selectedAuthor; SearchTextBox.Text = selectedAuthor; ManagementPackSearchChanged?.Invoke(sender, selectedAuthor); VerifyIfAllPacksAreCollapsed(); }
/// <summary> /// Clear the search box and start fresh /// </summary> /// <param name="sender">The Object requesting the SearchString be reset.</param> /// <param name="e"><see cref="RoutedEventArgs"/> from the event</param> private void ResetSearchState_Click(object sender, RoutedEventArgs e) { SearchString = string.Empty; SearchTextBox.Text = string.Empty; // After reseting the string, notify any attached handlers ManagementPackSearchChanged?.Invoke(this, SearchString); VerifyIfAllPacksAreCollapsed(); }
/// <summary> /// One of the <see cref="CommunityPackRowTemplate"/> instances has raised an event /// indicating removal of a Search Tag. /// </summary> /// <param name="sender">The sending Object</param> /// <param name="removedTag">Tag to remove from search</param> private void FilterTagRemovedByUser(object sender, string removedTag) { // Remove the requested tag from the search string SearchString = SearchString.Replace(removedTag, string.Empty); // Remove any double commas left from the Tag removal SearchString = SearchString.Replace(",,", ","); // Clean up leading or trailing commas SearchString = SearchString.Trim(','); ManagementPackSearchChanged?.Invoke(this, SearchString); VerifyIfAllPacksAreCollapsed(); }
/// <summary> /// Called when a user selects a tag on one of the <see cref="CommunityPackRowTemplate"/> /// </summary> /// <param name="sender">The clicked <see cref="CommunityPackRowTemplate"/></param> /// <param name="tagSelected">Value of the tag clicked.</param> private void FilterTagSelectedByUser(object sender, string tagSelected) { // Clear the search text SearchTextBox.Text = string.Empty; if (string.IsNullOrWhiteSpace(SearchString)) { SearchString += tagSelected; } else { SearchString += "," + tagSelected; } // Remove any double commas left from the Tag manipulations SearchString = SearchString.Replace(",,", ","); ManagementPackSearchChanged?.Invoke(this, SearchString); VerifyIfAllPacksAreCollapsed(); }