From ea469cfa3b0d2db7889eeb2ed60e3dd8ac9e95ac Mon Sep 17 00:00:00 2001 From: rowo360 <59574371+rowo360@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:44:11 +0100 Subject: [PATCH] Rename class TextBoxElement to ToolStripTextBoxElement and derive from base class ToolStripElement --- ...xElement.cs => ToolStripTextBoxElement.cs} | 32 +++---------------- .../testcentric.gui/Views/TestTreeView.cs | 2 +- 2 files changed, 6 insertions(+), 28 deletions(-) rename src/TestCentric/testcentric.gui/Elements/{TextBoxElement.cs => ToolStripTextBoxElement.cs} (78%) diff --git a/src/TestCentric/testcentric.gui/Elements/TextBoxElement.cs b/src/TestCentric/testcentric.gui/Elements/ToolStripTextBoxElement.cs similarity index 78% rename from src/TestCentric/testcentric.gui/Elements/TextBoxElement.cs rename to src/TestCentric/testcentric.gui/Elements/ToolStripTextBoxElement.cs index 348e1289..787c2d27 100644 --- a/src/TestCentric/testcentric.gui/Elements/TextBoxElement.cs +++ b/src/TestCentric/testcentric.gui/Elements/ToolStripTextBoxElement.cs @@ -10,17 +10,18 @@ namespace TestCentric.Gui.Elements { /// - /// This class implements the IChanged interface for a TextBox control. It provides this additional functionality: + /// This class implements the IChanged interface for a ToolStripTextBox control. It provides this additional functionality: /// - show a PlaceHoder text if there's no text input /// - Invoke the Changed event as soon as no further input is made within a short period of time. /// - public class TextBoxElement : IChanged + public class ToolStripTextBoxElement : ToolStripElement, IChanged { private Timer _typingTimer; public event CommandHandler Changed; - public TextBoxElement(Control textBox, string placeHolderText) + public ToolStripTextBoxElement(ToolStripTextBox textBox, string placeHolderText) + : base(textBox) { TextBox = textBox; PlaceHolderText = placeHolderText; @@ -33,35 +34,12 @@ public TextBoxElement(Control textBox, string placeHolderText) OnTextBoxLostFocus(null, EventArgs.Empty); } - public bool Enabled - { - get => TextBox.Enabled; - set => TextBox.Enabled = value; - } - - public bool Visible - { - get => TextBox.Visible; - set => TextBox.Visible = value; - } - - public string Text - { - get => TextBox.Text; - set => TextBox.Text = value; - } - private string PlaceHolderText { get; set; } - private Control TextBox { get; } + private ToolStripTextBox TextBox { get; } private bool IsPlaceHolderTextShown { get; set; } - public void InvokeIfRequired(MethodInvoker _delegate) - { - throw new NotImplementedException(); - } - private void OnTextBoxGotFocus(object sender, EventArgs e) { // If the PlaceHolderText is shown, replace it with an empty text diff --git a/src/TestCentric/testcentric.gui/Views/TestTreeView.cs b/src/TestCentric/testcentric.gui/Views/TestTreeView.cs index b61bdd57..1c4cc172 100644 --- a/src/TestCentric/testcentric.gui/Views/TestTreeView.cs +++ b/src/TestCentric/testcentric.gui/Views/TestTreeView.cs @@ -49,7 +49,7 @@ public TestTreeView() TestPropertiesCommand = new CommandMenuElement(testPropertiesMenuItem); ViewAsXmlCommand = new CommandMenuElement(viewAsXmlMenuItem); OutcomeFilter = new MultiCheckedToolStripButtonGroup(new[] { filterOutcomePassedButton, filterOutcomeFailedButton, filterOutcomeWarningButton, filterOutcomeNotRunButton }); - TextFilter = new TextBoxElement(filterTextBox.Control, "Filter..."); + TextFilter = new ToolStripTextBoxElement(filterTextBox, "Filter..."); TreeView = treeView; // NOTE: We use MouseDown here rather than MouseUp because