19
19
using Rubberduck . VBEditor . SafeComWrappers ;
20
20
using System . Windows ;
21
21
using Rubberduck . Parsing . UIContext ;
22
+ using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
22
23
23
24
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
24
25
// ReSharper disable ExplicitCallerInfoArgument
@@ -33,6 +34,7 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable
33
34
private readonly GeneralSettings _generalSettings ;
34
35
private readonly WindowSettings _windowSettings ;
35
36
private readonly IUiDispatcher _uiDispatcher ;
37
+ private readonly VBEKind _vbeKind ;
36
38
37
39
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
38
40
@@ -42,14 +44,16 @@ public CodeExplorerViewModel(
42
44
List < CommandBase > commands ,
43
45
IConfigProvider < GeneralSettings > generalSettingsProvider ,
44
46
IConfigProvider < WindowSettings > windowSettingsProvider ,
45
- IUiDispatcher uiDispatcher )
47
+ IUiDispatcher uiDispatcher ,
48
+ IVBE vbe )
46
49
{
47
50
_folderHelper = folderHelper ;
48
51
_state = state ;
49
52
_state . StateChanged += HandleStateChanged ;
50
53
_state . ModuleStateChanged += ParserState_ModuleStateChanged ;
51
54
_windowSettingsProvider = windowSettingsProvider ;
52
55
_uiDispatcher = uiDispatcher ;
56
+ _vbeKind = vbe . Kind ;
53
57
54
58
if ( generalSettingsProvider != null )
55
59
{
@@ -68,15 +72,19 @@ public CodeExplorerViewModel(
68
72
o => reparseCommand . Execute ( o ) ,
69
73
o => ! IsBusy && reparseCommand != null && reparseCommand . CanExecute ( o ) ) ;
70
74
71
- OpenCommand = commands . OfType < UI . CodeExplorer . Commands . OpenCommand > ( ) . SingleOrDefault ( ) ;
75
+ OpenCommand = commands . OfType < OpenCommand > ( ) . SingleOrDefault ( ) ;
72
76
OpenDesignerCommand = commands . OfType < OpenDesignerCommand > ( ) . SingleOrDefault ( ) ;
73
77
74
- AddTestModuleCommand = commands . OfType < UI . CodeExplorer . Commands . AddTestModuleCommand > ( ) . SingleOrDefault ( ) ;
75
- AddTestModuleWithStubsCommand = commands . OfType < AddTestModuleWithStubsCommand > ( ) . SingleOrDefault ( ) ;
76
-
78
+ AddVBFormCommand = commands . OfType < AddVBFormCommand > ( ) . SingleOrDefault ( ) ;
79
+ AddMDIFormCommand = commands . OfType < AddMDIFormCommand > ( ) . SingleOrDefault ( ) ;
80
+ AddUserFormCommand = commands . OfType < AddUserFormCommand > ( ) . SingleOrDefault ( ) ;
77
81
AddStdModuleCommand = commands . OfType < AddStdModuleCommand > ( ) . SingleOrDefault ( ) ;
78
82
AddClassModuleCommand = commands . OfType < AddClassModuleCommand > ( ) . SingleOrDefault ( ) ;
79
- AddUserFormCommand = commands . OfType < AddUserFormCommand > ( ) . SingleOrDefault ( ) ;
83
+ AddUserControlCommand = commands . OfType < AddUserControlCommand > ( ) . SingleOrDefault ( ) ;
84
+ AddPropertyPageCommand = commands . OfType < AddPropertyPageCommand > ( ) . SingleOrDefault ( ) ;
85
+ AddUserDocumentCommand = commands . OfType < AddUserDocumentCommand > ( ) . SingleOrDefault ( ) ;
86
+ AddTestModuleCommand = commands . OfType < UI . CodeExplorer . Commands . AddTestModuleCommand > ( ) . SingleOrDefault ( ) ;
87
+ AddTestModuleWithStubsCommand = commands . OfType < AddTestModuleWithStubsCommand > ( ) . SingleOrDefault ( ) ;
80
88
81
89
OpenProjectPropertiesCommand = commands . OfType < OpenProjectPropertiesCommand > ( ) . SingleOrDefault ( ) ;
82
90
RenameCommand = commands . OfType < RenameCommand > ( ) . SingleOrDefault ( ) ;
@@ -90,7 +98,7 @@ public CodeExplorerViewModel(
90
98
91
99
ImportCommand = commands . OfType < ImportCommand > ( ) . SingleOrDefault ( ) ;
92
100
ExportCommand = commands . OfType < ExportCommand > ( ) . SingleOrDefault ( ) ;
93
- ExportAllCommand = commands . OfType < Rubberduck . UI . Command . ExportAllCommand > ( ) . SingleOrDefault ( ) ;
101
+ ExportAllCommand = commands . OfType < ExportAllCommand > ( ) . SingleOrDefault ( ) ;
94
102
95
103
_externalRemoveCommand = commands . OfType < RemoveCommand > ( ) . SingleOrDefault ( ) ;
96
104
if ( _externalRemoveCommand != null )
@@ -511,11 +519,17 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
511
519
512
520
public CommandBase OpenCommand { get ; }
513
521
522
+
523
+ public CommandBase AddVBFormCommand { get ; }
524
+ public CommandBase AddMDIFormCommand { get ; }
525
+ public CommandBase AddUserFormCommand { get ; }
526
+ public CommandBase AddStdModuleCommand { get ; }
527
+ public CommandBase AddClassModuleCommand { get ; }
528
+ public CommandBase AddUserControlCommand { get ; }
529
+ public CommandBase AddPropertyPageCommand { get ; }
530
+ public CommandBase AddUserDocumentCommand { get ; }
514
531
public CommandBase AddTestModuleCommand { get ; }
515
532
public CommandBase AddTestModuleWithStubsCommand { get ; }
516
- public CommandBase AddStdModuleCommand { get ; }
517
- public CommandBase AddClassModuleCommand { get ; }
518
- public CommandBase AddUserFormCommand { get ; }
519
533
520
534
public CommandBase OpenDesignerCommand { get ; }
521
535
public CommandBase OpenProjectPropertiesCommand { get ; }
@@ -552,14 +566,18 @@ private void ExecuteRemoveComand(object param)
552
566
553
567
private bool CanExecuteExportAllCommand => ExportAllCommand . CanExecute ( SelectedItem ) ;
554
568
555
- public Visibility ExportVisibility => CanExecuteExportAllCommand ? Visibility . Collapsed : Visibility . Visible ;
569
+ public Visibility ExportVisibility => _vbeKind == VBEKind . Standalone || CanExecuteExportAllCommand ? Visibility . Collapsed : Visibility . Visible ;
556
570
557
571
public Visibility ExportAllVisibility => CanExecuteExportAllCommand ? Visibility . Visible : Visibility . Collapsed ;
558
572
559
573
public Visibility TreeViewVisibility => Projects == null || Projects . Count == 0 ? Visibility . Collapsed : Visibility . Visible ;
560
574
561
575
public Visibility EmptyUIRefreshMessageVisibility => _isBusy ? Visibility . Hidden : Visibility . Visible ;
562
576
577
+ public Visibility VB6Visibility => _vbeKind == VBEKind . Standalone ? Visibility . Visible : Visibility . Collapsed ;
578
+
579
+ public Visibility VBAVisibility => _vbeKind == VBEKind . Hosted ? Visibility . Visible : Visibility . Collapsed ;
580
+
563
581
public void FilterByName ( IEnumerable < CodeExplorerItemViewModel > nodes , string searchString )
564
582
{
565
583
foreach ( var item in nodes )
0 commit comments