public void ProgressControllerViewModel_AllPublicPropertiesNotifyChanges() { ProgressControllerViewModel model = new ProgressControllerViewModel(); ProgressStepViewModel step = new ProgressStepViewModel(); model.Steps.Add(step); ViewModelVerifier.RunVerificationTest <ProgressControllerViewModel, string>(model, "Title", "value1", "value2"); ViewModelVerifier.RunVerificationTest <ProgressControllerViewModel, ProgressStepViewModel>(model, "Current", null, step); ViewModelVerifier.RunVerificationTest <ProgressControllerViewModel, bool>(model, "Cancellable", true, false); ViewModelVerifier.RunVerificationTest <ProgressControllerViewModel, ICommand>(model, "CancelCommand", null, new RelayCommand((s) => { })); }
/// <summary> /// Re-hosts all the current observers into the specified <paramref name="host"/> /// </summary> public static void ChangeHost(IProgressControlHost host) { if (host == null) { throw new ArgumentNullException(nameof(host)); } Debug.Assert(ThreadHelper.CheckAccess(), "Expected to be called on the UI thread"); Lazy <ProgressControl> visualizer = new Lazy <ProgressControl>(() => VisualizeInHost(host)); observedControllersMap.ToList().ForEach(kv => { if (!kv.Value.IsFinished) { ProgressControllerViewModel state = kv.Value.State; kv.Value.Dispose(); // Dispose previous observer observedControllersMap[kv.Key] = CreateObserver(kv.Key, visualizer.Value, state); } }); }
internal ProgressObserver(IServiceProvider serviceProvider, IProgressVisualizer host, IProgressEvents progressEvents, ProgressControllerViewModel state) { // Event registration must be on the UI thread ThreadHelper.ThrowIfNotOnUIThread(); if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } Debug.Assert(progressEvents.Steps != null, "Expected to be initialized"); this.serviceProvider = serviceProvider; this.host = host; this.progressEvents = progressEvents; this.progressEvents.Started += this.ControllerStarted; this.progressEvents.Finished += this.ControllerFinished; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; this.progressEvents.CancellationSupportChanged += this.OnCancellationSupportChanged; this.viewModelRoot = state ?? new ProgressControllerViewModel(); this.InitializeStepViewModels(); this.host.ViewModel = this.viewModelRoot; }
public void Reset() { this.viewModel = new ProgressControllerViewModel(); this.IsShown = false; }
private static ProgressObserver CreateAndConfigureInstance(IServiceProvider serviceProvider, IProgressVisualizer visualizer, IProgressEvents progressEvents, ICommand cancelCommand, ProgressControllerViewModel state) { return(VsThreadingHelper.RunInline(serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { ProgressObserver returnValue = new ProgressObserver(serviceProvider, visualizer, progressEvents, state); returnValue.CancelCommand = cancelCommand; return returnValue; }, null)); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedProgressEvents(progressEvents); ProgressObserver observer = CreateAndConfigureInstance(serviceProvider, visualizer, progressEvents, null, state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return(observer); }
public static ProgressObserver StartObserving(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedController(controller); ProgressObserver observer = CreateAndConfigureInstance((IServiceProvider)controller, visualizer, controller.Events, new RelayCommand((s) => controller.TryAbort()), state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return(observer); }
private static ProgressObserver CreateObserver(IProgressController controller, IProgressVisualizer visualizer, ProgressControllerViewModel state) { return(ProgressObserver.StartObserving(controller, visualizer, state)); }
private void CreateTestSubject(ProgressControllerViewModel state = null) { this.testSubject = new ProgressObserver(this.testServiceProvider, this.testVisualizer, this.progressEvents, state); this.VerifyNonDisposedAndRegistered(); }