示例#1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (gameWorld == null)
            {
                return;
            }

            if (BombUpDown.Value == null)
            {
                return;
            }

            List <int> cards     = new List <int>();
            int        numPlayer = gameWorld.Players.Count;

            for (int i = 0; i < numPlayer; ++i)
            {
                IntegerUpDown cardUpDown = CardGrid.FindName(string.Format("Player{0}UpDown", i)) as IntegerUpDown;
                if (cardUpDown == null || cardUpDown.Value == null)
                {
                    return;
                }
                cards.Add((int)cardUpDown.Value);
                cardUpDown.Value = 0;
            }
            gameWorld.AddGame((int)BombUpDown.Value, cards);
            BombUpDown.Value = 0;

            UpdatePlayerScoreLabels();
            ScoreListViewer.Items.Refresh();
        }
示例#2
0
        private void UpdateNameLabels()
        {
            for (int i = 0; i < gameWorld.Players.Count; ++i)
            {
                Label nameLabel = CardGrid.FindName(string.Format("Plyer{0}NameLable", i)) as Label;
                if (nameLabel == null)
                {
                    return;
                }
                nameLabel.Content = gameWorld.Players[i].Name;

                IntegerUpDown cardUpDown = CardGrid.FindName(string.Format("Player{0}UpDown", i)) as IntegerUpDown;
                if (cardUpDown == null)
                {
                    return;
                }
                cardUpDown.IsReadOnly = false;
            }

            for (int i = gameWorld.Players.Count; i < 6; ++i)
            {
                Label nameLabel = CardGrid.FindName(string.Format("Plyer{0}NameLable", i)) as Label;
                if (nameLabel == null)
                {
                    return;
                }
                nameLabel.Content = "";

                IntegerUpDown cardUpDown = CardGrid.FindName(string.Format("Player{0}UpDown", i)) as IntegerUpDown;
                if (cardUpDown == null)
                {
                    return;
                }
                cardUpDown.IsReadOnly = true;
            }
        }