/// <summary> /// Initializes a new instance of the <see cref="DossierDecorator" /> class. /// </summary> /// <param name="dossier">The <see cref="Dossier" /> to decorate.</param> /// <param name="decoratorService">The <see cref="IDecoratorService" />.</param> public DossierDecorator(Dossier dossier, IDecoratorService decoratorService) { this._decoratorService = decoratorService; Name = dossier.Name; base.RootUnit = this._decoratorService.Decorate(dossier.RootUnit); this._scenarioReportsView = CollectionViewSource.GetDefaultView(base.ScenarioReports) as ListCollectionView; Contract.Assert(this._scenarioReportsView != null); ((INotifyCollectionChanged)this._scenarioReportsView).CollectionChanged += OnScenarioReportsCollectionChanged; foreach (var report in dossier.ScenarioReports) { AddNewReport(this._decoratorService.Decorate(report)); } this._scenarioReportsView.Refresh(); foreach (var unit in UnitsInHierarchy) { unit.PropertyChanged += OnUnitDecoratorPropertyChanged; } }
/// <summary> /// Initializes a new instance of the <see cref="UnitDecorator" /> class. /// </summary> /// <param name="unit">The <see cref="Unit" /> this view model represents.</param> /// <param name="decoratorService">The <see cref="IDecoratorService" />.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="unit" /> or <paramref name="decoratorService" />is a null /// reference. /// </exception> public UnitDecorator(Unit unit, IDecoratorService decoratorService) { Contract.Requires <ArgumentNullException>(unit != null); Contract.Requires <ArgumentNullException>(decoratorService != null); this._decoratorService = decoratorService; Name = unit.Name; IsSpecial = unit.IsSpecial; IsReserve = unit.IsReserve; Type = new KeyValuePair <string, UnitType>(unit.Type.ToDisplayName(), unit.Type); Nationality = new KeyValuePair <string, Nationality>(unit.Nationality.ToDisplayName(), unit.Nationality); this._reportsView = CollectionViewSource.GetDefaultView(base.Reports) as ListCollectionView; Contract.Assert(this._reportsView != null); ((INotifyCollectionChanged)this._reportsView).CollectionChanged += OnReportsCollectionChanged; foreach (var report in unit.Reports) { AddNewReport(this._decoratorService.Decorate(report, this)); } this._reportsView.Refresh(); }
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(); }
public Registration( Type serviceType, Lifetime lifetime, IFactory factory, IDecoratorService decoratorService) { _serviceType = serviceType; _factory = factory; _decoratorService = decoratorService; _lifetime = lifetime; }
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> /// Initializes a new instance of the <see cref="HigherUnitDecorator" /> class. /// </summary> /// <param name="higherUnit">The unit this decorater wraps.</param> /// <param name="decoratorService">The <see cref="IDecoratorService" />.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="higherUnit" /> or <paramref name="decoratorService" />is a null /// reference. /// </exception> public HigherUnitDecorator(HigherUnit higherUnit, IDecoratorService decoratorService) { Contract.Requires <ArgumentNullException>(higherUnit != null); Contract.Requires <ArgumentNullException>(decoratorService != null); this._decoratorService = decoratorService; Name = higherUnit.Name; base.Superior = higherUnit.Superior; foreach (var subordinate in higherUnit.Subordinates) { base.AddSubordinate(this._decoratorService.Decorate(subordinate)); } this._subordinatesView = CollectionViewSource.GetDefaultView(base.Subordinates) as ListCollectionView; Contract.Assert(this._subordinatesView != null); this._subordinatesView.CustomSort = new UnitComparer(); }