protected override void OnExecute(object parameter) { if (parameter == null) { return; } var node = (CodeExplorerItemViewModel)parameter; if (!node.QualifiedSelection.HasValue && !(node is CodeExplorerCustomFolderViewModel)) { return; } if (node is CodeExplorerProjectViewModel) { var declaration = ((ICodeExplorerDeclarationViewModel)node).Declaration; var componentDeclarations = _state.AllUserDeclarations.Where(c => c.DeclarationType.HasFlag(DeclarationType.Module) && c.Annotations.All(a => a.AnnotationType != AnnotationType.NoIndent) && c.ProjectId == declaration.ProjectId); foreach (var componentDeclaration in componentDeclarations) { _indenter.Indent(_state.ProjectsProvider.Component(componentDeclaration.QualifiedName.QualifiedModuleName)); } } if (node is CodeExplorerCustomFolderViewModel) { var components = node.Items.OfType <CodeExplorerComponentViewModel>() .Select(s => s.Declaration) .Where(d => d.Annotations.All(a => a.AnnotationType != AnnotationType.NoIndent)) .Select(d => _state.ProjectsProvider.Component(d.QualifiedName.QualifiedModuleName)); foreach (var component in components) { _indenter.Indent(component); } } if (node is CodeExplorerComponentViewModel) { _indenter.Indent(_state.ProjectsProvider.Component(node.QualifiedSelection.Value.QualifiedName)); } if (node is CodeExplorerMemberViewModel) { _navigateCommand.Execute(node.QualifiedSelection.Value.GetNavitationArgs()); _indenter.IndentCurrentProcedure(); } }
protected override void OnExecute(object parameter) { if (_state.Status != ParserState.Ready) { return; } var declaration = FindTarget(parameter); if (declaration == null) { return; } var viewModel = CreateViewModel(declaration); if (!viewModel.SearchResults.Any()) { _messageBox.Show(string.Format(RubberduckUI.AllReferences_NoneFound, declaration.IdentifierName), RubberduckUI.Rubberduck, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (viewModel.SearchResults.Count == 1) { _navigateCommand.Execute(viewModel.SearchResults.Single().GetNavigationArgs()); return; } _viewModel.AddTab(viewModel); _viewModel.SelectedTab = viewModel; try { var presenter = _presenterService.Presenter(_viewModel); presenter.Show(); } catch (Exception e) { Logger.Error(e); } }
public static void Go <T>(this INavigateCommand This, string key = null) where T : IRoutableViewModel { This.Execute(RxApp.GetService <T>(key)); }
protected override void OnExecute(object parameter) { // ReSharper disable once PossibleInvalidOperationException _openCommand.Execute(((CodeExplorerItemViewModel)parameter).QualifiedSelection.Value.GetNavitationArgs()); }