From 840bf6b6aaf92421404f1602de3e672cd7bf65b3 Mon Sep 17 00:00:00 2001 From: Abraham Hosch Date: Tue, 3 May 2016 10:56:37 -0500 Subject: [PATCH 1/7] Fill out bottom bar in Code Explorer. --- .../CodeExplorerCustomFolderViewModel.cs | 8 +++- .../CodeExplorerProjectViewModel.cs | 4 +- .../CodeExplorer/CodeExplorerViewModel.cs | 44 +++++++++++++++---- .../UI/CodeExplorer/CodeExplorerControl.xaml | 24 +++++----- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs index 2b59367af7..ebcac8b37c 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs +++ b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs @@ -11,6 +11,7 @@ namespace Rubberduck.Navigation.CodeExplorer public class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewModel { private readonly string _name; + private readonly string _folderAttribute; private static readonly DeclarationType[] ComponentTypes = { DeclarationType.ClassModule, @@ -19,9 +20,10 @@ public class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewModel DeclarationType.UserForm, }; - public CodeExplorerCustomFolderViewModel(string name, IEnumerable declarations) + public CodeExplorerCustomFolderViewModel(string name, string fullPath, IEnumerable declarations) { - _name = name; + _name = name.Replace("\"", string.Empty); + _folderAttribute = string.Format("@Folder(\"{0}\")", fullPath.Replace("\"", string.Empty)); _collapsedIcon = GetImageSource(resx.folder_horizontal); _expandedIcon = GetImageSource(resx.folder_horizontal_open); @@ -48,6 +50,8 @@ public CodeExplorerCustomFolderViewModel(string name, IEnumerable d } } + public string FolderAttribute { get { return _folderAttribute; } } + public override string Name { get { return _name; } } public override string NameWithSignature { get { return Name; } } diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs index 722570cfbb..26e83f29e8 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs +++ b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs @@ -43,7 +43,7 @@ public CodeExplorerProjectViewModel(Declaration declaration, IEnumerable FindFolders(IEnumerable declarations, char delimiter) { - var root = new CodeExplorerCustomFolderViewModel(string.Empty, new List()); + var root = new CodeExplorerCustomFolderViewModel(string.Empty, string.Empty, new List()); var items = declarations.ToList(); var folders = items.Where(item => ComponentTypes.Contains(item.DeclarationType)) @@ -68,7 +68,7 @@ private static IEnumerable FindFolders(IEnumerable ComponentTypes.Contains(item.DeclarationType) && item.CustomFolder == currentPath).ToList(); - next = new CodeExplorerCustomFolderViewModel(part, items.Where(item => + next = new CodeExplorerCustomFolderViewModel(part, currentPath, items.Where(item => parents.Contains(item) || parents.Any(parent => (item.ParentDeclaration != null && item.ParentDeclaration.Equals(parent)) || item.ComponentName == parent.ComponentName))); node.AddChild(next); diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs index 5dba572a25..c8d99cecfb 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs +++ b/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs @@ -81,6 +81,34 @@ public CodeExplorerViewModel(VBE vbe, private readonly Indenter _indenter; public ICommand NavigateCommand { get { return _navigateCommand; } } + public string Description + { + get + { + if (SelectedItem is CodeExplorerProjectViewModel) + { + return ((CodeExplorerProjectViewModel)SelectedItem).Declaration.DescriptionString; + } + + if (SelectedItem is CodeExplorerComponentViewModel) + { + return ((CodeExplorerComponentViewModel)SelectedItem).Declaration.DescriptionString; + } + + if (SelectedItem is CodeExplorerMemberViewModel) + { + return ((CodeExplorerMemberViewModel)SelectedItem).Declaration.DescriptionString; + } + + if (SelectedItem is CodeExplorerCustomFolderViewModel) + { + return ((CodeExplorerCustomFolderViewModel)SelectedItem).FolderAttribute; + } + + return string.Empty; + } + } + private CodeExplorerItemViewModel _selectedItem; public CodeExplorerItemViewModel SelectedItem { @@ -92,6 +120,7 @@ public CodeExplorerItemViewModel SelectedItem OnPropertyChanged("CanExecuteIndenterCommand"); OnPropertyChanged("CanExecuteRenameCommand"); OnPropertyChanged("CanExecuteFindAllReferencesCommand"); + OnPropertyChanged("Description"); } } @@ -267,21 +296,20 @@ private void ExecuteAddFormCommand(object param) private void ExecuteIndenterCommand(object param) { + if (SelectedItem.QualifiedSelection.HasValue) + { + return; + } + Debug.WriteLine("CodeExplorerViewModel.IndenterCommand"); if (SelectedItem is CodeExplorerProjectViewModel) { - if (SelectedItem.QualifiedSelection.HasValue) - { - _indenter.Indent(SelectedItem.QualifiedSelection.Value.QualifiedName.Project); - } + _indenter.Indent(SelectedItem.QualifiedSelection.Value.QualifiedName.Project); } if (SelectedItem is CodeExplorerComponentViewModel) { - if (SelectedItem.QualifiedSelection.HasValue) - { - _indenter.Indent(SelectedItem.QualifiedSelection.Value.QualifiedName.Component); - } + _indenter.Indent(SelectedItem.QualifiedSelection.Value.QualifiedName.Component); } } diff --git a/RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml b/RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml index 5abd2b04a2..8e5b7f1ffc 100644 --- a/RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml +++ b/RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml @@ -379,20 +379,18 @@ - - - - - - - - - - + + + + + - - + + + +