Skip to content

Commit

Permalink
Fixes #85: Elements that should be hidden are now not only hidden in …
Browse files Browse the repository at this point in the history
…the few, but filtered in the grid. By filtering the grid we are also able to hide groups that are empty.
  • Loading branch information
StefanKert committed Jul 17, 2020
1 parent 5063f67 commit 6e719ff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
17 changes: 1 addition & 16 deletions src/BuildVision.UI/Components/ProjectGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,7 @@
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridRowOnPreviewMouseLeftButtonDown" />

<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Value="{x:Static contracts:ProjectState.UpToDate}" Binding="{Binding Path=State}"/>
<Condition Binding="{Binding Path=DataContext.ControlSettings.GeneralSettings.HideUpToDateTargets, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProjectGrid}}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed"/>
</MultiDataTrigger>

<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Value="{x:Static contracts:ProjectState.Pending}" Binding="{Binding Path=State}"/>
<Condition Binding="{Binding Path=DataContext.ControlSettings.GeneralSettings.FillProjectListOnBuildBegin, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProjectGrid}}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed"/>
</MultiDataTrigger>


<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource ObjectsReferencesEqualsConverter}">
Expand Down
38 changes: 35 additions & 3 deletions src/BuildVision.UI/ViewModels/BuildVisionPaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,35 @@ public class BuildVisionPaneViewModel : BindableBase, IBuildVisionPaneViewModel
public bool HideUpToDateTargets
{
get => ControlSettings.GeneralSettings.HideUpToDateTargets;
set => SetProperty(() => ControlSettings.GeneralSettings.HideUpToDateTargets, val => ControlSettings.GeneralSettings.HideUpToDateTargets = val, value);
set
{
SetProperty(() => ControlSettings.GeneralSettings.HideUpToDateTargets, val => ControlSettings.GeneralSettings.HideUpToDateTargets = val, value);
ResetProjectListFilter();
}
}

private void ResetProjectListFilter()
{
if (ControlSettings.GeneralSettings.HideUpToDateTargets || !ControlSettings.GeneralSettings.FillProjectListOnBuildBegin)
{
GroupedProjectsList.Filter = x =>
{
var projectItem = x as ProjectItem;
if (ControlSettings.GeneralSettings.HideUpToDateTargets && projectItem.State == ProjectState.UpToDate)
{
return false;
}
if (!ControlSettings.GeneralSettings.FillProjectListOnBuildBegin && projectItem.State == ProjectState.Pending)
{
return false;
}
return true;
};
}
else
{
GroupedProjectsList.Filter = null;
}
}

public ControlSettings ControlSettings { get; }
Expand All @@ -80,7 +108,10 @@ public string GridGroupPropertyName
{
ControlSettings.GridSettings.GroupName = value;
GroupedProjectsList.GroupDescriptions.Clear();
GroupedProjectsList.GroupDescriptions.Add(new PropertyGroupDescription(value));
if (!string.IsNullOrEmpty(value))
{
GroupedProjectsList.GroupDescriptions.Add(new PropertyGroupDescription(value));
}
OnPropertyChanged(nameof(GridGroupPropertyName));
OnPropertyChanged(nameof(GridColumnsGroupMenuItems));
OnPropertyChanged(nameof(GridGroupHeaderName));
Expand Down Expand Up @@ -199,8 +230,8 @@ public BuildVisionPaneViewModel(
SolutionModel = solutionProvider.GetSolutionModel();
ControlSettings = settingsProvider.Settings;
Projects = _buildInformationProvider.Projects;

GroupedProjectsList = CollectionViewSource.GetDefaultView(Projects) as ListCollectionView;
ResetProjectListFilter();
if (!string.IsNullOrWhiteSpace(GridGroupPropertyName))
{
GroupedProjectsList.GroupDescriptions.Add(new PropertyGroupDescription(GridGroupPropertyName));
Expand Down Expand Up @@ -288,6 +319,7 @@ public void OnControlSettingsChanged()
// Raise all properties have changed.
OnPropertyChanged(null);
_taskBarInfoService.ResetTaskBarInfo(false);
ResetProjectListFilter();
}

private bool IsProjectItemEnabledForActions() => SelectedProjectItem != null && !string.IsNullOrEmpty(SelectedProjectItem.UniqueName) && !SelectedProjectItem.IsBatchBuildProject;
Expand Down

0 comments on commit 6e719ff

Please sign in to comment.