Skip to content

Commit

Permalink
apply search filter after reloading configuration (fixes #134)
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersign committed Jul 6, 2018
1 parent a4946da commit 53f8747
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 16 additions & 8 deletions BenchManager/BenchDashboard/AppList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,20 @@ private void InitializeAppList()
AsyncManager.StartTask(() =>
{
appLookup.Clear();
var list = new List<AppWrapper>();
var cnt = 0;
foreach (var app in core.Config.Apps)
{
cnt++;
app.LoadCachedValues();
var wrapper = new AppWrapper(app, cnt);
list.Add(wrapper);
appLookup[app.ID] = wrapper;
}
var bindingList = new SortedBindingList<AppWrapper>(list);
BeginInvoke((ThreadStart)(() =>
{
var selectedRow = gridApps.SelectedRows.Count > 0 ? gridApps.SelectedRows[0].Index : -10;
gridApps.SuspendLayout();
gridApps.DataSource = bindingList;
UpdateAppGridView();
if (sortedColumn != null)
{
gridApps.Sort(sortedColumn, sortDirection);
Expand Down Expand Up @@ -387,10 +383,12 @@ private void gridApps_CellDoubleClick(object sender, DataGridViewCellEventArgs e

#region Search

private void txtSearch_TextChanged(object sender, EventArgs e)
public bool HasSearchFilter => !string.IsNullOrWhiteSpace(txtSearch.Text);

private void UpdateAppGridView()
{
var apps = appLookup.Values;
if (!string.IsNullOrWhiteSpace(txtSearch.Text))
if (HasSearchFilter)
{
var searchWords = AppSearch.TokenizeSearchString(txtSearch.Text).Select(AppSearch.NormalizeForSearch).ToArray();
var sortedList = new SortedBindingList<AppWrapper>(apps
Expand All @@ -405,11 +403,21 @@ private void txtSearch_TextChanged(object sender, EventArgs e)
}
}

private void btnClearSearch_Click(object sender, EventArgs e)
public void ResetSearchFilter()
{
txtSearch.Text = string.Empty;
}

private void txtSearch_TextChanged(object sender, EventArgs e)
{
UpdateAppGridView();
}

private void btnClearSearch_Click(object sender, EventArgs e)
{
ResetSearchFilter();
}

#endregion
}

Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ Add a link to the GitHub diff like
[Unreleased]: https://github.com/mastersign/bench/compare/master...dev

### Added

* Menu item _View_ &rarr; _Last Logfile_

### Fixed
* Apply search filter after reloading the Bench configuration
([#134](https://github.com/mastersign/bench/issues/134))

## [0.20.2] - 2018-06-21

[0.20.2]: https://github.com/mastersign/bench/compare/v0.20.1...v0.20.2
Expand Down

0 comments on commit 53f8747

Please sign in to comment.