internal void RemoveArmyItem() { _planUnits.Remove(SelectedArmyUnit); SelectedArmyUnit = null; OnPropertyChanged(nameof(PlanUnits)); OnPropertyChanged(nameof(ArmyCost)); OnPropertyChanged(nameof(ArmyPointsValue)); }
public void CreateNewArmyItem() { var newArmyUnit = new PlanUnitViewModel(new PlanUnit()); newArmyUnit.PropertyChanged += SelectedArmyItem_PropertyChanged; PlanUnits.Add(newArmyUnit); SelectedArmyUnit = newArmyUnit; }
public async void PopulateArmyUnits() { IEnumerable <PlanUnit> armyUnits = await _armyUnitProvider.GetArmyUnitsForArmy((Guid)PlanArmy.PlanArmyId); PlanUnits = new ObservableCollection <PlanUnitViewModel>(armyUnits.Select(armyItem => { var armyVM = new PlanUnitViewModel(armyItem); armyVM.PropertyChanged += SelectedArmyItem_PropertyChanged; return(armyVM); })); OnPropertyChanged(nameof(ArmyPointsValue)); OnPropertyChanged(nameof(ArmyCost)); }
internal void CopyArmyItem() { var armyItem = SelectedArmyUnit.PlanUnit; armyItem.Options = SelectedArmyUnit.Options.Select(option => option.Option).ToList(); var copiedArmyItem = new PlanUnitViewModel(StaticHelper.DeepClone(armyItem)); PlanUnits.Add(copiedArmyItem); SelectedArmyUnit = copiedArmyItem; OnPropertyChanged(nameof(ArmyCost)); OnPropertyChanged(nameof(ArmyPointsValue)); }