Skip to content

Commit 76f3914

Browse files
committed
Bind CodeMetrics CommandMenuItem and related
1 parent 12b49bc commit 76f3914

File tree

9 files changed

+2170
-19
lines changed

9 files changed

+2170
-19
lines changed

RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ public class CodeMetricsViewModel : ViewModelBase
1212
{
1313
private readonly RubberduckParserState _state;
1414

15-
public CodeMetricsViewModel(RubberduckParserState state, List<CommandBase> commands, ICodeMetricsAnalyst analyst)
15+
public CodeMetricsViewModel(RubberduckParserState state, ICodeMetricsAnalyst analyst)
1616

1717
{
1818
_state = state;
19-
var reparseCommand = commands.OfType<ReparseCommand>().SingleOrDefault();
20-
RefreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(),
21-
reparseCommand == null ? (Action<object>)(o => { }) :
22-
o => reparseCommand.Execute(o),
23-
o => !IsBusy && reparseCommand != null && reparseCommand.CanExecute(o));
24-
19+
// FIXME deregister event on destruction
2520
_state.StateChanged += (_, change) =>
2621
{
2722
if (change.State == ParserState.Ready)
@@ -47,7 +42,7 @@ private set
4742
}
4843

4944

50-
public CommandBase RefreshCommand { get; set; }
45+
//public CommandBase RefreshCommand { get; set; }
5146

5247

5348
private bool _canSearch;

RetailCoder.VBE/Root/RubberduckIoCInstaller.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
4444
using Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract;
4545
using Component = Castle.MicroKernel.Registration.Component;
46+
using Rubberduck.UI.CodeMetrics;
47+
using Rubberduck.Navigation.CodeMetrics;
4648

4749
namespace Rubberduck.Root
4850
{
@@ -463,6 +465,7 @@ private static Type[] NavigateMenuItems()
463465
#if DEBUG
464466
typeof(RegexSearchReplaceCommandMenuItem),
465467
#endif
468+
466469
typeof(FindSymbolCommandMenuItem),
467470
typeof(FindAllReferencesCommandMenuItem),
468471
typeof(FindAllImplementationsCommandMenuItem)
@@ -486,6 +489,7 @@ private Type[] ToolsMenuItems()
486489
{
487490
typeof(RegexAssistantCommandMenuItem),
488491
typeof(ToDoExplorerCommandMenuItem),
492+
typeof(CodeMetricsCommandMenuItem),
489493
typeof(ExportAllCommandMenuItem)
490494
};
491495

@@ -598,6 +602,12 @@ private void RegisterCommandsWithPresenters(IWindsorContainer container)
598602
.LifestyleTransient()
599603
.Named(typeof(CodeExplorerCommand).Name));
600604

605+
container.Register(Component.For<CommandBase>()
606+
.ImplementedBy<CodeMetricsCommand>()
607+
.DependsOn(Dependency.OnComponent<IDockablePresenter, CodeMetricsDockablePresenter>())
608+
.LifestyleSingleton()
609+
.Named(typeof(CodeMetricsCommand).Name));
610+
601611
container.Register(Component.For<CommandBase>()
602612
.ImplementedBy<ToDoExplorerCommand>()
603613
.DependsOn(Dependency.OnComponent<IDockablePresenter, ToDoExplorerDockablePresenter>())

RetailCoder.VBE/UI/CodeMetrics/CodeMetricsControl.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ResxExtension.DefaultResxName="Rubberduck.UI.RubberduckUI"
1111
Language="{UICulture}"
1212
Name="CodeMetrics"
13-
mc:Ignorable="d"
13+
mc:Ignorable="d"
1414
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance codeMetrics:CodeMetricsViewModel}">
1515
<UserControl.Resources>
1616
<ResourceDictionary>
@@ -100,15 +100,15 @@
100100

101101
<Grid UseLayoutRounding="True">
102102
<Grid.RowDefinitions>
103-
<RowDefinition Height="30"/>
103+
<!--<RowDefinition Height="30"/>-->
104104
<RowDefinition Height="20"/>
105105
<RowDefinition Height="*" MinHeight="64" />
106106
</Grid.RowDefinitions>
107107

108-
<ToolBarTray Grid.Row="0" IsLocked="True">
108+
<!--<ToolBarTray Grid.Row="0" IsLocked="True">
109109
<ToolBar Style="{DynamicResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
110110
111-
<Button Command="{Binding RefreshCommand}">
111+
<Button>
112112
<Image Height="16" Source="../../Resources/arrow-circle-double.png">
113113
<Image.Style>
114114
<Style TargetType="Image">
@@ -125,7 +125,7 @@
125125
</Button.ToolTip>
126126
</Button>
127127
</ToolBar>
128-
</ToolBarTray>
128+
</ToolBarTray>-->
129129

130130
<Border Grid.Row="1"
131131
BorderBrush="{StaticResource {x:Static SystemColors.ControlBrushKey}}"

RetailCoder.VBE/UI/CodeMetrics/CodeMetricsWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace Rubberduck.UI.CodeMetrics
77
[ExcludeFromCodeCoverage]
88
public partial class CodeMetricsWindow : UserControl, IDockableUserControl
99
{
10-
private const string ClassId = "C5318B59-172F-417C-88E3-B377CDA2D80A";
11-
string IDockableUserControl.ClassId { get { return ClassId; } }
12-
string IDockableUserControl.Caption { get { return RubberduckUI.CodeExplorerDockablePresenter_Caption; } }
10+
private const string ClassId = "C5318B5A-172F-417C-88E3-B377CDA2D809";
11+
string IDockableUserControl.ClassId => ClassId;
12+
string IDockableUserControl.Caption => RubberduckUI.CodeMetricsDockablePresenter_Caption;
1313

1414
private CodeMetricsWindow()
1515
{

RetailCoder.VBE/UI/Command/MenuItems/CodeMetricsCommandMenuItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Rubberduck.UI.Command.MenuItems
55
{
6-
class CodeMetricsCommandMenuItem : CommandMenuItemBase
6+
public class CodeMetricsCommandMenuItem : CommandMenuItemBase
77
{
88
public CodeMetricsCommandMenuItem(CommandBase command)
99
: base(command)
@@ -12,6 +12,6 @@ public CodeMetricsCommandMenuItem(CommandBase command)
1212
public override bool EvaluateCanExecute(RubberduckParserState state) => true;
1313

1414
public override string Key => "RubberduckMenu_CodeMetrics";
15-
public override int DisplayOrder => (int)NavigationMenuItemDisplayOrder.CodeMetrics;
15+
public override int DisplayOrder => (int)ToolsMenuItemDisplayOrder.CodeMetrics;
1616
}
1717
}

RetailCoder.VBE/UI/Command/MenuItems/ParentMenus/NavigateParentMenu.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public enum NavigationMenuItemDisplayOrder
1616
{
1717
CodeExplorer,
1818
RegexSearchReplace,
19-
CodeMetrics,
2019
FindSymbol,
2120
FindAllReferences,
2221
FindImplementations

RetailCoder.VBE/UI/Command/MenuItems/ParentMenus/ToolsParentMenu.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public ToolsParentMenu(IEnumerable<IMenuItem> items)
1515
public enum ToolsMenuItemDisplayOrder
1616
{
1717
SourceControl,
18+
CodeMetrics,
1819
ToDoExplorer,
1920
RegexAssistant,
2021
ExportAll,

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,4 +2131,10 @@ Would you like to import them to Rubberduck?</value>
21312131
<data name="AboutWindow_CopyVersionMessage" xml:space="preserve">
21322132
<value>Version information copied to clipboard.</value>
21332133
</data>
2134+
<data name="CodeMetricsDockablePresenter_Caption" xml:space="preserve">
2135+
<value>Code Metrics</value>
2136+
</data>
2137+
<data name="RubberduckMenu_CodeMetrics" xml:space="preserve">
2138+
<value>Code Metrics</value>
2139+
</data>
21342140
</root>

0 commit comments

Comments
 (0)