Exemplo n.º 1
0
        public MainWindowViewModel(IFeatureRepository featureRepository, IFeatureController featureController)
        {
            _featureRepository = featureRepository;
            _featureController = featureController;

            var canGenerateMonster = this
                                     .WhenAnyValue(x => x.Name, x => x.SelectedQuality,
                                                   (name, quality) => !string.IsNullOrWhiteSpace(name) && quality >= 0);

            GenerateMonsterCommand = ReactiveCommand.Create(GenerateMonster, canGenerateMonster);

            SetMonsterQualityCommand = ReactiveCommand.Create <string, Unit>((p) =>
            {
                SelectedQuality = int.Parse(p);
                return(Unit.Default);
            });

            Features = GetFeatureViewModels();

            this.WhenAnyValue(x => x.IsGroup)
            .Subscribe(b =>
            {
                if (b)
                {
                    _featureController.AddFeature(new MassAttackFeature());
                    _featureController.AddFeature(new GroupFeature());
                }
                else
                {
                    _featureController.RemoveFeature(new GroupFeature());
                    GroupCount = null;
                }
            });
        }
Exemplo n.º 2
0
 private void AddFeature(bool isChecked)
 {
     if (isChecked)
     {
         _featureController.AddFeature(_feature);
     }
     else
     {
         _featureController.RemoveFeature(_feature);
     }
 }