/// <summary> /// Gets the available land transports. /// </summary> /// <param name="report">The report.</param> /// <param name="unit">The unit the report is for.</param> /// <param name="equipmentProvider">The equipment provider.</param> /// <returns> /// The available land transports. /// </returns> public static IEnumerable <Equipment> GetAvailableLandTransports(ReportDecorator report, UnitDecorator unit, IEquipmentProvider equipmentProvider) { var landTransports = new List <Equipment>(); if (report != null) { var unorderedTransports = new List <Equipment>(); if (report.Equipment.UsableTransports.Contains(LandTransport)) { // Usable transports has the "land" entry unorderedTransports.AddRange( equipmentProvider.Equipments.Where(equipment => equipment.Nationality == unit.Nationality.Value) .Where(equipment => equipment.Type == UnitType.LandTransport) .Where( equipment => equipment.ShortName.StartsWith(SpecialUnitPrefix) == unit.IsSpecial) .Where(equipment => String.IsNullOrEmpty(equipment.TransportCategory))); } if (String.IsNullOrEmpty(report.Equipment.UsableTransports)) { // Handle the default case without specified data in the usable transports column. if (report.Equipment != None && SatisfiesDefaultLandTransportRules(report.Equipment)) { // We do have valid equipment but no entry unorderedTransports.AddRange( equipmentProvider.Equipments.Where( equipment => equipment.Nationality == unit.Nationality.Value) .Where(equipment => equipment.Type == UnitType.LandTransport) .Where( equipment => equipment.ShortName.StartsWith(SpecialUnitPrefix) == unit.IsSpecial)); } } else { // Usable transports has no "land" entry but may have "heavypull" or similar entries unorderedTransports.AddRange( equipmentProvider.Equipments.Where(equipment => equipment.Nationality == unit.Nationality.Value) .Where(equipment => equipment.Type == UnitType.LandTransport) .Where( equipment => equipment.ShortName.StartsWith(SpecialUnitPrefix) == unit.IsSpecial) .Where(equipment => !String.IsNullOrEmpty(equipment.TransportCategory)) .Where( equipment => report.Equipment.UsableTransports.Contains(equipment.TransportCategory))); } landTransports.AddRange(unorderedTransports.OrderBy(equipment => equipment.AvailableFrom)); } landTransports.Insert(0, None); return(landTransports); }
/// <summary> /// Adds a new unit. /// </summary> /// <returns>The new <see cref="UnitDecorator" />.</returns> public IUnitDecorator AddNewUnit() { UnitDecorator unit = this._decoratorService.Decorate(new Unit()); AddSubordinate(unit); return(unit); }
/// <summary> /// Adds a new <see cref="Unit" /> to the root unit's list of subordinates. /// </summary> public void AddNewUnit() { UnitDecorator unit = this._decoratorService.Decorate(new Unit()); unit.PropertyChanged += OnUnitDecoratorPropertyChanged; RootUnit.AddSubordinate(unit); SelectedUnit = unit; }