-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI elements for test outcome filtering
- Loading branch information
Showing
17 changed files
with
404 additions
and
10 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/TestCentric/testcentric.gui/Elements/IMultiSelection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// *********************************************************************** | ||
// Copyright (c) Charlie Poole and TestCentric contributors. | ||
// Licensed under the MIT License. See LICENSE file in root directory. | ||
// *********************************************************************** | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace TestCentric.Gui.Elements | ||
{ | ||
/// <summary> | ||
/// The IMultiSelection interface represents a group of UI elements | ||
/// that allow the user to select a set of items. | ||
/// </summary> | ||
public interface IMultiSelection : IViewElement | ||
{ | ||
/// <summary> | ||
/// Gets or sets the string values of the currently selected items | ||
/// </summary> | ||
IEnumerable<string> SelectedItems { get; set; } | ||
|
||
/// <summary> | ||
/// Event raised when the selection is changed by the user | ||
/// </summary> | ||
event CommandHandler SelectionChanged; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/TestCentric/testcentric.gui/Elements/MultiCheckedToolStripButtonGroup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// *********************************************************************** | ||
// Copyright (c) Charlie Poole and TestCentric contributors. | ||
// Licensed under the MIT License. See LICENSE file in root directory. | ||
// *********************************************************************** | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace TestCentric.Gui.Elements | ||
{ | ||
/// <summary> | ||
/// MultiCheckedToolStripButtonGroup wraps a set of ToolStrip button items as an IMultiSelection. | ||
/// </summary> | ||
internal class MultiCheckedToolStripButtonGroup : IMultiSelection | ||
{ | ||
public event CommandHandler SelectionChanged; | ||
|
||
public MultiCheckedToolStripButtonGroup(params ToolStripButton[] buttons) | ||
{ | ||
ToolStripButtons = new List<ToolStripButton>(); | ||
|
||
foreach (var button in buttons) | ||
{ | ||
ToolStripButtons.Add(button); | ||
button.Click += OnButtonClicked; | ||
} | ||
} | ||
|
||
protected IList<ToolStripButton> ToolStripButtons { get; } | ||
|
||
public IEnumerable<string> SelectedItems | ||
{ | ||
get | ||
{ | ||
IList<string> result = new List<string>(); | ||
foreach (ToolStripButton button in ToolStripButtons) | ||
if (button.Checked) | ||
result.Add(button.Tag as string); | ||
|
||
return result; | ||
} | ||
|
||
set | ||
{ | ||
foreach (ToolStripButton button in ToolStripButtons) | ||
{ | ||
bool checkStatus = value.Contains(button.Tag as string); | ||
button.Checked = checkStatus; | ||
} | ||
} | ||
} | ||
|
||
private bool _enabled; | ||
public bool Enabled | ||
{ | ||
get { return _enabled; } | ||
set | ||
{ | ||
_enabled = value; | ||
|
||
foreach (ToolStripButton button in ToolStripButtons) | ||
button.Enabled = value; | ||
} | ||
} | ||
|
||
private bool _visible; | ||
public bool Visible | ||
{ | ||
get { return _visible; } | ||
set | ||
{ | ||
_visible = value; | ||
|
||
foreach (ToolStripButton button in ToolStripButtons) | ||
button.Visible = value; | ||
} | ||
} | ||
|
||
public string Text { get; set; } | ||
|
||
|
||
public void InvokeIfRequired(MethodInvoker _delegate) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
protected virtual void OnButtonClicked(object sender, EventArgs e) | ||
{ | ||
if (SelectionChanged != null) | ||
SelectionChanged(); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...TestCentric/testcentric.gui/Elements/MultiCheckedToolStripButtonGroupWithDefaultButton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// *********************************************************************** | ||
// Copyright (c) Charlie Poole and TestCentric contributors. | ||
// Licensed under the MIT License. See LICENSE file in root directory. | ||
// *********************************************************************** | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace TestCentric.Gui.Elements | ||
{ | ||
/// <summary> | ||
/// This class is a specialized class of class MultiCheckedToolStripButtonGroup | ||
/// Therefore this class supports also the selection of multiple buttons. | ||
/// But additionally there is one special default button that resets all other buttons when it is clicked. | ||
/// </summary> | ||
internal class MultiCheckedToolStripButtonGroupWithDefaultButton : MultiCheckedToolStripButtonGroup | ||
{ | ||
public MultiCheckedToolStripButtonGroupWithDefaultButton(params ToolStripButton[] buttons) : base(buttons) | ||
{ | ||
// By convention the default button is the first one in the list | ||
DefaultButton = buttons.First(); | ||
IndividualButtons = buttons.Skip(1); | ||
|
||
foreach (ToolStripButton button in ToolStripButtons) | ||
button.CheckedChanged += OnButtonCheckedChanged; | ||
|
||
DefaultButton.Checked = true; | ||
} | ||
|
||
private ToolStripButton DefaultButton { get; } | ||
|
||
private IEnumerable<ToolStripButton> IndividualButtons { get; } | ||
|
||
protected override void OnButtonClicked(object sender, EventArgs e) | ||
{ | ||
ToolStripButton clickedButton = sender as ToolStripButton; | ||
if (clickedButton == DefaultButton) | ||
DefaultButtonClicked(sender, e); | ||
else | ||
IndividualButtonClicked(sender, e); | ||
|
||
base.OnButtonClicked(sender, e); | ||
} | ||
|
||
private void DefaultButtonClicked(object sender, EventArgs e) | ||
{ | ||
foreach (ToolStripButton button in IndividualButtons) | ||
button.Checked = false; | ||
} | ||
|
||
private void IndividualButtonClicked(object sender, EventArgs e) | ||
{ | ||
DefaultButton.Checked = false; | ||
} | ||
|
||
private void OnButtonCheckedChanged(object sender, EventArgs e) | ||
{ | ||
ToolStripButton button = sender as ToolStripButton; | ||
var style = button.Checked ? FontStyle.Bold : FontStyle.Regular; | ||
button.Font = new Font(button.Font, style); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/TestCentric/testcentric.gui/Views/TestTreeView.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.