コード例 #1
0
        public PlayersSelectViewModel(string label, IEnumerable <int> humans, RangeViewModel minMax)
        {
            Label  = label;
            Humans = new OptionInputViewModel <int>(humans.ToArray());
            MinMax = minMax;

            RefreshForHumanPlayers = ReactiveCommand.Create((OptionInputItem <int> item) =>
            {
                OptionInputViewModel <int> minInput = MinMax.MinInput;
                foreach (var minItem in minInput.Items)
                {
                    minItem.IsEnabled = minItem.Item >= item.Item;
                }
                if (!minInput.SelectedItem.IsEnabled)
                {
                    minInput.SelectedItem = minInput.Items.Where(x => x.IsEnabled).First();
                }
            });

            RefreshForRaces = ReactiveCommand.Create((IEnumerable <DowRace> races) =>
            {
                Races = new ProportionalOptionsViewModel <DowRace>("Races", race => race.Name, races.ToArray());
            });

            this.WhenAnyValue(x => x.Humans.SelectedItem)
            .DistinctUntilChanged()
            .InvokeCommand(RefreshForHumanPlayers);
        }
コード例 #2
0
 public GameTabViewModel()
 {
     DiffOption = new ProportionalOptionsViewModel <GameDifficulty>("Difficulty", GameDifficultyEx.ToString,
                                                                    Enum.GetValues(typeof(GameDifficulty)).Cast <GameDifficulty>().ToArray());
     SpeedOption = new ProportionalOptionsViewModel <GameSpeed>("Game Speed", GameSpeedEx.ToString,
                                                                Enum.GetValues(typeof(GameSpeed)).Cast <GameSpeed>().ToArray());
     RateOption = new ProportionalOptionsViewModel <GameResourceRate>("Resource Rate", GameResourceRateEx.ToString,
                                                                      Enum.GetValues(typeof(GameResourceRate)).Cast <GameResourceRate>().ToArray());
     StartingOption = new ProportionalOptionsViewModel <GameStartResource>("Starting Resources", GameStartResourceEx.ToString,
                                                                           Enum.GetValues(typeof(GameStartResource)).Cast <GameStartResource>().ToArray());
 }