Exemple #1
0
        public DeploymentViewModel(
            IDeploymentContext context,
            IOperationContext operationContext,
            IWoaDeployer deployer, UIServices uiServices, AdvancedViewModel advancedViewModel,
            WimPickViewModel wimPickViewModel, IFileSystemOperations fileSystemOperations, IRaspberryPiSettingsService raspberryPiSettingsService,
            IDiskRoot diskRoot)
        {
            this.context                    = context;
            this.deployer                   = deployer;
            this.uiServices                 = uiServices;
            this.advancedViewModel          = advancedViewModel;
            this.wimPickViewModel           = wimPickViewModel;
            this.fileSystemOperations       = fileSystemOperations;
            this.raspberryPiSettingsService = raspberryPiSettingsService;

            var isSelectedWim = wimPickViewModel.WhenAnyObservable(x => x.WimMetadata.SelectedImageObs)
                                .Select(metadata => metadata != null);

            FullInstallWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                 ReactiveCommand.CreateFromTask(Deploy, isSelectedWim), uiServices.ContextDialog, operationContext);
            IsBusyObservable = FullInstallWrapper.Command.IsExecuting;
            isBusyHelper     = IsBusyObservable.ToProperty(this, model => model.IsBusy);

            RefreshDisksCommandWrapper = new CommandWrapper <Unit, IList <IDisk> >(this,
                                                                                   ReactiveCommand.CreateFromTask(diskRoot.GetDisks), uiServices.ContextDialog, operationContext);
            disks = RefreshDisksCommandWrapper.Command
                    .Select(x => x.Select(disk => new DiskViewModel(disk)))
                    .ToProperty(this, x => x.Disks);

            this.WhenAnyValue(x => x.SelectedDisk).Where(x => x != null).Subscribe(x => context.Device = new RaspberryPi(x.IDisk));
        }
        public AdvancedViewModel(IRaspberryPiSettingsService raspberryPiSettingsService, IFileSystemOperations fileSystemOperations,
                                 UIServices uiServices, IDeploymentContext context, IOperationContext operationContext,
                                 ILogCollector logCollector)
        {
            this.raspberryPiSettingsService = raspberryPiSettingsService;
            this.uiServices   = uiServices;
            this.context      = context;
            this.logCollector = logCollector;

            DeleteDownloadedWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                      ReactiveCommand.CreateFromTask(() => DeleteDownloaded(fileSystemOperations)), uiServices.ContextDialog, operationContext);

            CollectLogsCommmandWrapper = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(CollectLogs), uiServices.ContextDialog, operationContext);

            IsBusyObservable = Observable.Merge(DeleteDownloadedWrapper.Command.IsExecuting,
                                                CollectLogsCommmandWrapper.Command.IsExecuting);
        }