/// <summary> /// Rerun the filtering operation on all loaded game trees. /// </summary> /// <returns>A task wrapping the refiltering of the loaded game trees.</returns> private async Task RefilterTrees() { ComboBox box = this.FileFilterComboBox; this.StatusSpinner.Active = true; uint refilterStatusContextID = this.MainStatusBar.GetContextId("refreshFilter"); uint refilterStatusMessageID = this.MainStatusBar.Push ( refilterStatusContextID, "Refiltering node trees..." ); // Disable the pages foreach (var page in this.GamePages) { page.SetTreeSensitivity(false); } FilterType filterType = (FilterType)box.Active; foreach (var page in this.GamePages) { page.ShouldDisplayUnknownFiles = this.Config.ShowUnknownFilesWhenFiltering; if (filterType == FilterType.All) { page.SetFilterState(false); await page.RefilterAsync(); } else { page.SetFilterState(true); page.SetFilter(filterType.GetFileTypeSet()); await page.RefilterAsync(); } } // Reenable the pages foreach (var page in this.GamePages) { page.SetTreeSensitivity(true); } this.StatusSpinner.Active = false; this.MainStatusBar.Remove(refilterStatusContextID, refilterStatusMessageID); }
/// <summary> /// Handles updating the filter state for the game pages when the user changes it in the UI. /// </summary> /// <param name="sender">The sending object.</param> /// <param name="e">The event arguments.</param> private async void OnFilterChanged(object sender, EventArgs e) { ComboBox box = sender as ComboBox; if (box == null) { return; } this.StatusSpinner.Active = true; uint refilterStatusContextID = this.MainStatusBar.GetContextId("refreshFilter"); uint refilterStatusMessageID = this.MainStatusBar.Push ( refilterStatusContextID, "Refiltering node trees..." ); FilterType filterType = (FilterType)box.Active; foreach (GamePage page in this.GamePages) { if (filterType == FilterType.All) { page.SetFilterState(false); page.SetTreeSensitivity(false); await page.RefilterAsync(); page.SetTreeSensitivity(true); } else { page.SetFilterState(true); page.SetFilter(filterType.GetFileTypeSet()); page.SetTreeSensitivity(false); await page.RefilterAsync(); page.SetTreeSensitivity(true); } } this.StatusSpinner.Active = false; this.MainStatusBar.Remove(refilterStatusContextID, refilterStatusMessageID); }