mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-16 02:13:39 +12:00
[Feature] item starts with searchstring, sort it on top (#99), version 1.0.17.10
This commit is contained in:
parent
c00c02356a
commit
cdb5cb56f1
|
@ -134,7 +134,7 @@ namespace SystemTrayMenu
|
|||
1);
|
||||
|
||||
// 0 = Dark mode, 1 = Light mode
|
||||
if (registryValueAppsUseLightTheme != null &&
|
||||
if (registryValueAppsUseLightTheme != null &&
|
||||
registryValueAppsUseLightTheme.ToString() == "0")
|
||||
{
|
||||
isDarkModeActive = true;
|
||||
|
|
|
@ -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")]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue