Ability to clear trait selection

This should fulfill issue #7
This commit is contained in:
Jared Parsons 2015-08-23 21:00:28 -07:00
Родитель 65f3fc970e
Коммит 0e24227de0
3 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -110,6 +110,11 @@
<Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Clear" Command="{Binding TraitsClearCommand}" />
</ContextMenu>
</ListBox.ContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand Command="{Binding TraitSelectionChangedCommand}" />

Просмотреть файл

@ -50,6 +50,7 @@ namespace xunit.runner.wpf.ViewModel
this.RunCommand = new RelayCommand(OnExecuteRun, CanExecuteRun);
this.CancelCommand = new RelayCommand(OnExecuteCancel, CanExecuteCancel);
this.TraitSelectionChangedCommand = new RelayCommand(OnTraitSelectionChanged);
this.TraitsClearCommand = new RelayCommand(OnTraitsClear);
}
private static bool TestCaseMatches(TestCaseViewModel testCase, SearchQuery searchQuery)
@ -108,6 +109,7 @@ namespace xunit.runner.wpf.ViewModel
public RelayCommand RunCommand { get; }
public RelayCommand CancelCommand { get; }
public ICommand TraitSelectionChangedCommand { get; }
public ICommand TraitsClearCommand { get; }
public CommandBindingCollection CommandBindings { get; }
@ -328,8 +330,6 @@ namespace xunit.runner.wpf.ViewModel
tc.State = TestState.NotRun;
}
// TODO: Need a way to filter based on traits
var runAll = TestCases.Count == this.allTestCases.Count;
var testSessionList = new List<ITestSession>();
@ -437,6 +437,14 @@ namespace xunit.runner.wpf.ViewModel
FilterAfterDelay();
}
private void OnTraitsClear()
{
foreach (var cur in this.traitCollectionView.Collection)
{
cur.IsSelected = false;
}
}
public bool IncludePassedTests
{
get { return searchQuery.IncludePassedTests; }

Просмотреть файл

@ -9,13 +9,19 @@ namespace xunit.runner.wpf.ViewModel
{
public sealed class TraitViewModel : ViewModelBase
{
public readonly string _name;
public readonly string _value;
private readonly string _name;
private readonly string _value;
private bool _isSelected;
public string Name => _name;
public string Value => _value;
public string DisplayName => $"{Name}={Value}";
public bool IsSelected { get; set; }
public bool IsSelected
{
get { return _isSelected; }
set { Set(ref _isSelected, value, nameof(IsSelected)); }
}
public TraitViewModel(string name, string value)
{