Skip to content

Commit

Permalink
Allow wrapping search term in double-quotes to get exact matches.
Browse files Browse the repository at this point in the history
This'll be used for the ID search. We're also putting the search box text into a variable now, too.
  • Loading branch information
DrewNaylor committed Oct 3, 2020
1 parent cdf4c58 commit 61bb843
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions guinget/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<metadata name="contextmenustripPackageMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>357, 17</value>
</metadata>
<data name="textboxPackageDetails.Text" xml:space="preserve">
<value>No package is selected or the package list hasn't been loaded yet. You can load the package list by using the Refresh cache toolbar button, by going to Package list&gt;Refresh cache, or by pressing Ctrl+R.</value>
</data>
<metadata name="PkgAction.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand All @@ -147,6 +144,9 @@
<metadata name="Manifest.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="textboxPackageDetails.Text" xml:space="preserve">
<value>No package is selected or the package list hasn't been loaded yet. You can load the package list by using the Refresh cache toolbar button, by going to Package list&gt;Refresh cache, or by pressing Ctrl+R.</value>
</data>
<metadata name="toolstripMainWindow.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
Expand Down
24 changes: 18 additions & 6 deletions guinget/MainWindow.vb
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,26 @@ Public Class aaformMainWindow
' Update main window.
aaformMainWindow.Update()

Dim SearchTerm As String = aaformMainWindow.toolstriptextboxSearch.Text

For Each searchRow As DataGridViewRow In aaformMainWindow.datagridviewPackageList.Rows
' Look in each row in the datagridview, and see what text it has.
If searchRow.Cells.Item(2).Value.ToString.ToLowerInvariant.Contains(aaformMainWindow.toolstriptextboxSearch.Text.ToLowerInvariant) Then
' If the Package ID cell contains what's in the search box, show it.
searchRow.Visible = True
Else
' Otherwise, hide it.
searchRow.Visible = False
' If it starts and ends with double-quotes, remove them and do an exact match.
If SearchTerm.ToLowerInvariant.StartsWith("""") AndAlso SearchTerm.ToLowerInvariant.EndsWith("""") Then
' Set all rows visible to what's in the search box without the start and end.
If searchRow.Cells.Item(2).Value.ToString.ToLowerInvariant = SearchTerm.ToLowerInvariant.Trim(CChar("""")) Then
' Set only exactly-matching rows to show.
searchRow.Visible = True
Else
' Otherwise, hide it.
searchRow.Visible = False
End If
ElseIf searchRow.Cells.Item(2).Value.ToString.ToLowerInvariant.Contains(SearchTerm.ToLowerInvariant) Then
' If the Package ID cell contains what's in the search box, show it.
searchRow.Visible = True
Else
' Otherwise, hide it.
searchRow.Visible = False
End If
' Make the progress bar progress.
aaformMainWindow.toolstripprogressbarLoadingPackages.PerformStep()
Expand Down

0 comments on commit 61bb843

Please sign in to comment.