private async void ExecuteRefreshCommandAsync() { CanRefresh = _vbe.HostApplication() != null && _state.IsDirty(); if (!CanRefresh) { return; } await Task.Yield(); IsBusy = true; _state.OnParseRequested(this); }
private async void ExecuteRefreshCommandAsync(object parameter) { CanRefresh = _vbe.HostApplication() != null && _state.IsDirty(); if (!CanRefresh) { return; } await Task.Yield(); IsBusy = true; _logger.Debug("InspectionResultsViewModel.ExecuteRefreshCommand - requesting reparse"); _state.OnParseRequested(this); }
public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List <CommandBase> commands) { _folderHelper = folderHelper; _state = state; _state.StateChanged += ParserState_StateChanged; _state.ModuleStateChanged += ParserState_ModuleStateChanged; _refreshCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => _state.OnParseRequested(this), param => !IsBusy && _state.IsDirty()); _navigateCommand = commands.OfType <UI.CodeExplorer.Commands.NavigateCommand>().SingleOrDefault(); _addTestModuleCommand = commands.OfType <UI.CodeExplorer.Commands.AddTestModuleCommand>().SingleOrDefault(); _addStdModuleCommand = commands.OfType <AddStdModuleCommand>().SingleOrDefault(); _addClassModuleCommand = commands.OfType <AddClassModuleCommand>().SingleOrDefault(); _addUserFormCommand = commands.OfType <AddUserFormCommand>().SingleOrDefault(); _openDesignerCommand = commands.OfType <OpenDesignerCommand>().SingleOrDefault(); _openProjectPropertiesCommand = commands.OfType <OpenProjectPropertiesCommand>().SingleOrDefault(); _renameCommand = commands.OfType <RenameCommand>().SingleOrDefault(); _indenterCommand = commands.OfType <IndentCommand>().SingleOrDefault(); _findAllReferencesCommand = commands.OfType <UI.CodeExplorer.Commands.FindAllReferencesCommand>().SingleOrDefault(); _findAllImplementationsCommand = commands.OfType <UI.CodeExplorer.Commands.FindAllImplementationsCommand>().SingleOrDefault(); _collapseAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseNodes); _expandAllSubnodesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandNodes); _importCommand = commands.OfType <ImportCommand>().SingleOrDefault(); _exportCommand = commands.OfType <ExportCommand>().SingleOrDefault(); _externalRemoveCommand = commands.OfType <RemoveCommand>().SingleOrDefault(); if (_externalRemoveCommand != null) { _removeCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRemoveComand, _externalRemoveCommand.CanExecute); } _printCommand = commands.OfType <PrintCommand>().SingleOrDefault(); _commitCommand = commands.OfType <CommitCommand>().SingleOrDefault(); _undoCommand = commands.OfType <UndoCommand>().SingleOrDefault(); _copyResultsCommand = commands.OfType <CopyResultsCommand>().SingleOrDefault(); _setNameSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { SortByName = (bool)param; SortBySelection = !(bool)param; }); _setSelectionSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => { SortBySelection = (bool)param; SortByName = !(bool)param; }); }
public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List <ICommand> commands) { _folderHelper = folderHelper; _state = state; _state.StateChanged += ParserState_StateChanged; _refreshCommand = new DelegateCommand(param => _state.OnParseRequested(this), param => !IsBusy && _state.IsDirty()); _refreshComponentCommand = commands.OfType <CodeExplorer_RefreshComponentCommand>().FirstOrDefault(); _navigateCommand = commands.OfType <CodeExplorer_NavigateCommand>().FirstOrDefault(); _addTestModuleCommand = commands.OfType <CodeExplorer_AddTestModuleCommand>().FirstOrDefault(); _addStdModuleCommand = commands.OfType <CodeExplorer_AddStdModuleCommand>().FirstOrDefault(); _addClassModuleCommand = commands.OfType <CodeExplorer_AddClassModuleCommand>().FirstOrDefault(); _addUserFormCommand = commands.OfType <CodeExplorer_AddUserFormCommand>().FirstOrDefault(); _openDesignerCommand = commands.OfType <CodeExplorer_OpenDesignerCommand>().FirstOrDefault(); _renameCommand = commands.OfType <CodeExplorer_RenameCommand>().FirstOrDefault(); _indenterCommand = commands.OfType <CodeExplorer_IndentCommand>().FirstOrDefault(); _findAllReferencesCommand = commands.OfType <CodeExplorer_FindAllReferencesCommand>().FirstOrDefault(); _findAllImplementationsCommand = commands.OfType <CodeExplorer_FindAllImplementationsCommand>().FirstOrDefault(); _importCommand = commands.OfType <CodeExplorer_ImportCommand>().FirstOrDefault(); _exportCommand = commands.OfType <CodeExplorer_ExportCommand>().FirstOrDefault(); _externalRemoveCommand = commands.OfType <CodeExplorer_RemoveCommand>().FirstOrDefault(); if (_externalRemoveCommand != null) { _removeCommand = new DelegateCommand(ExecuteRemoveComand, _externalRemoveCommand.CanExecute); } _printCommand = commands.OfType <CodeExplorer_PrintCommand>().FirstOrDefault(); _commitCommand = commands.OfType <CodeExplorer_CommitCommand>().FirstOrDefault(); _undoCommand = commands.OfType <CodeExplorer_UndoCommand>().FirstOrDefault(); _copyResultsCommand = commands.OfType <CodeExplorer_CopyResultsCommand>().FirstOrDefault(); _setNameSortCommand = new DelegateCommand(param => { SortByName = (bool)param; SortBySelection = !(bool)param; }); _setSelectionSortCommand = new DelegateCommand(param => { SortBySelection = (bool)param; SortByName = !(bool)param; }); }
protected override void ExecuteImpl(object parameter) { EnsureRubberduckIsReferencedForEarlyBoundTests(); if (!_state.IsDirty()) { RunTests(); } else { _model.TestsRefreshed += TestsRefreshed; _model.Refresh(); } }
private bool CanExecuteRefreshCommand(object parameter) { return(!Model.IsBusy && _state.IsDirty()); }