Skip to content

Commit

Permalink
Add collapse/expand all commands to CodeExplorer
Browse files Browse the repository at this point in the history
  • Loading branch information
IvenBach committed Apr 20, 2021
1 parent a1f784d commit 7086c4c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
23 changes: 22 additions & 1 deletion Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs
Expand Up @@ -77,6 +77,8 @@ public sealed class CodeExplorerViewModel : ViewModelBase
CollapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes, EvaluateCanSwitchNodeState);
ExpandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes, EvaluateCanSwitchNodeState);
ClearSearchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteClearSearchCommand);
CollapseAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAllCommand);
ExpandAllCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAllCommand);
if (_externalRemoveCommand != null)
{
RemoveCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRemoveCommand, _externalRemoveCommand.CanExecute);
Expand Down Expand Up @@ -345,6 +347,22 @@ private void ExecuteClearSearchCommand(object parameter)
}
}

private void ExecuteCollapseAllCommand(object parameter)
{
foreach (var project in Projects)
{
ExecuteCollapseNodes(project);
}
}

private void ExecuteExpandAllCommand(object parameter)
{
foreach (var project in Projects)
{
ExecuteExpandNodes(project);
}
}

private bool EvaluateCanSwitchNodeState(object parameter)
{
return SelectedItem?.Children?.Any() ?? false;
Expand Down Expand Up @@ -420,7 +438,10 @@ private void ExecuteRemoveCommand(object param)

public CodeExplorerMoveToFolderDragAndDropCommand MoveToFolderDragAndDropCommand { get; set; }

public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
public CommandBase CollapseAllCommand { get; }
public CommandBase ExpandAllCommand { get; }

public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
{
if (declaration == null)
{
Expand Down
17 changes: 16 additions & 1 deletion Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml
Expand Up @@ -21,7 +21,7 @@
</ResourceDictionary.MergedDictionaries>

<CollectionViewSource x:Key="BuiltInTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding BuiltInTemplates}" />
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="BuiltInTemplatesView" Source="{Binding UserDefinedTemplates}" />
<CollectionViewSource x:Key="UserDefinedTemplatesViewSource" x:Name="UserDefinedTemplatesView" Source="{Binding UserDefinedTemplates}" />
<CollectionViewSource x:Key="AnnotationsViewSource" x:Name="AnnotationsView" Source="{Binding Annotations}" />

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

<converters:BooleanToNullableDoubleConverter x:Key="BoolToDouble" />
<converters:TemplateCommandParameterToTupleConverter x:Key="TemplateCommandParameterToTuple" />
Expand Down Expand Up @@ -381,6 +383,19 @@
</i:Interaction.Behaviors>
</MenuItem>
</Menu>

<Separator />

<Button Name="CollapseAll" Command="{Binding CollapseAllCommand}" Margin="2"
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_CollapseAll}">
<Image Source="{StaticResource CollapseAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
</Button>

<Button Name="ExpandAll" Command="{Binding ExpandAllCommand}" Margin="2"
ToolTip="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=InspectionResults_ExpandAll}">
<Image Source="{StaticResource ExpandAllImage}" Style="{StaticResource ToolbarImageOpacity}" />
</Button>

</ToolBar>
</ToolBarTray>

Expand Down

0 comments on commit 7086c4c

Please sign in to comment.