Merge pull request #1339 from mRemoteNG/clear_searchbox

Add button to clear searchbox
This commit is contained in:
David Sparer
2019-03-21 13:42:13 -05:00
committed by GitHub
8 changed files with 243 additions and 52 deletions

View File

@@ -78,6 +78,15 @@ namespace mRemoteNG {
}
}
/// <summary>
/// Looks up a localized string similar to Clear search string.
/// </summary>
internal static string ClearSearchString {
get {
return ResourceManager.GetString("ClearSearchString", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Create a New Connection File.
/// </summary>

View File

@@ -2660,6 +2660,9 @@ Development umfasst Alphas, Betas und Release Candidates.</value>
<data name="Favorites" xml:space="preserve">
<value>Favoriten</value>
</data>
<data name="ClearSearchString" xml:space="preserve">
<value>Suchbegriff löschen</value>
</data>
<data name="ConnectInViewOnlyMode" xml:space="preserve">
<value>Im View-Only-Modus verbinden</value>
</data>

View File

@@ -2775,6 +2775,9 @@ Development Channel includes Alphas, Betas &amp; Release Candidates.</value>
<data name="Favorites" xml:space="preserve">
<value>Favorites</value>
</data>
<data name="ClearSearchString" xml:space="preserve">
<value>Clear search string</value>
</data>
<data name="ConnectInViewOnlyMode" xml:space="preserve">
<value>Connect in View Only mode</value>
</data>

View File

@@ -0,0 +1,65 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace mRemoteNG.UI.Controls.Base
{
public class NGSearchBox : NGTextBox
{
private PictureBox pbClear = new PictureBox();
private ToolTip btClearToolTip = new ToolTip();
public NGSearchBox()
{
InitializeComponent();
LostFocus += FocusLost;
GotFocus += FocusGot;
AddClearButton();
ApplyLanguage();
}
private void ApplyLanguage()
{
btClearToolTip.SetToolTip(pbClear, Language.ClearSearchString);
}
private void AddClearButton()
{
pbClear.Image = Resources.Delete;
pbClear.Width = 20;
pbClear.Dock = DockStyle.Right;
pbClear.Cursor = Cursors.Default;
pbClear.Click += PbClear_Click;
pbClear.LostFocus += FocusLost;
Controls.Add(pbClear);
}
private void FocusLost(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Text))
{
Text = Language.strSearchPrompt;
pbClear.Visible = false;
}
}
private void FocusGot(object sender, EventArgs e) => Text = "";
private void InitializeComponent()
{
this.SuspendLayout();
//
// NGSearchBox
//
this.TextChanged += new System.EventHandler(this.NGSearchBox_TextChanged);
this.ResumeLayout(false);
}
private void PbClear_Click(object sender, EventArgs e) => Text = string.Empty;
private void NGSearchBox_TextChanged(object sender, EventArgs e)
{
pbClear.Visible = Text == Language.strSearchPrompt ? false : TextLength > 0;
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -1,4 +1,4 @@

using mRemoteNG.Connection;
using mRemoteNG.Tree;
@@ -29,14 +29,14 @@ namespace mRemoteNG.UI.Window
this.mMenViewExpandAllFolders = new System.Windows.Forms.ToolStripMenuItem();
this.mMenViewCollapseAllFolders = new System.Windows.Forms.ToolStripMenuItem();
this.mMenSortAscending = new System.Windows.Forms.ToolStripMenuItem();
this.vsToolStripExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this.PictureBoxSearch = new mRemoteNG.UI.Controls.Base.NGPictureBox(this.components);
this.txtSearch = new mRemoteNG.UI.Controls.Base.NGTextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.mMenFavorites = new System.Windows.Forms.ToolStripMenuItem();
this.vsToolStripExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this.pbSearch = new mRemoteNG.UI.Controls.Base.NGPictureBox(this.components);
this.txtSearch = new mRemoteNG.UI.Controls.Base.NGSearchBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
((System.ComponentModel.ISupportInitialize)(this.olvConnections)).BeginInit();
this.msMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxSearch)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbSearch)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
@@ -133,21 +133,29 @@ namespace mRemoteNG.UI.Window
this.mMenSortAscending.Name = "mMenSortAscending";
this.mMenSortAscending.Size = new System.Drawing.Size(28, 20);
//
// mMenFavorites
//
this.mMenFavorites.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.mMenFavorites.Image = global::mRemoteNG.Resources.star;
this.mMenFavorites.Name = "mMenFavorites";
this.mMenFavorites.Size = new System.Drawing.Size(28, 20);
this.mMenFavorites.Text = "Favorites";
//
// vsToolStripExtender
//
this.vsToolStripExtender.DefaultRenderer = null;
//
// PictureBoxSearch
// pbSearch
//
this.PictureBoxSearch.Dock = System.Windows.Forms.DockStyle.Fill;
this.PictureBoxSearch.Image = global::mRemoteNG.Resources.Search;
this.PictureBoxSearch.Location = new System.Drawing.Point(0, 0);
this.PictureBoxSearch.Margin = new System.Windows.Forms.Padding(0);
this.PictureBoxSearch.Name = "PictureBoxSearch";
this.PictureBoxSearch.Size = new System.Drawing.Size(26, 21);
this.PictureBoxSearch.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.PictureBoxSearch.TabIndex = 1;
this.PictureBoxSearch.TabStop = false;
this.pbSearch.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbSearch.Image = global::mRemoteNG.Resources.Search;
this.pbSearch.Location = new System.Drawing.Point(0, 0);
this.pbSearch.Margin = new System.Windows.Forms.Padding(0);
this.pbSearch.Name = "pbSearch";
this.pbSearch.Size = new System.Drawing.Size(26, 21);
this.pbSearch.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pbSearch.TabIndex = 1;
this.pbSearch.TabStop = false;
//
// txtSearch
//
@@ -163,9 +171,7 @@ namespace mRemoteNG.UI.Window
this.txtSearch.TabStop = false;
this.txtSearch.Text = "Search";
this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
this.txtSearch.GotFocus += new System.EventHandler(this.txtSearch_GotFocus);
this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown);
this.txtSearch.LostFocus += new System.EventHandler(this.txtSearch_LostFocus);
//
// tableLayoutPanel1
//
@@ -173,7 +179,7 @@ namespace mRemoteNG.UI.Window
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 26F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.PictureBoxSearch, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.pbSearch, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.txtSearch);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 390);
@@ -183,14 +189,6 @@ namespace mRemoteNG.UI.Window
this.tableLayoutPanel1.Size = new System.Drawing.Size(204, 21);
this.tableLayoutPanel1.TabIndex = 32;
//
// mMenFavorites
//
this.mMenFavorites.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.mMenFavorites.Image = global::mRemoteNG.Resources.star;
this.mMenFavorites.Name = "mMenFavorites";
this.mMenFavorites.Size = new System.Drawing.Size(28, 20);
this.mMenFavorites.Text = "Favorites";
//
// ConnectionTreeWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@@ -209,7 +207,7 @@ namespace mRemoteNG.UI.Window
((System.ComponentModel.ISupportInitialize)(this.olvConnections)).EndInit();
this.msMain.ResumeLayout(false);
this.msMain.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxSearch)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbSearch)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
@@ -221,8 +219,8 @@ namespace mRemoteNG.UI.Window
private System.ComponentModel.IContainer components;
private Controls.ConnectionTree olvConnections;
private WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender vsToolStripExtender;
internal Controls.Base.NGPictureBox PictureBoxSearch;
internal Controls.Base.NGTextBox txtSearch;
internal Controls.Base.NGPictureBox pbSearch;
internal Controls.Base.NGSearchBox txtSearch;
public System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
internal System.Windows.Forms.ToolStripMenuItem mMenFavorites;
}

View File

@@ -103,7 +103,7 @@ namespace mRemoteNG.UI.Window
_themeManager.ActiveTheme.Theme);
if (!_themeManager.ActiveAndExtended) return;
//Treelistview need to be manually themed
//Treelistview needs to be manually themed
olvConnections.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TreeView_Background");
olvConnections.ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TreeView_Foreground");
olvConnections.SelectedBackColor =
@@ -117,6 +117,8 @@ namespace mRemoteNG.UI.Window
//There is a border around txtSearch that dont theme well
txtSearch.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Background");
txtSearch.ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Foreground");
//Picturebox needs to be manually themed
pbSearch.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TreeView_Background");
}
#endregion
@@ -252,18 +254,6 @@ namespace mRemoteNG.UI.Window
#region Search
private void txtSearch_GotFocus(object sender, EventArgs e)
{
if (txtSearch.Text == Language.strSearchPrompt)
txtSearch.Text = "";
}
private void txtSearch_LostFocus(object sender, EventArgs e)
{
if (txtSearch.Text != "") return;
txtSearch.Text = Language.strSearchPrompt;
}
private void txtSearch_KeyDown(object sender, KeyEventArgs e)
{
try
@@ -295,9 +285,7 @@ namespace mRemoteNG.UI.Window
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(
"txtSearch_KeyDown (UI.Window.ConnectionTreeWindow) failed",
ex);
Runtime.MessageCollector.AddExceptionStackTrace("txtSearch_KeyDown (UI.Window.ConnectionTreeWindow) failed", ex);
}
}
@@ -360,9 +348,7 @@ namespace mRemoteNG.UI.Window
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(
"tvConnections_KeyPress (UI.Window.ConnectionTreeWindow) failed",
ex);
Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_KeyPress (UI.Window.ConnectionTreeWindow) failed", ex);
}
}
@@ -384,9 +370,7 @@ namespace mRemoteNG.UI.Window
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(
"tvConnections_KeyDown (UI.Window.ConnectionTreeWindow) failed",
ex);
Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_KeyDown (UI.Window.ConnectionTreeWindow) failed", ex);
}
}

View File

@@ -406,6 +406,9 @@
<Compile Include="UI\Controls\Base\NGRadioButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\Base\NGSearchBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\Base\NGTextBox.cs">
<SubType>Component</SubType>
</Compile>
@@ -846,6 +849,9 @@
<EmbeddedResource Include="UI\Controls\Base\NGRadioButton.resx">
<DependentUpon>NGRadioButton.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Controls\Base\NGSearchBox.resx">
<DependentUpon>NGSearchBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Controls\Base\NGTextBox.resx">
<DependentUpon>NGTextBox.cs</DependentUpon>
</EmbeddedResource>