Skip to content

Commit 7086c4c

Browse files
committed
Add collapse/expand all commands to CodeExplorer
1 parent a1f784d commit 7086c4c

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public CodeExplorerViewModel(
7777
CollapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes, EvaluateCanSwitchNodeState);
7878
ExpandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes, EvaluateCanSwitchNodeState);
7979
ClearSearchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteClearSearchCommand);
80+
CollapseAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAllCommand);
81+
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAllCommand);
8082
if (_externalRemoveCommand != null)
8183
{
8284
RemoveCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRemoveCommand, _externalRemoveCommand.CanExecute);
@@ -345,6 +347,22 @@ private void ExecuteClearSearchCommand(object parameter)
345347
}
346348
}
347349

350+
private void ExecuteCollapseAllCommand(object parameter)
351+
{
352+
foreach (var project in Projects)
353+
{
354+
ExecuteCollapseNodes(project);
355+
}
356+
}
357+
358+
private void ExecuteExpandAllCommand(object parameter)
359+
{
360+
foreach (var project in Projects)
361+
{
362+
ExecuteExpandNodes(project);
363+
}
364+
}
365+
348366
private bool EvaluateCanSwitchNodeState(object parameter)
349367
{
350368
return SelectedItem?.Children?.Any() ?? false;
@@ -420,7 +438,10 @@ private void ExecuteRemoveCommand(object param)
420438

421439
public CodeExplorerMoveToFolderDragAndDropCommand MoveToFolderDragAndDropCommand { get; set; }
422440

423-
public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
441+
public CommandBase CollapseAllCommand { get; }
442+
public CommandBase ExpandAllCommand { get; }
443+
444+
public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
424445
{
425446
if (declaration == null)
426447
{

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ResourceDictionary.MergedDictionaries>
2222

2323
<CollectionViewSource x:Key="BuiltInTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding BuiltInTemplates}" />
24-
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding UserDefinedTemplates}" />
24+
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="UserDefinedTemplatesView" Source="{Binding UserDefinedTemplates}" />
2525
<CollectionViewSource x:Key="AnnotationsViewSource" x:Name="AnnotationsView" Source="{Binding Annotations}" />
2626

2727
<BitmapImage x:Key="RefreshImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/arrow-circle-double.png" />
@@ -47,6 +47,8 @@
4747
<BitmapImage x:Key="SyncImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Custom/PNG/SyncArrows.png" />
4848
<BitmapImage x:Key="FontSizeImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/edit-size.png" />
4949
<BitmapImage x:Key="ExtractInterfaceImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Custom/PNG/ExtractInterface.png" />
50+
<BitmapImage x:Key="CollapseAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/collapse-all.png" />
51+
<BitmapImage x:Key="ExpandAllImage" UriSource="pack://application:,,,/Rubberduck.Resources;component/Icons/Fugue/expand-all.png" />
5052

5153
<converters:BooleanToNullableDoubleConverter x:Key="BoolToDouble" />
5254
<converters:TemplateCommandParameterToTupleConverter x:Key="TemplateCommandParameterToTuple" />
@@ -381,6 +383,19 @@
381383
</i:Interaction.Behaviors>
382384
</MenuItem>
383385
</Menu>
386+
387+
<Separator />
388+
389+
<Button Name="CollapseAll" Command="{Binding CollapseAllCommand}" Margin="2"
390+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_CollapseAll}">
391+
<Image Source="{StaticResource CollapseAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
392+
</Button>
393+
394+
<Button Name="ExpandAll" Command="{Binding ExpandAllCommand}" Margin="2"
395+
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_ExpandAll}">
396+
<Image Source="{StaticResource ExpandAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
397+
</Button>
398+
384399
</ToolBar>
385400
</ToolBarTray>
386401

0 commit comments

Comments
 (0)