diff --git a/src/LessMsi.Gui/Extensions/ObjectArrayExtensions.cs b/src/LessMsi.Gui/Extensions/ObjectArrayExtensions.cs
new file mode 100644
index 0000000..607d7bd
--- /dev/null
+++ b/src/LessMsi.Gui/Extensions/ObjectArrayExtensions.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace LessMsi.Gui.Extensions
+{
+ public static class ObjectArrayExtensions
+ {
+ public static bool Contains(this object[] objects, string needle, StringComparison comparisonType)
+ {
+ foreach(object obj in objects)
+ {
+ if (obj.ToString().Contains(needle, comparisonType))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/LessMsi.Gui/Extensions/StringExtensions.cs b/src/LessMsi.Gui/Extensions/StringExtensions.cs
new file mode 100644
index 0000000..95add46
--- /dev/null
+++ b/src/LessMsi.Gui/Extensions/StringExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace LessMsi.Gui.Extensions
+{
+ public static class StringExtensions
+ {
+ public static bool Contains(this string src, string needle, StringComparison comparisonType)
+ {
+ return src.IndexOf(needle, comparisonType) >= 0;
+ }
+ }
+}
diff --git a/src/LessMsi.Gui/LessMsi.Gui.csproj b/src/LessMsi.Gui/LessMsi.Gui.csproj
index 25d2784..6b51101 100644
--- a/src/LessMsi.Gui/LessMsi.Gui.csproj
+++ b/src/LessMsi.Gui/LessMsi.Gui.csproj
@@ -65,6 +65,8 @@
AboutBox.cs
+
+
Form
diff --git a/src/LessMsi.Gui/MainForm.cs b/src/LessMsi.Gui/MainForm.cs
index 5ae5506..95c317a 100644
--- a/src/LessMsi.Gui/MainForm.cs
+++ b/src/LessMsi.Gui/MainForm.cs
@@ -426,8 +426,7 @@ private void InitializeComponent()
this.fileGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.fileGrid.Size = new System.Drawing.Size(446, 366);
this.fileGrid.TabIndex = 5;
- this.fileGrid.KeyDown += new System.Windows.Forms.KeyEventHandler(this.fileGrid_KeyDown);
- this.fileGrid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.fileGrid_KeyPress);
+ this.fileGrid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SearchableGrid_KeyPress);
//
// panel2
//
@@ -530,6 +529,7 @@ private void InitializeComponent()
this.msiTableGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.msiTableGrid.Size = new System.Drawing.Size(453, 370);
this.msiTableGrid.TabIndex = 10;
+ this.msiTableGrid.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SearchableGrid_KeyPress);
//
// tabSummary
//
@@ -787,7 +787,7 @@ private void InitializeComponent()
this.searchFileToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+F";
this.searchFileToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
this.searchFileToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
- this.searchFileToolStripMenuItem.Text = "Search File";
+ this.searchFileToolStripMenuItem.Text = "Search";
this.searchFileToolStripMenuItem.Click += new System.EventHandler(this.searchFileToolStripMenuItem_Click);
//
// aboutToolStripMenuItem
@@ -807,6 +807,7 @@ private void InitializeComponent()
this.Controls.Add(this.panel1);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.KeyPreview = true;
this.MainMenuStrip = this.menuStrip1;
this.MinimumSize = new System.Drawing.Size(352, 404);
this.Name = "MainForm";
@@ -814,6 +815,7 @@ private void InitializeComponent()
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
+ this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown);
this.tabs.ResumeLayout(false);
this.tabExtractFiles.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.fileGrid)).EndInit();
@@ -1034,22 +1036,20 @@ private void searchFileToolStripMenuItem_Click(object sender, EventArgs e)
if (IsFileTabSelected)
{
searchPanel.SearchDataGrid(this.fileGrid,
- (o, args) => Presenter.BeginSearching(args.SearchString),
- (o, args) => { Presenter.BeginSearching(""); }
+ Presenter.ExecuteFileSearch,
+ () => { Presenter.ExecuteFileSearch(this.fileGrid, string.Empty); }
);
}
- }
-
- private void fileGrid_KeyDown(object sender, KeyEventArgs e)
- {
- // If they press escape while navigating the grid and the search panel is open in the search panel, cancel the search:
- if (e.KeyCode == Keys.Escape)
+ else if (IsTableTabSelected)
{
- searchPanel.CancelSearch();
+ searchPanel.SearchDataGrid(this.msiTableGrid,
+ Presenter.ExecuteTableSearch,
+ () => { Presenter.ExecuteTableSearch(this.msiTableGrid, string.Empty); }
+ );
}
}
- private void fileGrid_KeyPress(object sender, KeyPressEventArgs e)
+ private void SearchableGrid_KeyPress(object sender, KeyPressEventArgs e)
{
if (Char.IsLetterOrDigit(e.KeyChar))
{
@@ -1093,5 +1093,21 @@ protected bool IsFileTabSelected
}
}
+ protected bool IsTableTabSelected
+ {
+ get
+ {
+ return tabs.SelectedTab == tabTableView;
+ }
+ }
+
+ private void MainForm_KeyDown(object sender, KeyEventArgs e)
+ {
+ // If they press escape while navigating the grid and the search panel is open in the search panel, cancel the search:
+ if (e.KeyCode == Keys.Escape)
+ {
+ searchPanel?.CancelSearch();
+ }
+ }
}
}
diff --git a/src/LessMsi.Gui/MainFormPresenter.cs b/src/LessMsi.Gui/MainFormPresenter.cs
index bb5e6e3..b55df1c 100644
--- a/src/LessMsi.Gui/MainFormPresenter.cs
+++ b/src/LessMsi.Gui/MainFormPresenter.cs
@@ -28,7 +28,9 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Windows.Forms;
using LessIO;
+using LessMsi.Gui.Extensions;
using LessMsi.Gui.Model;
using LessMsi.Gui.Windows.Forms;
using LessMsi.Msi;
@@ -45,6 +47,7 @@ class MainFormPresenter
{
private readonly MainForm _view;
private SortableBindingList fileDataSource;
+ private IList