Skip to content
Permalink
Browse files

[I] Add searching funcationality to Multiple Files Utility

  • Loading branch information...
Baine committed May 13, 2019
1 parent 12413a5 commit f270852d18191797542aab8e0f336e549aa05f28
Showing with 24 additions and 0 deletions.
  1. +24 −0 Shoko.Desktop/UserControls/MultipleFilesControl.xaml.cs
@@ -327,12 +327,16 @@ public MultipleFilesControl()
PreferredVideoCodecs.CollectionChanged += SaveSettings;
PreferredAudioCodecs.CollectionChanged += SaveSettings;

txtFileSearch.TextChanged += new TextChangedEventHandler(txtFileSearch_TextChanged);
btnClearSearch.Click += new RoutedEventHandler(btnClearSearch_Click);

IsLoading = false;

CurrentEpisodes = new ObservableCollection<VM_AnimeEpisode_User>();
ViewEpisodes = CollectionViewSource.GetDefaultView(CurrentEpisodes);
ViewEpisodes.SortDescriptions.Add(new SortDescription("AnimeName", ListSortDirection.Ascending));
ViewEpisodes.SortDescriptions.Add(new SortDescription("EpisodeTypeAndNumberAbsolute", ListSortDirection.Ascending));
ViewEpisodes.Filter = EpisodeSearchFilter;

workerFiles.DoWork += new DoWorkEventHandler(workerFiles_DoWork);
workerFiles.RunWorkerCompleted += new RunWorkerCompletedEventHandler(workerFiles_RunWorkerCompleted);
@@ -344,6 +348,26 @@ public MultipleFilesControl()
chkOnlyFinished.Checked += new RoutedEventHandler(chkOnlyFinished_Checked);
}

private void btnClearSearch_Click(object sender, RoutedEventArgs e)
{
txtFileSearch.Clear();
}

private bool EpisodeSearchFilter(object obj)
{
return (obj == null ||
(obj as VM_AnimeEpisode_User).EpisodeName.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase) > -1 ||
(obj as VM_AnimeEpisode_User).EpisodeNameEnglish.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase) > -1 ||
((obj as VM_AnimeEpisode_User).EpisodeNameRomaji != null && (obj as VM_AnimeEpisode_User).EpisodeNameRomaji.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase) > -1) ||
(obj as VM_AnimeEpisode_User).AnimeName.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase) > -1
? true : false);
}

private void txtFileSearch_TextChanged(object sender, TextChangedEventArgs e)
{
ViewEpisodes.Refresh();
}

private void SaveSettings(object sender, RoutedEventArgs e)
{
SaveSettings();

0 comments on commit f270852

Please sign in to comment.
You can’t perform that action at this time.