Exemple #1
0
        //Checks arrow scores and stores them, shows the completed score sheet when round is over
        private void BnOk_Click(object sender, RoutedEventArgs e)
        {
            if (Validate())
            {
                endScore.Clear();
                //take account of potential edits

                if (tbArch1Arr1.Text == "M" || tbArch1Arr1.Text == "m")
                {
                    endScore.Add(0);
                }
                if (tbArch1Arr2.Text == "M" || tbArch1Arr2.Text == "m")
                {
                    endScore.Add(0);
                }
                if (tbArch1Arr3.Text == "M" || tbArch1Arr3.Text == "m")
                {
                    endScore.Add(0);
                }

                if (int.TryParse(tbArch1Arr1.Text, out int arrow))      //should only fail if M/m as Vaidate checks inputs
                {
                    endScore.Add(arrow);
                }
                if (int.TryParse(tbArch1Arr2.Text, out arrow))
                {
                    endScore.Add(arrow);
                }
                if (int.TryParse(tbArch1Arr3.Text, out arrow))
                {
                    endScore.Add(arrow);
                }

                foreach (int score in endScore)
                {
                    archer.AddToScore(score);
                    if (score != 0)
                    {
                        archer.AddHit();
                    }
                    if (score == 10)
                    {
                        archer.AddTen();
                    }
                }

                archer.FinishEnd();

                ClearArrowsFromTarget();                //make it clear the score has been accepted
                EmptyScoreEntry();

                if (nEnd < nTotalEnds)
                {
                    nEnd++;
                    labelEnd.Content = "End " + nEnd + " of " + nTotalEnds;
                }
                else
                {
                    this.Visibility = Visibility.Hidden;
                    ScoreSheet scoreSheet = new ScoreSheet(archer, this);
                    scoreSheet.ShowDialog();
                }
            }
        }