Skip to content

Commit 6ec32a6

Browse files
committed
Add buttons to expand and collapse all groups. Closes #3960
1 parent 6c8d56e commit 6ec32a6

File tree

8 files changed

+79
-7
lines changed

8 files changed

+79
-7
lines changed

Rubberduck.Core/UI/Controls/GroupingGrid.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
<Setter Property="Template">
6161
<Setter.Value>
6262
<ControlTemplate>
63-
<Expander Background="WhiteSmoke" Foreground="Black" FontWeight="SemiBold" IsExpanded="True">
63+
<Expander Background="WhiteSmoke" Foreground="Black" FontWeight="SemiBold"
64+
IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:GroupingGrid}}}">
6465
<Expander.Header>
6566
<StackPanel Orientation="Horizontal">
6667
<TextBlock Margin="4"

Rubberduck.Core/UI/Controls/GroupingGrid.xaml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ namespace Rubberduck.UI.Controls
77
public partial class GroupingGrid
88
{
99
public static readonly DependencyProperty ShowGroupingItemCountProperty =
10-
DependencyProperty.Register("ShowGroupingItemCount", typeof (bool), typeof (GroupingGrid));
10+
DependencyProperty.Register("ShowGroupingItemCount", typeof (bool), typeof(GroupingGrid));
11+
12+
public static readonly DependencyProperty IsExpandedProperty =
13+
DependencyProperty.Register("IsExpanded", typeof(bool), typeof(GroupingGrid));
1114

1215
public bool ShowGroupingItemCount
1316
{
1417
get => (bool) GetValue(ShowGroupingItemCountProperty);
1518
set => SetValue(ShowGroupingItemCountProperty, value);
1619
}
1720

21+
public bool IsExpanded
22+
{
23+
get => (bool)GetValue(IsExpandedProperty);
24+
set => SetValue(IsExpandedProperty, value);
25+
}
26+
1827
public GroupingGrid()
1928
{
2029
InitializeComponent();

Rubberduck.Core/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
<ResourceDictionary Source="../Controls/ToolBar.xaml"/>
1818
</ResourceDictionary.MergedDictionaries>
1919

20-
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
21-
2220
<codeInspections:InspectionSeverityImageSourceConverter x:Key="SeverityIconConverter" />
2321
<codeInspections:InspectionImageSourceConverter x:Key="InspectionIconConverter" />
24-
<codeInspections:InspectionTypeConverter x:Key="InspectionTypeConverter" />
2522

2623
<Style x:Key="IconMargin" TargetType="Image">
2724
<Setter Property="Margin" Value="4" />
@@ -41,7 +38,10 @@
4138
<BitmapImage x:Key="FilterBySuggestionImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/information.png" />
4239
<BitmapImage x:Key="FilterByWarningImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/exclamation.png" />
4340
<BitmapImage x:Key="FilterByErrorImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/cross-circle.png" />
44-
41+
42+
<BitmapImage x:Key="ExpandAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/expand-all.png" />
43+
<BitmapImage x:Key="CollapseAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/collapse-all.png" />
44+
4545
<Style TargetType="Image">
4646
<Setter Property="Height" Value="16"/>
4747
<Setter Property="Width" Value="16" />
@@ -161,6 +161,18 @@
161161

162162
<Separator />
163163

164+
<Button Name="CollapseAll" Command="{Binding CollapseAllCommand}" Margin="2"
165+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_CollapseAll}">
166+
<Image Source="{StaticResource CollapseAllImage}" />
167+
</Button>
168+
169+
<Button Name="ExpandAll" Command="{Binding ExpandAllCommand}" Margin="2"
170+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_ExpandAll}">
171+
<Image Source="{StaticResource ExpandAllImage}" />
172+
</Button>
173+
174+
<Separator />
175+
164176
<Button Command="{Binding CopyResultsCommand}">
165177
<Image Source="{StaticResource CopyResultsImage}" />
166178
<Button.ToolTip>
@@ -180,6 +192,7 @@
180192
Grid.Row="1"
181193
ShowGroupingItemCount="True"
182194
SelectedItem="{Binding SelectedItem}"
195+
IsExpanded="{Binding IsExpanded, NotifyOnSourceUpdated=True}"
183196
ItemsSource="{Binding Results, NotifyOnSourceUpdated=True}"
184197
VirtualizingPanel.IsVirtualizingWhenGrouping="True">
185198
<DataGrid.Columns>

Rubberduck.Core/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public InspectionResultsViewModel(
111111
QuickFixInAllProjectsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteQuickFixInAllProjectsCommand, _ => SelectedItem != null && _state.Status == ParserState.Ready);
112112
CopyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand, CanExecuteCopyResultsCommand);
113113
OpenInspectionSettings = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
114+
CollapseAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
115+
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);
114116

115117
_configService.SettingsChanged += _configService_SettingsChanged;
116118

@@ -280,6 +282,18 @@ private bool InspectionFilter(IInspectionResult result)
280282
public CommandBase DisableInspectionCommand { get; }
281283
public CommandBase CopyResultsCommand { get; }
282284
public CommandBase OpenInspectionSettings { get; }
285+
public CommandBase CollapseAllCommand { get; }
286+
public CommandBase ExpandAllCommand { get; }
287+
288+
private void ExecuteCollapseAll(object parameter)
289+
{
290+
IsExpanded = false;
291+
}
292+
293+
private void ExecuteExpandAll(object parameter)
294+
{
295+
IsExpanded = true;
296+
}
283297

284298
private void OpenSettings(object param)
285299
{
@@ -328,6 +342,17 @@ public bool Unparsed
328342
}
329343
}
330344

345+
private bool _expanded;
346+
public bool IsExpanded
347+
{
348+
get => _expanded;
349+
set
350+
{
351+
_expanded = value;
352+
OnPropertyChanged();
353+
}
354+
}
355+
331356
private bool _runInspectionsOnReparse;
332357
private void HandleStateChanged(object sender, ParserStateEventArgs e)
333358
{
539 Bytes
Loading
583 Bytes
Loading

Rubberduck.Resources/RubberduckUI.Designer.cs

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/RubberduckUI.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,4 +1499,10 @@ NOTE: Restart is required for the setting to take effect.</value>
14991499
<data name="GroupingStyle_BySeverity" xml:space="preserve">
15001500
<value>By severity</value>
15011501
</data>
1502+
<data name="InspectionResults_CollapseAll" xml:space="preserve">
1503+
<value>Collapse all</value>
1504+
</data>
1505+
<data name="InspectionResults_ExpandAll" xml:space="preserve">
1506+
<value>Expand all</value>
1507+
</data>
15021508
</root>

0 commit comments

Comments
 (0)