public DynamicColumnManagementViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog, IDynamicColumnManagementService service, BindableCollection <DynamicColumn> columnsCollection, BindableCollection <IToolBarItem> toolBarItemsCollection, Func <DynamicColumnEditViewModel> editViewModelFactory, IToolBarService toolBarService) : base(log, scheduler, standardDialog) { _service = service; _editViewModelFactory = editViewModelFactory; Disposables.Add(service); Columns = columnsCollection; ToolBarItems = toolBarItemsCollection; var saveToolBarItem = toolBarService.CreateToolBarButtonItem(); saveToolBarItem.DisplayName = "Save"; _saveCommand = new DelegateCommand(() => { ClosingStrategy.Close(); }); saveToolBarItem.Command = _saveCommand; ToolBarItems.Add(saveToolBarItem); var cancelToolBarItem = toolBarService.CreateToolBarButtonItem(); cancelToolBarItem.DisplayName = "Cancel"; cancelToolBarItem.Command = ClosingStrategy.CloseCommand; ToolBarItems.Add(cancelToolBarItem); }
public void Initialise(IViewModel viewModel) { ViewModel = viewModel; var supportClosing = ViewModel as ISupportClosing; if (supportClosing != null) { ShowClose = true; IDisposable closing = null; closing = supportClosing.ClosingStrategy.Closed .Subscribe(x => { if (!_viewModelIsClosed) { _viewModelIsClosed = true; ClosingStrategy.Close(); } if (closing != null) { closing.Dispose(); } }); } }
public void when_Close_is_called_then_Closing_is_called_then_Closed() { var closingStrategy = new ClosingStrategy(new NoOpLogger()); var closingCalled = false; var closedCalled = false; closingStrategy.Closing .Subscribe(_ => { Assert.That(closingCalled, Is.False); Assert.That(closedCalled, Is.False); closingCalled = true; }); closingStrategy.Closing .Subscribe(_ => { Assert.That(closingCalled, Is.True); Assert.That(closedCalled, Is.False); closedCalled = true; }); closingStrategy.Close(); Assert.That(closingCalled, Is.True); Assert.That(closedCalled, Is.True); }
private void Save() { BusyViewModel.ActiveAsync("... Saving Quote ...") .Then(() => _service.SaveQuoteAsync(Model), Scheduler.Task.TPL) .LogException(Log) .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem saving quote"), Scheduler.Task.TPL) .Finally(() => { BusyViewModel.InActive(); ClosingStrategy.Close(); }, Scheduler.Task.TPL); }
public DialogViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog, BindableCollection <DialogItemViewModel <T> > answersCollection) : base(log, scheduler, standardDialog) { Answers = answersCollection; ExecuteCommand = new DelegateCommand <DialogItemViewModel <T> >(x => { SelectedAnswer = x.Response; ClosingStrategy.Close(); }); }