コード例 #1
0
        internal void RemoveArmyItem()
        {
            _planUnits.Remove(SelectedArmyUnit);
            SelectedArmyUnit = null;

            OnPropertyChanged(nameof(PlanUnits));
            OnPropertyChanged(nameof(ArmyCost));
            OnPropertyChanged(nameof(ArmyPointsValue));
        }
コード例 #2
0
        public void CreateNewArmyItem()
        {
            var newArmyUnit = new PlanUnitViewModel(new PlanUnit());

            newArmyUnit.PropertyChanged += SelectedArmyItem_PropertyChanged;

            PlanUnits.Add(newArmyUnit);

            SelectedArmyUnit = newArmyUnit;
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }