implemented search filtering feature

This commit is contained in:
David Sparer
2017-11-19 09:13:44 -06:00
parent 7c4ccde69b
commit 3fb72dfc24
10 changed files with 101 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ namespace mRemoteNG {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -2614,5 +2614,17 @@ namespace mRemoteNG {
this["SaveConnectionsAfterEveryEdit"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool UseFilterSearch {
get {
return ((bool)(this["UseFilterSearch"]));
}
set {
this["UseFilterSearch"] = value;
}
}
}
}

View File

@@ -650,5 +650,8 @@
<Setting Name="SaveConnectionsAfterEveryEdit" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="UseFilterSearch" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -19,7 +19,7 @@ namespace mRemoteNG {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Language {
@@ -141,6 +141,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to Filter search matches in connection tree.
/// </summary>
internal static string FilterSearchMatchesInConnectionTree {
get {
return ResourceManager.GetString("FilterSearchMatchesInConnectionTree", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Incorrect password.
/// </summary>

View File

@@ -2619,4 +2619,7 @@ This page will walk you through the process of upgrading your connections file o
<data name="SaveConnectionsAfterEveryEdit" xml:space="preserve">
<value>Save connections after every edit</value>
</data>
<data name="FilterSearchMatchesInConnectionTree" xml:space="preserve">
<value>Filter search matches in connection tree</value>
</data>
</root>

View File

@@ -0,0 +1,26 @@
using BrightIdeasSoftware;
using mRemoteNG.Connection;
namespace mRemoteNG.UI.Controls
{
public class ConnectionTreeSearchTextFilter : IModelFilter
{
public string FilterText { get; set; } = "";
public bool Filter(object modelObject)
{
var objectAsConnectionInfo = modelObject as ConnectionInfo;
if (objectAsConnectionInfo == null)
return false;
var filterTextLower = FilterText.ToLowerInvariant();
if (objectAsConnectionInfo.Name.ToLowerInvariant().Contains(filterTextLower) ||
objectAsConnectionInfo.Hostname.ToLowerInvariant().Contains(filterTextLower) ||
objectAsConnectionInfo.Description.ToLowerInvariant().Contains(filterTextLower))
return true;
return false;
}
}
}

View File

@@ -50,6 +50,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.pnlRdpConnectionTimeout = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.chkSaveConnectionsAfterEveryEdit = new mRemoteNG.UI.Controls.Base.NGCheckBox();
this.chkUseFilterSearch = new mRemoteNG.UI.Controls.Base.NGCheckBox();
((System.ComponentModel.ISupportInitialize)(this.numRDPConTimeout)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numRdpReconnectionCount)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numAutoSave)).BeginInit();
@@ -183,7 +184,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.pnlConfirmCloseConnection.Controls.Add(this.radCloseWarnMultiple);
this.pnlConfirmCloseConnection.Controls.Add(this.radCloseWarnExit);
this.pnlConfirmCloseConnection.Controls.Add(this.radCloseWarnNever);
this.pnlConfirmCloseConnection.Location = new System.Drawing.Point(2, 191);
this.pnlConfirmCloseConnection.Location = new System.Drawing.Point(3, 214);
this.pnlConfirmCloseConnection.Name = "pnlConfirmCloseConnection";
this.pnlConfirmCloseConnection.Size = new System.Drawing.Size(595, 137);
this.pnlConfirmCloseConnection.TabIndex = 6;
@@ -248,7 +249,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.pnlRdpReconnectionCount.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F));
this.pnlRdpReconnectionCount.Controls.Add(this.lblRdpReconnectionCount, 0, 0);
this.pnlRdpReconnectionCount.Controls.Add(this.numRdpReconnectionCount, 1, 0);
this.pnlRdpReconnectionCount.Location = new System.Drawing.Point(3, 95);
this.pnlRdpReconnectionCount.Location = new System.Drawing.Point(4, 118);
this.pnlRdpReconnectionCount.Name = "pnlRdpReconnectionCount";
this.pnlRdpReconnectionCount.RowCount = 1;
this.pnlRdpReconnectionCount.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
@@ -263,7 +264,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.pnlRdpConnectionTimeout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F));
this.pnlRdpConnectionTimeout.Controls.Add(this.numRDPConTimeout, 1, 0);
this.pnlRdpConnectionTimeout.Controls.Add(this.lblRDPConTimeout, 0, 0);
this.pnlRdpConnectionTimeout.Location = new System.Drawing.Point(3, 127);
this.pnlRdpConnectionTimeout.Location = new System.Drawing.Point(4, 150);
this.pnlRdpConnectionTimeout.Name = "pnlRdpConnectionTimeout";
this.pnlRdpConnectionTimeout.RowCount = 1;
this.pnlRdpConnectionTimeout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
@@ -278,11 +279,11 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F));
this.tableLayoutPanel1.Controls.Add(this.numAutoSave, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.lblAutoSave1, 0, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 159);
this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 182);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(595, 26);
this.tableLayoutPanel1.TabIndex = 5;
//
@@ -297,10 +298,22 @@ namespace mRemoteNG.UI.Forms.OptionsPages
this.chkSaveConnectionsAfterEveryEdit.Text = "Save connections after every edit";
this.chkSaveConnectionsAfterEveryEdit.UseVisualStyleBackColor = true;
//
// chkUseFilterSearch
//
this.chkUseFilterSearch._mice = mRemoteNG.UI.Controls.Base.NGCheckBox.MouseState.HOVER;
this.chkUseFilterSearch.AutoSize = true;
this.chkUseFilterSearch.Location = new System.Drawing.Point(4, 95);
this.chkUseFilterSearch.Name = "chkUseFilterSearch";
this.chkUseFilterSearch.Size = new System.Drawing.Size(214, 17);
this.chkUseFilterSearch.TabIndex = 8;
this.chkUseFilterSearch.Text = "Filter search matches in connection tree";
this.chkUseFilterSearch.UseVisualStyleBackColor = true;
//
// ConnectionsPage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.chkUseFilterSearch);
this.Controls.Add(this.chkSaveConnectionsAfterEveryEdit);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.pnlRdpConnectionTimeout);
@@ -343,5 +356,6 @@ namespace mRemoteNG.UI.Forms.OptionsPages
private System.Windows.Forms.TableLayoutPanel pnlRdpConnectionTimeout;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
internal Controls.Base.NGCheckBox chkSaveConnectionsAfterEveryEdit;
private Controls.Base.NGCheckBox chkUseFilterSearch;
}
}

View File

@@ -27,6 +27,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkSingleClickOnOpenedConnectionSwitchesToIt.Text = Language.strSingleClickOnOpenConnectionSwitchesToIt;
chkHostnameLikeDisplayName.Text = Language.strSetHostnameLikeDisplayName;
chkSaveConnectionsAfterEveryEdit.Text = Language.SaveConnectionsAfterEveryEdit;
chkUseFilterSearch.Text = Language.FilterSearchMatchesInConnectionTree;
lblRdpReconnectionCount.Text = Language.strRdpReconnectCount;
lblRDPConTimeout.Text = Language.strRDPOverallConnectionTimeout;
@@ -47,6 +48,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkSingleClickOnOpenedConnectionSwitchesToIt.Checked = Settings.Default.SingleClickSwitchesToOpenConnection;
chkHostnameLikeDisplayName.Checked = Settings.Default.SetHostnameLikeDisplayName;
chkSaveConnectionsAfterEveryEdit.Checked = Settings.Default.SaveConnectionsAfterEveryEdit;
chkUseFilterSearch.Checked = Settings.Default.UseFilterSearch;
numRdpReconnectionCount.Value = Convert.ToDecimal(Settings.Default.RdpReconnectionCount);
numRDPConTimeout.Value = Convert.ToDecimal(Settings.Default.ConRDPOverallConnectionTimeout);
@@ -75,6 +77,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
Settings.Default.SingleClickSwitchesToOpenConnection = chkSingleClickOnOpenedConnectionSwitchesToIt.Checked;
Settings.Default.SetHostnameLikeDisplayName = chkHostnameLikeDisplayName.Checked;
Settings.Default.SaveConnectionsAfterEveryEdit = chkSaveConnectionsAfterEveryEdit.Checked;
Settings.Default.UseFilterSearch = chkUseFilterSearch.Checked;
Settings.Default.RdpReconnectionCount = (int) numRdpReconnectionCount.Value;
Settings.Default.ConRDPOverallConnectionTimeout = (int) numRDPConTimeout.Value;

View File

@@ -19,6 +19,7 @@ namespace mRemoteNG.UI.Window
private readonly ConnectionContextMenu _contextMenu;
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
private ThemeManager _themeManager;
private readonly ConnectionTreeSearchTextFilter _connectionTreeSearchTextFilter = new ConnectionTreeSearchTextFilter();
public ConnectionInfo SelectedNode => olvConnections.SelectedNode;
@@ -42,6 +43,7 @@ namespace mRemoteNG.UI.Window
SetMenuEventHandlers();
SetConnectionTreeEventHandlers();
Settings.Default.PropertyChanged += (sender, args) => SetConnectionTreeEventHandlers();
olvConnections.ModelFilter = _connectionTreeSearchTextFilter;
}
@@ -242,9 +244,24 @@ namespace mRemoteNG.UI.Window
private void txtSearch_TextChanged(object sender, EventArgs e)
{
if (txtSearch.Text == "") return;
olvConnections.NodeSearcher?.SearchByName(txtSearch.Text);
JumpToNode(olvConnections.NodeSearcher?.CurrentMatch);
if (Settings.Default.UseFilterSearch)
{
if (txtSearch.Text == "" || txtSearch.Text == Language.strSearchPrompt)
{
olvConnections.UseFiltering = false;
olvConnections.ResetColumnFiltering();
return;
}
olvConnections.UseFiltering = true;
_connectionTreeSearchTextFilter.FilterText = txtSearch.Text;
olvConnections.ModelFilter = _connectionTreeSearchTextFilter;
}
else
{
if (txtSearch.Text == "") return;
olvConnections.NodeSearcher?.SearchByName(txtSearch.Text);
JumpToNode(olvConnections.NodeSearcher?.CurrentMatch);
}
}
private void JumpToNode(ConnectionInfo connectionInfo)

View File

@@ -671,6 +671,9 @@
<setting name="SaveConnectionsAfterEveryEdit" serializeAs="String">
<value>True</value>
</setting>
<setting name="UseFilterSearch" serializeAs="String">
<value>False</value>
</setting>
</mRemoteNG.Settings>
</userSettings>
<applicationSettings>

View File

@@ -381,6 +381,7 @@
<Compile Include="UI\Controls\ConnectionTree\ConnectionTree.Designer.cs">
<DependentUpon>ConnectionTree.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\ConnectionTree\ConnectionTreeSearchTextFilter.cs" />
<Compile Include="UI\Controls\CredentialRecordComboBox.cs">
<SubType>Component</SubType>
</Compile>