示例#1
0
文件: MainVM.cs 项目: Thujed/Quiz
        public MainVM()
        {
            Players.CollectionChanged += (s, e) =>
                                         PlayersPresentationData.OnPlayersInfoUpdate(Players.OrderByDescending(p => p.PlayerName.Length).First().PlayerName);

            DBWorker dataBase = new DBWorker();

            Players.AddRange(dataBase.GetAllPlayers().
                             Select(p => new PlayerDataVM(p)).
                             ToList());
            int playersCount = Players.Count;

            for (int i = 0; i < MIN_PLAYERS_COUNT - playersCount; ++i)
            {
                Players.Add(new PlayerDataVM(new Player(
                                                 "Player " + (Players.Count + 1).ToString(),
                                                 0,
                                                 Players.Count >= _defaultPlayerColours.Length ? Color.FromRgb(125, 125, 125) : _defaultPlayerColours[Players.Count]
                                                 )));
            }

            Players.LinkActionToPlayerDataList(Player_OnPlayerSelected);
            ChangePointsVM.OnPlayerPointsChanged += ChangePointsVM_OnPlayerPointsChanged;
        }