public StartupScanEnabledViewModel(IResolver resolver, IRegistryManager registryManager, ILoginsReader loginsReader, Action onCloseOut, bool isAutoShowPopup) : base(resolver, null) { this.onCloseOut = onCloseOut; this.onClose = OnClose; // By default ScanStatus = DefaultProperties.ReturnString("Onboardv4StatusUnknown"); ScanSummary = registryManager.GetScanSummary(); popupViewModel = new ScanPopupNotificationViewModel(resolver, this, OnClose); _currentVM = mainViewModel; bool isScanSummaryEmpty = ScanSummary.Duplicate + ScanSummary.Weak + ScanSummary.Insecure == 0; IsScanSummaryPopupVisible = isAutoShowPopup && !isScanSummaryEmpty; if (IsScanSummaryPopupVisible) { mainViewModel = new ScanNowViewModel(_resolver, OnClose, () => StartScanCommand.Execute(this)); } else { mainViewModel = new ProgressScanViewModel(_resolver, loginsReader, OnClose, OnScanCompleted); } ClosePopup = new RelayCommand((o) => { popupViewModel.LogStep(MarketingActionType.Continue); IsScanSummaryPopupVisible = false; CurrentVM = new ScanNowViewModel(_resolver, OnClose, () => { StartScanCommand.Execute(o); }); }); StartScanCommand = new RelayCommand((o) => { mainViewModel = new ProgressScanViewModel(_resolver, loginsReader, OnClose, OnScanCompleted); var vm = mainViewModel as ProgressScanViewModel; if (vm != null) { CurrentVM = vm; vm.StartScan(); // TODO: better move to View.Loaded event, where animation starts now } } ); if (IsScanSummaryPopupVisible) { } else { Task.Factory.StartNew(() => { StartScanCommand.Execute(this); }); } }
private void OnScanCompleted() { var vm = CurrentVM as ProgressScanViewModel; if (vm != null) { if (vm.Result.ScanList.Length != 0) { mainViewModel = new ScanResultWithItemsViewModel(_resolver, onClose, vm.Result); ScanStatus = DefaultProperties.ReturnString("Onboardv4StatusAtRisk"); } else { mainViewModel = new ScanResultNoItemsViewModel(_resolver, onClose); ScanStatus = DefaultProperties.ReturnString("Onboardv4StatusAtRisk"); } CurrentVM = mainViewModel; } }