public ShellViewModel(DossierViewModel dossierViewModel, BusyWatcher busyWatcher, IApplicationService applicationService, IDecoratorService decoratorService, IFileService fileService, IDialogService dialogService, IWindowManager windowManager) { this._dossierViewModel = dossierViewModel; this._busyWatcher = busyWatcher; this._applicationService = applicationService; this._decoratorService = decoratorService; this._fileService = fileService; this._dialogService = dialogService; this._windowManager = windowManager; this._busyWatcher.BusyChanged += (sender, e) => { IsBusy = this._busyWatcher.IsBusy; }; this._currentDossier = this._decoratorService.Decorate(new Dossier()); this._dossierViewModel.Dossier = this._currentDossier; ActivateItem(this._dossierViewModel); this._dossierViewModel.ModelChanged += (sender, e) => IsModelDirty = true; UpdateDisplayName(); }
/// <summary> /// Creates a new dossier. /// </summary> public IEnumerable <IResult> CreateNewDossierAsync() { bool isCurrentDossierClosable = false; yield return(CloseDossierAsync(canClose => isCurrentDossierClosable = canClose).AsSequentialResult()); if (!isCurrentDossierClosable) { yield break; } this._currentDossier = this._decoratorService.Decorate(new Dossier()); this._dossierViewModel.Dossier = this._currentDossier; CurrentFileName = null; IsModelDirty = false; }
public DossierViewModel([ImportMany] IEnumerable <IDossierScreen> dossierScreens, IDecoratorService decoratorService) { this._dossier = decoratorService.Decorate(new Dossier()); Items.AddRange(dossierScreens.OrderBy(screen => screen.Order)); ActivateItem(Items.FirstOrDefault()); foreach (var dossierScreen in Items) { var reportingScreen = dossierScreen as IReportModelChanges; if (reportingScreen != null) { reportingScreen.ModelChanged += OnReportingScreenModelChanged; } } }
/// <summary> /// Opens a dossier. /// </summary> public IEnumerable <IResult> OpenDossierAsync() { bool isCurrentDossierClosable = false; yield return(CloseDossierAsync(canClose => isCurrentDossierClosable = canClose).AsSequentialResult()); if (!isCurrentDossierClosable) { yield break; } using (Stream stream = this._fileService.Open()) { if (stream == null) { yield break; } using (this._busyWatcher.GetTicket()) { IResult <Dossier> dossierOp = DossierSerializer.LoadFromAsync(stream, exception => ShowErrorDialog(exception, Resources.UnableToOpen)); yield return(dossierOp); var decoratedDossierOp = new AsyncResult <DossierDecorator>(() => this._decoratorService.Decorate(dossierOp.Result)); yield return(decoratedDossierOp); this._currentDossier = decoratedDossierOp.Result; this._dossierViewModel.Dossier = this._currentDossier; CurrentFileName = this._fileService.LastFile; IsModelDirty = false; } } }