From 57b613492dbd3a0a33c3d4a92da6b8b93db63abe Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Sun, 31 Jul 2016 09:06:57 -0400 Subject: [PATCH 1/9] add text-clear icon (font-awesome under SIL OFL) --- GUI/CKAN-GUI.csproj | 1 + GUI/Resources/text-clear.png | Bin 0 -> 421 bytes 2 files changed, 1 insertion(+) create mode 100644 GUI/Resources/text-clear.png diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj index 51010b1ef8..c4f2ffe6c3 100644 --- a/GUI/CKAN-GUI.csproj +++ b/GUI/CKAN-GUI.csproj @@ -290,5 +290,6 @@ + \ No newline at end of file diff --git a/GUI/Resources/text-clear.png b/GUI/Resources/text-clear.png new file mode 100644 index 0000000000000000000000000000000000000000..518da3557a7564425ac80425a3cf17f60afc0f98 GIT binary patch literal 421 zcmeAS@N?(olHy`uVBq!ia0vp^N+8U^3=*07`vZ_l3-AeX1=7!N-=Z~|l%vo9v`Mif z$S;_IiJ66yi<^g+PfkJEEvc!wvuECloxAoNJbLQhgD1~k{0^S=#}26Ytfz}(h(+(( zi?@ZE40u>B-0I@0U=R5a^!dO2N@wdG-iLoIsC<2Hrq3*i&&OxI{c|vI(~9@eHMiYd zqD*$ys~?}JaGBd6u%Yu&vX-D(vjFF33qdo5Cvv+g%rutpEvZO38s&Q7Mv3um~fxCtK1>6p?LVcW6g-RuA#C85O~69ZXiax$iMKH6BRwaj_rBU!ns zhY=s<)xNm2Nnta;%I=K}#oG)|uG3*F-sF5qTHvCI*rcDXyHwxq{ty)D Date: Sun, 31 Jul 2016 09:14:15 -0400 Subject: [PATCH 2/9] darken text-clear icon --- GUI/Resources/text-clear.png | Bin 421 -> 421 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/GUI/Resources/text-clear.png b/GUI/Resources/text-clear.png index 518da3557a7564425ac80425a3cf17f60afc0f98..71da7594325a262687342923926108def4a255e7 100644 GIT binary patch delta 137 zcmZ3=yp(x@PW`fZ^JtC4gs!A8Ffb^V1o;IsFfp@ma&hzU^2sSEyCpSET>T3GS}{kZ delta 137 zcmZ3=yp(x@PW|)Sw`h$fT3G`ITSY From 7b8255a511716c07fc4d305f436d393bec76da8b Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Sun, 31 Jul 2016 10:00:02 -0400 Subject: [PATCH 3/9] fix up resource binding for clear icon --- GUI/Properties/Resources.Designer.cs | 10 ++++++++++ GUI/Properties/Resources.resx | 2 ++ GUI/Resources/text-clear.png | Bin 421 -> 0 bytes GUI/Resources/textClear.png | Bin 0 -> 556 bytes 4 files changed, 12 insertions(+) delete mode 100644 GUI/Resources/text-clear.png create mode 100644 GUI/Resources/textClear.png diff --git a/GUI/Properties/Resources.Designer.cs b/GUI/Properties/Resources.Designer.cs index 422ccc6350..79c9c70f64 100644 --- a/GUI/Properties/Resources.Designer.cs +++ b/GUI/Properties/Resources.Designer.cs @@ -148,6 +148,16 @@ internal static System.Drawing.Bitmap settings { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap textClear { + get { + object obj = ResourceManager.GetObject("textClear", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/GUI/Properties/Resources.resx b/GUI/Properties/Resources.resx index 6416c54ebf..7e1cb39dae 100644 --- a/GUI/Properties/Resources.resx +++ b/GUI/Properties/Resources.resx @@ -147,5 +147,7 @@ ..\Resources\forward.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\textClear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/GUI/Resources/text-clear.png b/GUI/Resources/text-clear.png deleted file mode 100644 index 71da7594325a262687342923926108def4a255e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 421 zcmeAS@N?(olHy`uVBq!ia0vp^N+8U^3=*07`vZ_l3-AeX1=7pr&7(CE6S|TDv`Mif z$S;_IiJ66yi<^g+PfkJEEvc!wvuECloxAoNJbLQhgD1~k{0^S=#}26Ytfz}(h(+(( zi?@ZE40u>B-0I@0U=R5a^!dO2N@wdG-iLoIsC<2Hrq3*i&&OxI{c|vI(~9@eHMiYd zqD*$ys~?}JaGBd6u%Yu&vX-D(vjFF33qdo5Cvv+g%rutpEvZO38s&Q7Mv3um~fxCtK1>6p?LVcW6g-RuA#C85O~69ZXiax$iMKH6BRwaj_rBU!ns zhY=s<)xNm2Nnta;%I=K}#oG)|uG3*F-sF5qTHvCI*rcDXyHwxq{ty)D z-hc`sR+83$RRo(AHoH4JKW5YDDQ98!VTSq64E$Gj1-cKBQWfA3*a0qp{ZORi`h!TR zLEsEn0uDkEWetgx8UQYV)x>ZUSa!igN{s-|z-VIlBox^*LNo|xj0T~_1P%ymi~*60 zsiZ!h8V~@Bz-^>d^%n?$-AF0PK;ntFEVn-wXyTS=)!m)0Pb~LGY@n; zFykJG7O-7(YHGkEP%SaPTEIjo@?px6GBFv1DOtUI*vEdKzK-e(lLsu~+l_o%#k|#q0fl4Ut>`0000 Date: Sun, 31 Jul 2016 10:00:47 -0400 Subject: [PATCH 4/9] add subclass of TextBox to handle clear icon --- GUI/CKAN-GUI.csproj | 8 ++- GUI/HintTextBox.Designer.cs | 44 +++++++++++++ GUI/HintTextBox.cs | 35 ++++++++++ GUI/HintTextBox.resx | 123 ++++++++++++++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 GUI/HintTextBox.Designer.cs create mode 100644 GUI/HintTextBox.cs create mode 100644 GUI/HintTextBox.resx diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj index c4f2ffe6c3..86a037d84e 100644 --- a/GUI/CKAN-GUI.csproj +++ b/GUI/CKAN-GUI.csproj @@ -77,6 +77,12 @@ ChooseKSPInstance.cs + + Component + + + HintTextBox.cs + Code @@ -290,6 +296,6 @@ - + \ No newline at end of file diff --git a/GUI/HintTextBox.Designer.cs b/GUI/HintTextBox.Designer.cs new file mode 100644 index 0000000000..e994032109 --- /dev/null +++ b/GUI/HintTextBox.Designer.cs @@ -0,0 +1,44 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace CKAN +{ + partial class HintTextBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // HintTextBox + // + this.TextChanged += new System.EventHandler(this.HintTextBox_TextChanged); + this.ResumeLayout(false); + } + + #endregion + } +} diff --git a/GUI/HintTextBox.cs b/GUI/HintTextBox.cs new file mode 100644 index 0000000000..938ec06ea6 --- /dev/null +++ b/GUI/HintTextBox.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CKAN +{ + public partial class HintTextBox : TextBox + { + public HintTextBox() + { + InitializeComponent(); + } + + private void HintTextBox_TextChanged(object sender, EventArgs e) + { + // sanity checks + if (!Visible || ReadOnly) + { + return; + } + + if (TextLength <= 0) + { + return; + } + + } + } +} diff --git a/GUI/HintTextBox.resx b/GUI/HintTextBox.resx new file mode 100644 index 0000000000..e5858cc294 --- /dev/null +++ b/GUI/HintTextBox.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file From 6149652ae77199bf0eea5dad33ebef03f4f690a0 Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Sun, 31 Jul 2016 12:57:11 -0400 Subject: [PATCH 5/9] add clear-able text box to filter fields (#1018) --- GUI/CKAN-GUI.csproj | 3 +++ GUI/HintTextBox.Designer.cs | 2 ++ GUI/HintTextBox.cs | 46 ++++++++++++++++++++++++++++++++++-- GUI/Main.Designer.cs | 10 ++++---- GUI/Resources/textClear.png | Bin 556 -> 568 bytes 5 files changed, 54 insertions(+), 7 deletions(-) diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj index 86a037d84e..e31bbb2fc1 100644 --- a/GUI/CKAN-GUI.csproj +++ b/GUI/CKAN-GUI.csproj @@ -187,6 +187,9 @@ ErrorDialog.cs + + HintTextBox.cs + KSPCommandLineOptionsDialog.cs diff --git a/GUI/HintTextBox.Designer.cs b/GUI/HintTextBox.Designer.cs index e994032109..4f1832775a 100644 --- a/GUI/HintTextBox.Designer.cs +++ b/GUI/HintTextBox.Designer.cs @@ -35,8 +35,10 @@ private void InitializeComponent() // // HintTextBox // + this.SizeChanged += new System.EventHandler(this.HintTextBox_SizeChanged); this.TextChanged += new System.EventHandler(this.HintTextBox_TextChanged); this.ResumeLayout(false); + } #endregion diff --git a/GUI/HintTextBox.cs b/GUI/HintTextBox.cs index 938ec06ea6..0ea7d1d4e1 100644 --- a/GUI/HintTextBox.cs +++ b/GUI/HintTextBox.cs @@ -12,9 +12,36 @@ namespace CKAN { public partial class HintTextBox : TextBox { + private PictureBox _clearIcon; + public HintTextBox() { InitializeComponent(); + + // set up clear icon state and handlers + _clearIcon = new PictureBox(); + _clearIcon.BackColor = Color.Transparent; + _clearIcon.Visible = false; + _clearIcon.Cursor = Cursors.Hand; + _clearIcon.Image = global::CKAN.Properties.Resources.textClear; + _clearIcon.SizeMode = PictureBoxSizeMode.CenterImage; + _clearIcon.Size = _clearIcon.Image.Size; + _clearIcon.Click += HintClearIcon_Click; + _clearIcon.Paint += ClearIcon_Paint; + + Controls.Add(_clearIcon); + _clearIcon.Parent = this; + _clearIcon.BringToFront(); + } + + private void ClearIcon_Paint(object sender, PaintEventArgs e) + { + var gfx = e.Graphics; + } + + private void HintClearIcon_Click(object sender, EventArgs e) + { + Text = string.Empty; } private void HintTextBox_TextChanged(object sender, EventArgs e) @@ -24,12 +51,27 @@ private void HintTextBox_TextChanged(object sender, EventArgs e) { return; } + + _clearIcon.Visible = (TextLength > 0); + } - if (TextLength <= 0) + private void HintTextBox_SizeChanged(object sender, EventArgs e) + { + if (_clearIcon.Image != null) { - return; + _clearIcon.Location = new Point(Width - _clearIcon.Image.Width - 1, (Height - _clearIcon.Image.Height) / 2); + } + } + + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if (keyData == Keys.Escape) + { + Text = ""; + return true; } + return base.ProcessCmdKey(ref msg, keyData); } } } diff --git a/GUI/Main.Designer.cs b/GUI/Main.Designer.cs index ab9e73a7ed..a777f01f39 100644 --- a/GUI/Main.Designer.cs +++ b/GUI/Main.Designer.cs @@ -107,13 +107,13 @@ private void InitializeComponent() this.StatusLabel = new System.Windows.Forms.Label(); this.MainTabControl = new CKAN.MainTabControl(); this.ManageModsTabPage = new System.Windows.Forms.TabPage(); - this.FilterByAuthorTextBox = new System.Windows.Forms.TextBox(); + this.FilterByAuthorTextBox = new HintTextBox(); this.FilterByAuthorLabel = new System.Windows.Forms.Label(); this.KSPVersionLabel = new System.Windows.Forms.Label(); this.FilterByNameLabel = new System.Windows.Forms.Label(); - this.FilterByNameTextBox = new System.Windows.Forms.TextBox(); + this.FilterByNameTextBox = new HintTextBox(); this.FilterByDescriptionLabel = new System.Windows.Forms.Label(); - this.FilterByDescriptionTextBox = new System.Windows.Forms.TextBox(); + this.FilterByDescriptionTextBox = new HintTextBox(); this.ChangesetTabPage = new System.Windows.Forms.TabPage(); this.CancelChangesButton = new System.Windows.Forms.Button(); this.ConfirmChangesButton = new System.Windows.Forms.Button(); @@ -1548,9 +1548,9 @@ private void InitializeComponent() private TabPage ManageModsTabPage; private Label KSPVersionLabel; private Label FilterByNameLabel; - private TextBox FilterByNameTextBox; + private HintTextBox FilterByNameTextBox; private Label FilterByDescriptionLabel; - private TextBox FilterByDescriptionTextBox; + private HintTextBox FilterByDescriptionTextBox; private TabPage WaitTabPage; private Button CancelCurrentActionButton; private TextBox LogTextBox; diff --git a/GUI/Resources/textClear.png b/GUI/Resources/textClear.png index 6193c8524320ef00fcded8a654463b8cfd055cc8..79cab638cb37bd3d15270da67432b81abcccf8dc 100644 GIT binary patch delta 529 zcmV+s0`C2+1h@ntiBL{Q4GJ0x0000DNk~Le0000I0000I2nGNE09MY9SCJtze-JS? zbqgDy0005SNklkmojpHoIrBS zIbbaqod>RY;AWNaEAS<)&w(It0BoByuP^%+@FHz!{0o}_q3~;yh9Stnf25f!5gA^& zKX8zR11u8A1lY=|Hhn3WM8zzWnF3wK=E$VWSsa`s zed%v*(?K4X^afxMEy6SG0#|{1S91gr!hiBL{Q4GJ0x0000DNk~Le0000Y0000Y2nGNE06Iqt!jT~}e+?HB zo+wOq0005GNkl*9Yu@eF+YO9C{RvOeh*hV~pH=vy$B3OC_ z;)u;&f<;6@ku=_b3L;jL)__$6n-w;@J3BvS)95K@VfJB$`OXadS9b-v50O$8;1JjW zE`a?|q~rR7NU1^K3|ImVLJ?&Re~FYD04{;m#BdW>cELnSjR4QUXkz#z6xlOEGze#m z2BF0S4hUuw8U&YQQ5 Date: Tue, 30 Aug 2016 16:23:44 -0400 Subject: [PATCH 6/9] add missing tag to resx --- GUI/Properties/Resources.resx | 1 + 1 file changed, 1 insertion(+) diff --git a/GUI/Properties/Resources.resx b/GUI/Properties/Resources.resx index 7e1cb39dae..3d6e7fddf3 100644 --- a/GUI/Properties/Resources.resx +++ b/GUI/Properties/Resources.resx @@ -147,6 +147,7 @@ ..\Resources\forward.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\textClear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a From 0c7b027a5ba4d1c4adf6bb7c1f4b16b85632e3e3 Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Tue, 30 Aug 2016 16:24:27 -0400 Subject: [PATCH 7/9] fix compile errors due to useless namespaces --- GUI/HintTextBox.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/GUI/HintTextBox.cs b/GUI/HintTextBox.cs index 0ea7d1d4e1..12d8732b0a 100644 --- a/GUI/HintTextBox.cs +++ b/GUI/HintTextBox.cs @@ -1,11 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace CKAN From 5cdd640d3a63cc22a0374af1b8832b400c9c32d4 Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Tue, 30 Aug 2016 16:51:03 -0400 Subject: [PATCH 8/9] fix positioning of clear icon in HintTextBox, improve its documentation and efficiency --- GUI/HintTextBox.cs | 67 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/GUI/HintTextBox.cs b/GUI/HintTextBox.cs index 12d8732b0a..6f7842f0a5 100644 --- a/GUI/HintTextBox.cs +++ b/GUI/HintTextBox.cs @@ -4,40 +4,56 @@ namespace CKAN { + /// + /// A textbox which shows a "clear text" icon on the right side + /// whenever data is present. + /// public partial class HintTextBox : TextBox { - private PictureBox _clearIcon; + private readonly PictureBox _clearIcon; + /// + /// Creates a HintTextBox object. + /// public HintTextBox() { InitializeComponent(); // set up clear icon state and handlers - _clearIcon = new PictureBox(); - _clearIcon.BackColor = Color.Transparent; - _clearIcon.Visible = false; - _clearIcon.Cursor = Cursors.Hand; - _clearIcon.Image = global::CKAN.Properties.Resources.textClear; - _clearIcon.SizeMode = PictureBoxSizeMode.CenterImage; + _clearIcon = new PictureBox() + { + BackColor = Color.Transparent, + Visible = false, + Cursor = Cursors.Hand, + Image = global::CKAN.Properties.Resources.textClear, + SizeMode = PictureBoxSizeMode.CenterImage + }; + + // post-instantiation setup _clearIcon.Size = _clearIcon.Image.Size; _clearIcon.Click += HintClearIcon_Click; - _clearIcon.Paint += ClearIcon_Paint; + // add icon and show form Controls.Add(_clearIcon); _clearIcon.Parent = this; _clearIcon.BringToFront(); } - private void ClearIcon_Paint(object sender, PaintEventArgs e) - { - var gfx = e.Graphics; - } - + /// + /// When the icon is clicked, reset the textbox value. + /// + /// The control sending the event + /// The event arguments private void HintClearIcon_Click(object sender, EventArgs e) { Text = string.Empty; } + /// + /// Show the clear icon when the textbox has data + /// + /// The control sending the event + /// The event arguments private void HintTextBox_TextChanged(object sender, EventArgs e) { // sanity checks @@ -45,18 +61,37 @@ private void HintTextBox_TextChanged(object sender, EventArgs e) { return; } - + _clearIcon.Visible = (TextLength > 0); } + /// + /// Adjust the position of the clear icon regardless of control size. + /// + /// The control sending the event + /// The event arguments private void HintTextBox_SizeChanged(object sender, EventArgs e) { - if (_clearIcon.Image != null) + if (_clearIcon.Image == null) { - _clearIcon.Location = new Point(Width - _clearIcon.Image.Width - 1, (Height - _clearIcon.Image.Height) / 2); + return; } + + _clearIcon.Location = new Point( + // align with right edge of textbox minus 5px + Width - _clearIcon.Width - 5, + // need to divide these as decimals and drop back to int at the end + (int)Math.Ceiling(Height / 2d - (_clearIcon.Height / 2d)) + ); } + /// + /// Intercept the low-level key press messages to catch Esc, + /// which causes the textbox to clear + /// + /// Win32 Message object + /// Which keys are being pressed + /// protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Escape) From 254ed3dac90ae15739494205b0c8f35e06fe3de4 Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Sat, 3 Sep 2016 12:40:26 -0400 Subject: [PATCH 9/9] convert line endings in Resources.resx --- GUI/Properties/Resources.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/Properties/Resources.resx b/GUI/Properties/Resources.resx index 3d6e7fddf3..d7ccda9e2b 100644 --- a/GUI/Properties/Resources.resx +++ b/GUI/Properties/Resources.resx @@ -1,4 +1,4 @@ - +