public ShipAttributesViewModel(IDataLoaderService loader, IEventAggregator eventaggregator, ShipAttributesModel data) { this._data = data; this._loader = loader; this._eventAggregator = eventaggregator; this._eventAggregator.GetEvent<OutfittingChangedEvent>().Subscribe(SaveOutfitting); this._shipout = new ShipOutfittingModel(); this._combinedInternals = new List<InternalModel>(); this.ResetClickCommand = new DelegateCommand(this.OnResetClick); this.SaveHangarClickCommand = new DelegateCommand(this.OnSaveHangarClick); this.SaveFileClickCommand = new DelegateCommand(this.OnSaveFileClick); // Load all Ships and set the first as "seleted this.Data.Ships = _loader.loadShips(); this.SelectedShip = this.Data.Ships[0]; }
public ShipOutfittingViewModel(IDataLoaderService loader, IEventAggregator eventaggregator, ShipOutfittingModel data) { this._loader = loader; this.Data = data; this._updateItem = new Pair<int, ItemType>(); this._selectedShip = new ShipModel(); this._eventAggregator = eventaggregator; _eventAggregator.GetEvent<SelectedIDEvent>().Subscribe(LoadNewItem); _eventAggregator.GetEvent<SelectedShipEvent>().Subscribe(ShipSelectionChanged); _eventAggregator.GetEvent<OutfittingRestrictionsEvent>().Subscribe(RestrictionsChanged); // Initialize the filthy rest this.HardpointClickCommand = new DelegateCommand(this.OnHardpointClick); this.BulkheadClickCommand = new DelegateCommand(this.OnBulkheadClick); this.PowerPlantClickCommand = new DelegateCommand(this.OnPowerPlantClick); this.ThrusterClickCommand = new DelegateCommand(this.OnThrusterClick); this.FSDClickCommand = new DelegateCommand(this.OnFSDClick); this.LifeSupportClickCommand = new DelegateCommand(this.OnLifeSupportClick); this.PowerDistribClickCommand = new DelegateCommand(this.OnPowerDistribClick); this.SensorClickCommand = new DelegateCommand(this.OnSensorClick); this.FuelTankClickCommand = new DelegateCommand(this.OnFuelTankClick); this.UtilityClickCommand = new DelegateCommand(this.OnUtilityClick); this.Internal1ClickCommand = new DelegateCommand(this.OnInternal1Click); this.Internal2ClickCommand = new DelegateCommand(this.OnInternal2Click); }
// Recieve the outfitting changes, calculate the according stats and // send the new outfitting restrictions ( e.g. The Hullmass ) to the "OutfittingViewModel" private void SaveOutfitting(OutfittingChangedEventArgs e) { this._shipout = e.Outfitting; this._combinedInternals = new List<InternalModel>(e.Outfitting.InternalComps1); this._combinedInternals.AddRange(e.Outfitting.InternalComps2); CalculateAttributes(); RestrictionModel tmpres = new RestrictionModel((int)Double.Parse(this.Data.Hullladen)); var eventargs = new OutfittingRestrictionsEventArgs(tmpres); this._eventAggregator.GetEvent<OutfittingRestrictionsEvent>().Publish(eventargs); }