Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/MSDIAL5/MsdialGuiApp/Model/Search/KeywordFilterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class KeywordFilterModel : DisposableModelBase

public KeywordFilterModel(string label, KeywordFilteringType type = KeywordFilteringType.IgnoreIfWordIsNull) {
_sem = new SemaphoreSlim(1, 1).AddTo(Disposables);
_keywords = new List<string>();
_keywords = [];
Keywords = _keywords.AsReadOnly();
switch (type) {
case KeywordFilteringType.ExactMatch:
Expand All @@ -33,6 +33,7 @@ public KeywordFilterModel(string label, KeywordFilteringType type = KeywordFilte
_method = new KeepIfWordIsNull();
break;
case KeywordFilteringType.IgnoreIfWordIsNull:
case KeywordFilteringType.None:
default:
_method = new IgnoreIfWordIsNull();
break;
Expand All @@ -56,10 +57,21 @@ public async Task SetKeywordsAsync(IEnumerable<string> keywords, CancellationTok
}
}

public void ClearKeywords() {
_sem.Wait();
try {
SetKeywords([]);
}
finally {
_sem.Release();
}
}

private void SetKeywords(IEnumerable<string> keywords) {
_keywords.Clear();
_keywords.AddRange(keywords);
IsEnabled = _keywords.Count > 0;
OnPropertyChanged(nameof(Keywords));
}

public bool Match(string word) {
Expand Down
14 changes: 14 additions & 0 deletions src/MSDIAL5/MsdialGuiApp/Model/Search/PeakSpotNavigatorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ public string? SelectedAnnotationLabel {
public PeakSpotTagSearchQueryBuilderModel TagSearchQueryBuilder { get; }
public ObservableCollection<PeakFilterModel> PeakFilters { get; } = new ObservableCollection<PeakFilterModel>();

public void ResetFilters() {
foreach (var peakFilterModel in PeakFilters) {
peakFilterModel.CheckedFilter = DisplayFilter.Unset;
}
AmplitudeFilterModel.Reset();
foreach (var valueFilterModel in ValueFilterModels) {
valueFilterModel.Reset();
}
foreach (var keywordFilterModel in KeywordFilterModels) {
keywordFilterModel.ClearKeywords();
}
TagSearchQueryBuilder.Reset();
}

public void RefreshCollectionViews() {
foreach (var view in PeakSpotsCollection) {
view.Refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public bool Excludes {
}
private bool _excludes;

public void Reset() {
Confirmed = false;
LowQualitySpectrum = false;
Misannotation = false;
Coelution = false;
Overannotation = false;
Excludes = false;
}

public PeakSpotTagSearchQuery CreateQuery() {
var tags = new List<PeakSpotTag>();
if (Confirmed) {
Expand Down
6 changes: 6 additions & 0 deletions src/MSDIAL5/MsdialGuiApp/Model/Search/ValueFilterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public bool Contains(double value) {
return Lower <= value && value <= Upper;
}

public void Reset() {
Lower = Minimum;
Upper = Maximum;
IsEnabled = false;
}

public bool IsEnabled {
get => _isEnabled;
set => SetProperty(ref _isEnabled, value);
Expand Down
43 changes: 41 additions & 2 deletions src/MSDIAL5/MsdialGuiApp/View/Dims/DimsAlignmentSpotTableView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,42 @@
<DataTemplate DataType="{x:Type searchvm:KeywordFilterViewModel}">
<StackPanel Margin="5,0,0,0">
<TextBlock Text="{Binding Label, Mode=OneTime}"/>
<TextBox Text="{Binding Keywords.Value, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Grid>
<TextBox Text="{Binding Keywords.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Button Content="&#xE894;"
FontFamily="Segoe MDL2 Assets"
FontSize="6"
Width="12"
Height="12"
Margin="0,0,2,0"
Background="Transparent"
BorderThickness="0"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Command="{Binding ClearCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border"
Property="Background"
Value="#CCC"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down Expand Up @@ -127,6 +161,11 @@
Margin="8,0"
VerticalAlignment="Center" HorizontalAlignment="Left"
Width="128"/>
<Button Content="Reset filter"
Command="{Binding PeakSpotNavigatorViewModel.ResetFiltersCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Width="64"/>
</StackPanel>
</Grid>

Expand Down
43 changes: 41 additions & 2 deletions src/MSDIAL5/MsdialGuiApp/View/Dims/DimsAnalysisPeakTableView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,42 @@
<DataTemplate DataType="{x:Type searchvm:KeywordFilterViewModel}">
<StackPanel Margin="5,0,0,0">
<TextBlock Text="{Binding Label, Mode=OneTime}"/>
<TextBox Text="{Binding Keywords.Value, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Grid>
<TextBox Text="{Binding Keywords.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Button Content="&#xE894;"
FontFamily="Segoe MDL2 Assets"
FontSize="6"
Width="12"
Height="12"
Margin="0,0,2,0"
Background="Transparent"
BorderThickness="0"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Command="{Binding ClearCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border"
Property="Background"
Value="#CCC"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down Expand Up @@ -128,6 +162,11 @@
Margin="8,0"
VerticalAlignment="Center" HorizontalAlignment="Left"
Width="128"/>
<Button Content="Reset filter"
Command="{Binding PeakSpotNavigatorViewModel.ResetFiltersCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Width="64"/>
</StackPanel>
</Grid>

Expand Down
43 changes: 41 additions & 2 deletions src/MSDIAL5/MsdialGuiApp/View/Gcms/GcmsAlignmentSpotTableView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,42 @@
<DataTemplate DataType="{x:Type searchvm:KeywordFilterViewModel}">
<StackPanel Margin="5,0,0,0">
<TextBlock Text="{Binding Label, Mode=OneTime}"/>
<TextBox Text="{Binding Keywords.Value, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Grid>
<TextBox Text="{Binding Keywords.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Button Content="&#xE894;"
FontFamily="Segoe MDL2 Assets"
FontSize="6"
Width="12"
Height="12"
Margin="0,0,2,0"
Background="Transparent"
BorderThickness="0"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Command="{Binding ClearCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border"
Property="Background"
Value="#CCC"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down Expand Up @@ -127,6 +161,11 @@
Margin="8,0"
VerticalAlignment="Center" HorizontalAlignment="Left"
Width="128"/>
<Button Content="Reset filter"
Command="{Binding PeakSpotNavigatorViewModel.ResetFiltersCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Width="64"/>
</StackPanel>
</Grid>

Expand Down
43 changes: 41 additions & 2 deletions src/MSDIAL5/MsdialGuiApp/View/Gcms/GcmsAnalysisPeakTableView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,42 @@
<DataTemplate DataType="{x:Type searchvm:KeywordFilterViewModel}">
<StackPanel Margin="5,0,0,0">
<TextBlock Text="{Binding Label, Mode=OneTime}"/>
<TextBox Text="{Binding Keywords.Value, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Grid>
<TextBox Text="{Binding Keywords.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"/>
<Button Content="&#xE894;"
FontFamily="Segoe MDL2 Assets"
FontSize="6"
Width="12"
Height="12"
Margin="0,0,2,0"
Background="Transparent"
BorderThickness="0"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Command="{Binding ClearCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="10">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border"
Property="Background"
Value="#CCC"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
Expand Down Expand Up @@ -127,6 +161,11 @@
Margin="8,0"
VerticalAlignment="Center" HorizontalAlignment="Left"
Width="128"/>
<Button Content="Reset filter"
Command="{Binding PeakSpotNavigatorViewModel.ResetFiltersCommand, Mode=OneTime, FallbackValue={x:Static commonmvvm:NeverCommand.Instance}}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Width="64"/>
</StackPanel>
</Grid>

Expand Down
Loading
Loading