public override void Initialise()
        {
            _minDamageSliderDVM = new SliderDataViewModel <int>(
                new Scaler <int>(WeaponModel.LegalDamageValues, (a, b) => a < b),
                WeaponModel.LegalDamageValues.Count - 1,
                () => DataObject().MinDamage,
                val =>
            {
                DataObject().MinDamage = val;
                OnPropertyChanged(nameof(MinDamageIndex));
                OnPropertyChanged(nameof(MinDamage));
            },
                CheckRulesMinDamage);

            _maxDamageSliderDVM = new SliderDataViewModel <int>(
                new Scaler <int>(WeaponModel.LegalDamageValues, (a, b) => a < b),
                WeaponModel.LegalDamageValues.Count - 1,
                () => DataObject().MaxDamage,
                val =>
            {
                DataObject().MaxDamage = val;
                OnPropertyChanged(nameof(MaxDamageIndex));
                OnPropertyChanged(nameof(MaxDamage));
            },
                CheckRulesMaxDamage);

            _jewelSocketsSliderDVM = new IntSliderDataViewModel(
                WeaponModel.MaxNoOfJewelSockets,
                () => DataObject().JewelSockets,
                val =>
            {
                DataObject().JewelSockets = val;
                OnPropertyChanged(nameof(JewelSocketsIndex));
                OnPropertyChanged(nameof(JewelSockets));
            });

            _rarityTierSCDVM = new SelectionControlDVM <RarityTier, RarityTierDataViewModel>(
                () => DataObject().RarityTierId,
                val =>
            {
                DataObject().RarityTierId = DomainClassBase <RarityTier> .IdOrNullId(val);
                OnPropertyChanged(nameof(RaritySelected));
            });

            _weaponTypeSCDVM = new SelectionControlDVM <WeaponType, WeaponTypeDataViewModel>(
                () => DataObject().WeaponTypeId,
                val =>
            {
                DataObject().WeaponTypeId = DomainClassBase <WeaponType> .IdOrNullId(val);
                OnPropertyChanged(nameof(WeaponTypeSelected));
            });
        }
Exemple #2
0
        public override void Initialise()
        {
            // Integer-slider DVM for at kunne se/rette Health Points
            _hpSliderDVM = new IntSliderDataViewModel(
                Character.MaxHealthPoints,
                HPScaleFactor,
                () => DataObject().HealthPoints,
                val =>
            {
                DataObject().HealthPoints = val;
                OnPropertyChanged(nameof(HealthPointsIndex));
                OnPropertyChanged(nameof(HealthPoints));
            });

            // Integer-slider DVM for at kunne se/rette Level
            _levelSliderDVM = new IntSliderDataViewModel(
                Character.MaxLevel,
                () => DataObject().Level,
                val =>
            {
                DataObject().Level = val;
                OnPropertyChanged(nameof(LevelIndex));
                OnPropertyChanged(nameof(Level));
            });

            // Selection-control DVM for at kunne se/rette ejede Weapon
            _ownedWeaponControlDVM = new SelectionControlDVM <Weapon, WeaponDataViewModel>(
                () => OwnedWeaponSelectedId,
                val => OwnedWeaponSelectedId = val,
                w => w.CharacterId == DataObject().Id);

            // Selection-control DVM for at kunne se/rette frie Weapon
            _freeWeaponControlDVM = new SelectionControlDVM <Weapon, WeaponDataViewModel>(
                () => FreeWeaponSelectedId,
                val => FreeWeaponSelectedId = val,
                w => w.CharacterId == null);

            // Command-objekter til hhv. at droppe eller tilføje et Weapon
            _dropWeaponCommand = new ReferenceChangeCommand <Weapon>(w => w.CharacterId = null);
            _addWeaponCommand  = new ReferenceChangeCommand <Weapon>(w => w.CharacterId = DataObject().Id);

            OwnedWeaponSelectedId = null;
            FreeWeaponSelectedId  = null;

            // Da drop/tilføj vil medføre ændringer i Weapon-Cataloget, som udføres
            // fra Command-objekter, vil vi gerne notificeres om dette.
            DomainModel.GetCatalog <Weapon>().CatalogChanged += WeaponCatalogChanged;
        }
        public override void Initialise()
        {
            _rarityTierSCDVM = new SelectionControlDVM <RarityTier, RarityTierDataViewModel>(
                () => DataObject().RarityTierId,
                val =>
            {
                DataObject().RarityTierId = DomainClassBase <RarityTier> .IdOrNullId(val);
                OnPropertyChanged(nameof(RaritySelected));
            });

            _baseDamageSliderDVM = new IntSliderDataViewModel(
                JewelModel.MaxBaseDamage,
                BaseDamageScaleFactor,
                () => DataObject().BaseDamage,
                val =>
            {
                DataObject().BaseDamage = val;
                OnPropertyChanged(nameof(BaseDamageIndex));
                OnPropertyChanged(nameof(BaseDamage));
            });
        }