[Feature] item starts with searchstring, sort it on top (#99), version 1.0.17.10

This commit is contained in:
Markus Hofknecht 2021-04-14 23:12:14 +02:00
parent c00c02356a
commit cdb5cb56f1
3 changed files with 33 additions and 10 deletions

View file

@ -134,7 +134,7 @@ namespace SystemTrayMenu
1);
// 0 = Dark mode, 1 = Light mode
if (registryValueAppsUseLightTheme != null &&
if (registryValueAppsUseLightTheme != null &&
registryValueAppsUseLightTheme.ToString() == "0")
{
isDarkModeActive = true;

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.17.9")]
[assembly: AssemblyFileVersion("1.0.17.9")]
[assembly: AssemblyVersion("1.0.17.10")]
[assembly: AssemblyFileVersion("1.0.17.10")]

View file

@ -580,13 +580,36 @@ namespace SystemTrayMenu.UserInterface
string filterField = dgv.Columns[1].Name;
SearchTextChanging?.Invoke();
data.DefaultView.RowFilter = string.Format(
CultureInfo.InvariantCulture,
"[{0}] LIKE '%{1}%'",
filterField,
textBoxSearch.Text);
string searchString = textBoxSearch.Text.Trim();
string like = string.Empty;
string[] splittedParts = searchString.Split(" ");
if (splittedParts.Length > 1)
{
foreach (string splittedPart in splittedParts)
{
string and = string.Empty;
if (!string.IsNullOrEmpty(like))
{
and = $" AND [{filterField}]";
}
if (string.IsNullOrEmpty(textBoxSearch.Text))
like += $"{and} LIKE '%{splittedPart}%'";
}
}
else
{
like = $"LIKE '%{searchString}%'";
}
try
{
data.DefaultView.RowFilter = $"[{filterField}] {like}";
}
catch (EvaluateException)
{
}
if (string.IsNullOrEmpty(searchString))
{
data.DefaultView.Sort = string.Empty;
}
@ -597,7 +620,7 @@ namespace SystemTrayMenu.UserInterface
foreach (DataRow row in data.Rows)
{
if (row[1].ToString().StartsWith(
textBoxSearch.Text,
searchString,
StringComparison.InvariantCultureIgnoreCase))
{
row[columnSortIndex] = 0;