private void Stop() { if (resumeCommand.CanExecute(null)) { resumeCommand.Execute(null); } crawlerCancellationToken.Cancel(); crawlerService.IsCrawl = false; crawlCommand.RaiseCanExecuteChanged(); pauseCommand.RaiseCanExecuteChanged(); resumeCommand.RaiseCanExecuteChanged(); stopCommand.RaiseCanExecuteChanged(); }
private void ShellViewModelPropertyChanged(object?sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(ShellViewModel.IsValid)) { saveCommand.RaiseCanExecuteChanged(); } }
public ConditionsDefinitionEditorViewModel(Func <IHistoryManager> historyCreator, IConditionDataProvider conditionDataProvider, IWindowManager windowManager, ITaskRunner taskRunner, IParameterFactory parameterFactory) { this.conditionDataProvider = conditionDataProvider; SourceItems = new ObservableCollection <ConditionJsonData>(conditionDataProvider.GetConditions().ToList()); this.windowManager = windowManager; this.parameterFactory = parameterFactory; SelectedIndex = -1; Save = new DelegateCommand(() => { taskRunner.ScheduleTask("Saving conditions definition list", SaveConditions); }, () => IsModified); Delete = new DelegateCommand(DeleteItem); AddItem = new AsyncCommand(AddNewItem); EditItem = new AsyncCommand <ConditionJsonData?>(EditCondition); // history setup historyHandler = new ConditionsEditorHistoryHandler(SourceItems); History = historyCreator(); undoCommand = new DelegateCommand(History.Undo, () => History.CanUndo); redoCommand = new DelegateCommand(History.Redo, () => History.CanRedo); History.PropertyChanged += (sender, args) => { undoCommand.RaiseCanExecuteChanged(); redoCommand.RaiseCanExecuteChanged(); IsModified = !History.IsSaved; }; History.AddHandler(historyHandler); }
private void NavigateBack() { isNavigatingBack = true; SelectedNavigationItem = navigationStack.Pop(); isNavigatingBack = false; navigateBackCommand.RaiseCanExecuteChanged(); }
private async Task SearchConfigAsync() { try { _isSearching = true; var disks = await Task.Run(() => DiskSearcher.Search()); foreach (var disk in disks.Where(x => x.CanBeSD).OrderBy(x => x.PhysicalDrive)) { var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(disk)) { continue; } CurrentConfig = configNew; OperationStatus = Resources.OperationStatus_Found; return; } CurrentConfig = null; OperationStatus = Resources.OperationStatus_No; } finally { _isSearching = false; DelegateCommand.RaiseCanExecuteChanged(); } }
protected void RaiseCanExecuteChanges(DelegateCommand command) { if (command != null) { command.RaiseCanExecuteChanged(); } }
private void DeviceConnection_PortStatusChanged(object sender, bool e) { RaisePropertyChanged(nameof(CanRead)); RaisePropertyChanged(nameof(CanWrite)); _cmdReadFromDevice.RaiseCanExecuteChanged(); _cmdWriteToDevice.RaiseCanExecuteChanged(); }
private void OnCurrentConfigPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(ConfigViewModel.IsChanged)) { DelegateCommand.RaiseCanExecuteChanged(); } }
public async void ExecuteStopCommand() { EndDialog dialog = new EndDialog(); await dialog.ShowAsync(); if (dialog.DiagResult == ContentDialogResult.Primary) { CurrentTripDataRepo.DriveValue = EnumHelper.DeParse(DriveStateStatus.TripCompleted); if (SelectedTripData.IsTripComplete != true) { CurrentTripDataRepo.EndTime = DateTime.Now; upTimer.Stop(); TripSummary.SetBusy(true); SelectedTripData.TripEndTime = CurrentTripDataRepo.EndTime; SelectedTripData.IsTripComplete = true; SelectedTripData.Pay = CurrentTripDataRepo.SelectedPayStatus = dialog.SelectedPayStatus; SelectedTripData.Mode = CurrentTripDataRepo.SelectedPayMode = dialog.SelectedPayMode; tripDataManager.SaveTrip(SelectedTripData); } geoLocationService.PositionChanged -= GeoLocationService_PositionChanged; geoLocationService.StopListening(); StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); GotoHomeTaskCommand.RaiseCanExecuteChanged(); } }
/// <inheritdoc /> protected override void OnIsBusyChanged() { base.OnIsBusyChanged(); _SubmitEditCommand?.RaiseCanExecuteChanged(); _RefetchLastRevisionCommand?.RaiseCanExecuteChanged(); _GenerateSummaryCommand?.RaiseCanExecuteChanged(); }
public ViewModel() { DataRepository = new DataRepository(); _engine = new SynteticDataGenerator( new RealDataImporter(), new FtfTensorCurveImporter(), new ObservatoryDataExporter()); LoadDataCommand = new DelegateCommand(Load); LoadImpedanceCommand = new DelegateCommand(LoadImpedance); LoadGicCommand = new DelegateCommand(LoadGic); SaveDataCommand = new DelegateCommand(SaveData, CanSaveData); SaveSpectraCommand = new DelegateCommand(SaveSpectraData, CanSaveSpectraData); ExportCommand = new DelegateCommand(ExportImage); Status = new CalculationInfoModel(Validation, Calculate); SpectraStatus = new CalculationInfoModel(ValidationSpectra, CalculateSpectra); Status.RaiseValidation(); SpectraStatus.RaiseValidation(); SaveDataCommand.RaiseCanExecuteChanged(); SaveSpectraCommand.RaiseCanExecuteChanged(); DataRepository.SelectedSites.CollectionChanged += SelectedSites_CollectionChanged; DataRepository.All.CollectionChanged += All_CollectionChanged; }
public async void Initialize() { try { await accountService.InitializeAsync(); } catch (Exception ex) { await messageService.ShowMessageDialogAsync(resourceService.GetString("SignInError"), ex.Message); } finally { isInitialized = true; signInCommand.RaiseCanExecuteChanged(); } }
public MainViewModel(IServiceProvider serviceProvider) : base(serviceProvider) { isIntermediate = true; CheckoutAndBuildMainCommand = new DelegateCommand <object>(ExecuteCheckoutAndBuildRun, CanExecuteCheckoutAndBuildRun); PauseCommand = new DelegateCommand <object>(PauseCheckoutAndBuildRun, CanPauseCheckoutAndBuildRun); ResumeCommand = new DelegateCommand <object>(ResumeCheckoutAndBuildRun, CanResumeCheckoutAndBuildRun); CompleteCancelCommand = new DelegateCommand <object>(o => Cancel(), CanCancelCheckoutAndBuildRun); CancelCurrentOperationCommand = new DelegateCommand <object>(o => CancelCurrentOperation(), CanCancelCancelCurrentOperation); GlobalStatusService = serviceProvider.Get <GlobalStatusService>(); ProfileSelectorViewModel = new ProfileSelectorViewModel(serviceProvider); WorkspaceSelectorViewModel = new WorkspaceSelectorViewModel(serviceProvider); GitBranchSelectorViewModel = new GitBranchSelectorViewModel(serviceProvider); BuildSettingsSelectorViewModel = new ServiceSettingsSelectorViewModel(serviceProvider); IncludedWorkingfolderModel = new WorkingFolderListViewModel(serviceProvider); ExcludedWorkingfolderModel = new WorkingFolderListViewModel(serviceProvider); registeredHandlers.Add(this.OnChange(() => HasWorkspaceOrDirectory, b => Update()), this); registeredHandlers.Add(this.OnChange(() => IsBusy, b => { CheckoutAndBuildMainCommand.RaiseCanExecuteChanged(); UpdateStatusBarInfo(false); }), this); registeredHandlers.Add(GlobalStatusService?.OnChange(() => GlobalStatusService.IsActive, b => UpdateStatusBarInfo(true)), GlobalStatusService); registeredHandlers.Add(MainLogic?.OnChange(() => MainLogic.IsCompleteRunning, b => RaisePauseChanged(), true), MainLogic); IncludedWorkingfolderModel.ProjectsChanged += UpdateExcludedLists; ExcludedWorkingfolderModel.ProjectsChanged += UpdateIncludedLists; MainLogic?.OnChange(() => MainLogic.CurrentOperation, service => CancelCurrentOperationCommand.RaiseCanExecuteChanged()); UpdateHeader(); }
public ConfirmActionUserControlViewModel(string message, DelegateCommand command) { ContinueCommand = new DelegateCommand(() => { Hide(); command.Execute(); }); ShowCommand = new DelegateCommand(Reset, () => command.CanExecute()); command.CanExecuteChanged += (s, e) => ShowCommand.RaiseCanExecuteChanged(); Message = message; }
public LoginViewModel(ISettingsHandler settingsHandler, IGoBot goBot) { _settingsHandler = settingsHandler; _goBot = goBot; LoginCommand = DelegateCommand.FromAsyncHandler(Login, CanLogin); LoginTypes = new ObservableCollection <LoginType>(new List <LoginType>() { new LoginType() { LoginAuth = LoginAuth.Google }, new LoginType() { LoginAuth = LoginAuth.PCT } }); SelectedLoginType = LoginTypes.FirstOrDefault(t => t.LoginAuth == _settingsHandler.Settings.LoginAuth); UserName = _settingsHandler.Settings.Username; Password = _settingsHandler.Settings.Password; LoginCommand.RaiseCanExecuteChanged(); _dispatcher = new DispatcherTimer(); _dispatcher.Tick += LoginDispatcher; _dispatcher.Interval = new TimeSpan(0, 0, 1); }
private void OnNeu() { SetNewItem(); SetEditMode(true); CmdNew.RaiseCanExecuteChanged(); }
/// <summary> /// Deletes the current account. /// </summary> private void DeleteAccount() { if ((_index < 0) || (_index >= _accounts.Count)) { _delete.RaiseCanExecuteChanged(); return; } var index = _index; try { _accounts.RemoveAt(index); while (index >= _accounts.Count) { index--; } SelectedIndex = index; } finally { SaveState(); } }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case (nameof(_viewmodel.SelectedZone)): _deleteZoneCommand?.RaiseCanExecuteChanged(); _editZoneCommand?.RaiseCanExecuteChanged(); _addItemCommand?.RaiseCanExecuteChanged(); break; case (nameof(_viewmodel.SelectedItem)): _deleteItemCommand?.RaiseCanExecuteChanged(); _editItemCommand?.RaiseCanExecuteChanged(); _addStatCommand?.RaiseCanExecuteChanged(); break; case (nameof(_viewmodel.SelectedStat)): _deleteStatCommand?.RaiseCanExecuteChanged(); _editStatCommand?.RaiseCanExecuteChanged(); break; default: break; } }
private void OnInstallationFinished(Task task) { _dispatcher.BeginInvoke(() => { string result; if (task.IsFaulted) { result = "failed"; HasFailed = true; ErrorMessage = FormatErrorMessage(task.Exception); } else { _success = true; result = "succeeded"; } _installationTask = null; InstallationResult = result; IsInstalling = false; IsPostInstallation = true; _launchCommand.RaiseCanExecuteChanged(); }); }
private void ShellViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "IsValid") { _saveCommand.RaiseCanExecuteChanged(); } }
private bool _windowClosedBySelf = false; // Tracks whether the window was closed by logic internal // to the command (e.g. not by clicking the window's close button) // Presents the user with a sign-in dialog public override void Execute(object parameter) { // Initialize the viewmodel if not yet done if (viewModel == null) { // Instantiate the viewmodel and sign-in/cancel commands viewModel = new SignInViewModel(); DelegateCommand signInCommand = new DelegateCommand(onSignIn, canSignIn); viewModel.SignIn = signInCommand; viewModel.Cancel = new DelegateCommand(onCancel); // When a property changes on the viewmodel, have the sign-in command check its executable state viewModel.PropertyChanged += (o, e) => signInCommand.RaiseCanExecuteChanged(); // instantiate the view view = new SignInView() { Margin = new Thickness(10) }; // plug the viewmodel into the view view.DataContext = viewModel; } // Prompt for sign-in if (MapApplication.Current != null) MapApplication.Current.ShowWindow(Strings.SignIn, view, true, null, onWindowClosed, WindowType.DesignTimeFloating); }
public void Init(Model model) { InitializeComponent(); try { OnCompleted += () => { disposables.Dispose(); }; /*disposables.Add(Observable.FromEventPattern<MouseWheelEventArgs>(scroll, "PreviewMouseWheel") * .Subscribe(evarg => * { * scroll.ScrollToVerticalOffset(-1 * evarg.EventArgs.Delta); * }) * );*/ listTriggers.ItemsSource = model.triggers; listTriggers.CreateBinding(ListBox.SelectedValueProperty, model, x => x.selection, (m, o) => { m.selection = o; }); var createTriggerCommand = new DelegateCommand( () => Success(new Result.Create(model)), () => true ); createTriggerButton.Command = createTriggerCommand; var deleteTriggerCommand = new DelegateCommand( () => Success(new Result.Delete(model)), () => model.selection != null ); deleteTriggerButton.Command = deleteTriggerCommand; var modifyTriggerCommand = new DelegateCommand( () => Success(new Result.Modify(model)), () => model.selection != null ); modifyTriggerButton.Command = modifyTriggerCommand; disposables.Add( model .GetPropertyChangedEvents(m => m.selection) .Subscribe(v => { modifyTriggerCommand.RaiseCanExecuteChanged(); deleteTriggerCommand.RaiseCanExecuteChanged(); }) ); } catch (Exception err) { dbg.Error(err); } Localization(); }
private void Player_StatusChanged(object sender, EventArgs e) { _playCommand.RaiseCanExecuteChanged(); _pauseCommand.RaiseCanExecuteChanged(); _stopCommand.RaiseCanExecuteChanged(); _setInCommand.RaiseCanExecuteChanged(); _setOutCommand.RaiseCanExecuteChanged(); _goInCommand.RaiseCanExecuteChanged(); _goOutCommand.RaiseCanExecuteChanged(); _nextFrameCommand.RaiseCanExecuteChanged(); _previousFrameCommand.RaiseCanExecuteChanged(); _applyCommand.RaiseCanExecuteChanged(); if (_player.Status == PreviewPlayerStatus.Stopped) { this.RaisePropertyChanged(nameof(this.Position)); } //SetSourceUri(_player.Name); this.RaisePropertyChanged(nameof(this.Seekable)); }
public MultiViewModel() { SelectAllCommand = new DelegateCommand(SelectAll); ClearSelectionCommand = new DelegateCommand(ClearSelection, CanClearSelection); SelectedItems = new ObservableCollection<ItemViewModel>(); SelectedItems.CollectionChanged += (sender, args) => ClearSelectionCommand.RaiseCanExecuteChanged(); }
public SmartDataGroupsEditorViewModel(ISmartRawDataProvider smartDataProvider, ITaskRunner taskRunner, IMessageBoxService messageBoxService, IWindowManager windowManager, Func <IHistoryManager> historyCreator, SmartDataSourceMode dataSourceMode) { this.smartDataProvider = smartDataProvider; this.messageBoxService = messageBoxService; this.windowManager = windowManager; this.dataSourceMode = dataSourceMode; SourceItems = new ObservableCollection <SmartDataGroupsEditorData>(); MakeItems(); AddGroup = new AsyncAutoCommand(AddGroupToSource); Save = new DelegateCommand(() => { taskRunner.ScheduleTask("Saving Group Definitions to file", SaveGroupsToFile); }); DeleteItem = new DelegateCommand <object>(DeleteItemFromSource); AddMember = new AsyncAutoCommand <SmartDataGroupsEditorData>(AddItemToGroup); EditItem = new AsyncAutoCommand <SmartDataGroupsEditorData>(EditSourceItem); // history setup History = historyCreator(); historyHandler = new SmartDataGroupsHistory(SourceItems); UndoCommand = new DelegateCommand(History.Undo, () => History.CanUndo); RedoCommand = new DelegateCommand(History.Redo, () => History.CanRedo); History.PropertyChanged += (sender, args) => { UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); IsModified = !History.IsSaved; RaisePropertyChanged(nameof(IsModified)); }; History.AddHandler(historyHandler); }
private void InvalidateCommands() { ViewChangesetDetailsCommand.RaiseCanExecuteChanged(); ToggleAddByIdCommand.RaiseCanExecuteChanged(); CancelAddChangesetByIdCommand.RaiseCanExecuteChanged(); AddChangesetByIdCommand.RaiseCanExecuteChanged(); }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(IsWorking): _selectOutputPathCommand.RaiseCanExecuteChanged(); _runCommand.RaiseCanExecuteChanged(); _openCommand.RaiseCanExecuteChanged(); break; case nameof(OutputPath): _openCommand.RaiseCanExecuteChanged(); _runCommand.RaiseCanExecuteChanged(); break; } }
public EventsPageViewModel() { SearchCommand = new DelegateCommand(Search, () => CanSearch); UndoFilterCommand = new DelegateCommand(UndoFilter, () => CanUndoFilter); //Get Distances DistanceOptions = new ObservableCollection <int>(); GetDistanceOptions(false); //Get Page sizes PageSizeOptions = new ObservableCollection <int>(); GetPageSizes(false); //Get Categories CategoryOptions = new ObservableCollection <Category>(); CategoryOptions.CollectionChanged += (s, e) => { RaisePropertyChanged(nameof(HasCategoryOptions)); }; GetCategories(true); SearchResults = new ObservableCollection <Result>(); SearchResults.CollectionChanged += (s, e) => { RaisePropertyChanged(nameof(SearchResults)); RaisePropertyChanged(nameof(HasSearchResults)); UndoFilterCommand.RaiseCanExecuteChanged(); }; }
private void GenerateReport() { BusyViewModel.ActiveAsync("... Generating ...") .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL) .Then(() => Service.GenerateAsync(Service.CreateRequest(ParameterViewModel)), Scheduler.Task.TPL) .Do(response => _response = response, Scheduler.Task.TPL) .Then(response => Service.GenerateDataViewModelsAsync(response), Scheduler.Task.TPL) .Do(dataViewModels => { foreach (var dataViewModel in dataViewModels) { Items.Add(dataViewModel); var supportActivationState = dataViewModel as ISupportActivationState; if (supportActivationState != null) { this.SyncViewModelActivationStates(supportActivationState).AddDisposable(Disposables); } } }, Scheduler.Dispatcher.TPL) .LogException(Log) .CatchAndHandle(x => StandardDialog.Error("Error", "Problem Generating Report"), Scheduler.Task.TPL) .Finally(() => { BusyViewModel.InActive(); IsExpanded = false; _exportToExcel.RaiseCanExecuteChanged(); }, Scheduler.Task.TPL); }
public DemoViewModel(IDemoProfileActivator demoListener) { _demoListener = demoListener; _activateIdentityCommand = new DelegateCommand(ActivateIdentity, IsIdentityValid); this.PropertyChanges(vm => vm.Identity).Subscribe(_ => _activateIdentityCommand.RaiseCanExecuteChanged()); }
public void CommandCanExecuteChangedTest() { DelegateCommand command = new DelegateCommand(() => { }); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged()); AssertHelper.ExpectedException<ArgumentNullException>( () => AssertHelper.CanExecuteChangedEvent(null, () => command.RaiseCanExecuteChanged())); AssertHelper.ExpectedException<ArgumentNullException>( () => AssertHelper.CanExecuteChangedEvent(command, null)); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => { })); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => { command.RaiseCanExecuteChanged(); command.RaiseCanExecuteChanged(); })); }
public MainViewModel(NumberDiceViewModel numDiceViewModel, NumberSidesViewModel numSidesViewModel, RollModeViewModel rollModeViewModel, RandomModeViewModel randomModeViewModel) { if (numDiceViewModel == null) throw new ArgumentNullException("numDiceViewModel is null."); if (numSidesViewModel == null) throw new ArgumentNullException("numSidesViewModel is null."); if (rollModeViewModel == null) throw new ArgumentNullException("rollModeViewModel is null."); if (randomModeViewModel == null) throw new ArgumentNullException("randomModeViewModel is null."); SetupPages = new ObservableCollection<IPageViewModel>(); Dice = new ObservableCollection<IDieViewModel>(); Statistics = new ObservableCollection<IStatisticViewModel>(); _rollCommand = new DelegateCommand(x => randomModeViewModel.GeneratorIsReady, x => rollDice()); _numDiceViewModel = numDiceViewModel; _numDiceViewModel.NumberDiceChanged += (sender, e) => onSetupChanged(); SetupPages.Add(_numDiceViewModel); _numSidesViewModel = numSidesViewModel; _numSidesViewModel.NumberSidesChanged += (sender, e) => onSetupChanged(); SetupPages.Add(_numSidesViewModel); _rollModeViewModel = rollModeViewModel; _rollModeViewModel.ModeChanged += (sender, e) => onSetupChanged(); SetupPages.Add(_rollModeViewModel); _randomModeViewModel = randomModeViewModel; _randomModeViewModel.RandomModeChanged += (sender, e) => onSetupChanged(); _randomModeViewModel.Ready += (sender, e) => _rollCommand.RaiseCanExecuteChanged(); _randomModeViewModel.Error += (sender, e) => _rollCommand.RaiseCanExecuteChanged(); // TODO: Add error checking before adding this feature //SetupPages.Add(_randomModeViewModel); onSetupChanged(); }
public void CommandCanExecuteChangedTest2() { var command = new DelegateCommand(() => { }); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => { })); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => { command.RaiseCanExecuteChanged(); command.RaiseCanExecuteChanged(); })); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 0, ExpectedChangedCountMode.Exact)); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 2, ExpectedChangedCountMode.Exact)); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 2, ExpectedChangedCountMode.AtLeast)); AssertHelper.ExpectedException<AssertException>(() => AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 0, ExpectedChangedCountMode.AtMost)); }
public void RaiseCanExecuteChangedTest() { bool executed = false; bool canExecute = false; DelegateCommand command = new DelegateCommand(() => executed = true, () => canExecute); Assert.IsFalse(command.CanExecute()); canExecute = true; Assert.IsTrue(command.CanExecute()); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged()); Assert.IsFalse(executed); }
public PersonEntryViewModel(IPersonEntry person, ISchedulerProvider schedulerProvider) { _person = person; _schedulerProvider = schedulerProvider; SaveCommand = new DelegateCommand(Save, () => !Person.HasErrors && !Person.State.HasError); var errors = Observable.FromEventPattern<EventHandler<DataErrorsChangedEventArgs>, DataErrorsChangedEventArgs>( h => Person.ErrorsChanged += h, h => Person.ErrorsChanged -= h) .Select(_ => Unit.Default); var states = Person.OnPropertyChanges(p => p.State) .Select(_ => Unit.Default); _errorStateSubscription = Observable .Merge(errors, states) .ObserveOn(_schedulerProvider.Dispatcher) .Subscribe(_ => SaveCommand.RaiseCanExecuteChanged()); states.ObserveOn(_schedulerProvider.Dispatcher) .Subscribe(_ => OnPropertyChanged("State")); }
public void CommandCanExecuteChangedTest1() { var command = new DelegateCommand(() => { }); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged()); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 1, ExpectedChangedCountMode.Exact); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 0, ExpectedChangedCountMode.AtLeast); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), 2, ExpectedChangedCountMode.AtMost); AssertHelper.ExpectedException<ArgumentNullException>( () => AssertHelper.CanExecuteChangedEvent(null, () => command.RaiseCanExecuteChanged())); AssertHelper.ExpectedException<ArgumentNullException>( () => AssertHelper.CanExecuteChangedEvent(command, null)); AssertHelper.ExpectedException<ArgumentOutOfRangeException>( () => AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged(), -1, ExpectedChangedCountMode.Exact)); }
void OnLoggedIn(dynamic result) { if (result["Result"].ToObject<bool>()) { m_ServerStatusMetadataSource = result["ServerMetadataSource"].ToObject<List<KeyValuePair<string, StatusInfoAttribute[]>>>(); BuildGridColumns( m_ServerStatusMetadataSource.FirstOrDefault(p => string.IsNullOrEmpty(p.Key)).Value, GetCommonColumns(m_ServerStatusMetadataSource.Where(p => !string.IsNullOrEmpty(p.Key)).Select(c => c.Value).ToArray())); var nodeInfo = DynamicViewModelFactory.Create(result["NodeStatus"].ToString()); GlobalInfo = nodeInfo.BootstrapStatus; var instances = nodeInfo.InstancesStatus as IEnumerable<DynamicViewModel.DynamicViewModel>; Instances = new ObservableCollection<DynamicViewModel.DynamicViewModel>(instances.Select(i => { var startCommand = new DelegateCommand<DynamicViewModel.DynamicViewModel>(ExecuteStartCommand, CanExecuteStartCommand); var stopCommand = new DelegateCommand<DynamicViewModel.DynamicViewModel>(ExecuteStopCommand, CanExecuteStopCommand); var restartCommand = new DelegateCommand<DynamicViewModel.DynamicViewModel>(ExecuteRestartCommand, CanExecuteRestartCommand); i.PropertyChanged += (s, e) => { if (string.IsNullOrEmpty(e.PropertyName) || e.PropertyName.Equals("IsRunning", StringComparison.OrdinalIgnoreCase)) { startCommand.RaiseCanExecuteChanged(); stopCommand.RaiseCanExecuteChanged(); restartCommand.RaiseCanExecuteChanged(); } }; i.Set("StartCommand", startCommand); i.Set("StopCommand", stopCommand); i.Set("RestartCommand", restartCommand); return i; })); State = NodeState.Connected; LastUpdatedTime = DateTime.Now; } else { m_LoginFailed = true; //login failed m_WebSocket.Close(); ErrorMessage = "Logged in failed!"; } }