some design improvements

This commit is contained in:
Faryan Rezagholi
2019-03-10 20:16:02 +01:00
parent 6ba1d28f13
commit 446b40d8a6
2 changed files with 24 additions and 27 deletions

View File

@@ -1,11 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace mRemoteNG.UI.Controls.Base
{
public class NGSearchBox : NGTextBox
{
private Button btClear = new Button();
private PictureBox pbClear = new PictureBox();
private ToolTip btClearToolTip = new ToolTip();
public NGSearchBox()
@@ -19,18 +20,18 @@ namespace mRemoteNG.UI.Controls.Base
private void ApplyLanguage()
{
btClearToolTip.SetToolTip(btClear, Language.ClearSearchString);
btClearToolTip.SetToolTip(pbClear, Language.ClearSearchString);
}
private void AddClearButton()
{
btClear.BackgroundImage = Resources.Delete;
btClear.BackgroundImageLayout = ImageLayout.Stretch;
btClear.Width = 16;
btClear.Dock = DockStyle.Right;
btClear.Click += BtClear_Click;
btClear.LostFocus += FocusLost;
Controls.Add(btClear);
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)
@@ -38,7 +39,7 @@ namespace mRemoteNG.UI.Controls.Base
if (string.IsNullOrEmpty(Text))
{
Text = Language.strSearchPrompt;
btClear.Visible = false;
pbClear.Visible = false;
}
}
@@ -52,17 +53,13 @@ namespace mRemoteNG.UI.Controls.Base
//
this.TextChanged += new System.EventHandler(this.NGSearchBox_TextChanged);
this.ResumeLayout(false);
}
private void BtClear_Click(object sender, EventArgs e) => Text = string.Empty;
private void PbClear_Click(object sender, EventArgs e) => Text = string.Empty;
private void NGSearchBox_TextChanged(object sender, EventArgs e)
{
if (Text == Language.strSearchPrompt)
btClear.Visible = false;
else
btClear.Visible = TextLength > 0;
pbClear.Visible = Text == Language.strSearchPrompt ? false : TextLength > 0;
}
}
}

View File

@@ -29,11 +29,11 @@ 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.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();
this.mMenFavorites = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.olvConnections)).BeginInit();
this.msMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbSearch)).BeginInit();
@@ -133,17 +133,25 @@ 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.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 = "PictureBoxSearch";
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;
@@ -181,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);