Skip to content

Commit

Permalink
Modified to allow filtering by multiple criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
yt3trees committed Nov 12, 2023
1 parent 6061791 commit e07c366
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions msbuild-gui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,29 @@ private void MenuItem_Click_1(object sender, RoutedEventArgs e)
private void SearchTextbox_TextChanged(object sender, TextChangedEventArgs e)
{
SourceList.Items.Clear();
foreach (string item in List.sourceList)

if (string.IsNullOrWhiteSpace(SearchTextbox.Text))
{
//大文字小文字を区別せず検索
if (item.IndexOf(SearchTextbox.Text, StringComparison.OrdinalIgnoreCase) >= 0)
// テキストボックスが空の場合、全てのアイテムを再表示
foreach (string item in List.sourceList)
{
SourceList.Items.Add(item);
}
}
else
{
// 検索ボックスからテキストを取得し、改行コードで分割する
var searchTerms = SearchTextbox.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

foreach (string item in List.sourceList)
{
// 任意の検索語がアイテムに含まれているか確認
if (searchTerms.Any(term => item.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0))
{
SourceList.Items.Add(item);
}
}
}
}

private void TargetList_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
Expand Down

0 comments on commit e07c366

Please sign in to comment.