Skip to content

Commit

Permalink
Rename class TextBoxElement to ToolStripTextBoxElement and derive fro…
Browse files Browse the repository at this point in the history
…m base class ToolStripElement
  • Loading branch information
rowo360 committed Jan 11, 2025
1 parent ef41947 commit ea469cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
namespace TestCentric.Gui.Elements
{
/// <summary>
/// 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.
/// </summary>
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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/TestCentric/testcentric.gui/Views/TestTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea469cf

Please sign in to comment.