implement characterlist-search-function
This commit is contained in:
@@ -143,6 +143,41 @@ public partial class CharacterListControl : UserControl
|
||||
mainApi.OpenTab(new TabCharView(mainApi, character), string.IsNullOrWhiteSpace(character.Name) ? CharListControlLangRes.UnnamedChar : character.Name);
|
||||
}
|
||||
|
||||
private void SearchInList()
|
||||
{
|
||||
var filterText = radTextBoxControl_SearchBox.Text.Trim();
|
||||
|
||||
radListView_CharList.BeginUpdate();
|
||||
|
||||
foreach (ListViewDataItem item in radListView_CharList.Items)
|
||||
{
|
||||
if (item.Value is Character character)
|
||||
{
|
||||
var isValidResult = false;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filterText))
|
||||
{
|
||||
var allValues = new string[]
|
||||
{
|
||||
character.Name!,
|
||||
character.Fandom ?? "",
|
||||
character.Owner!.Name!,
|
||||
};
|
||||
|
||||
foreach (var value in allValues)
|
||||
{
|
||||
if (!isValidResult && value.Contains(filterText))
|
||||
isValidResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
item.Visible = isValidResult;
|
||||
}
|
||||
}
|
||||
|
||||
radListView_CharList.EndUpdate();
|
||||
}
|
||||
|
||||
// E V E N T S
|
||||
|
||||
private void RadMenuItem_AddChar_Click(object sender, System.EventArgs e)
|
||||
@@ -162,6 +197,6 @@ public partial class CharacterListControl : UserControl
|
||||
|
||||
private void RadTextBoxControl_SearchBox_TextChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
SearchInList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user