Exemple #1
0
        /// <summary>
        /// Removes the end scores as per official rules
        /// </summary>
        /// <returns>New list with the valid scores</returns>
        public ScoreList generateScoresWithoutFirstAndLastScore()
        {
            ScoreList ScoresWithoutFirstAndLastScore = new ScoreList();

            SortScoreListAscending();

            // sums all the scores
            // i start at 1 to skip first
            if (Scores?.Count > 2)
            {
                for (int i = 1; i < Scores.Count; i++)
                {
                    // skip last
                    if (i == Scores.Count - 1)
                    {
                        break;
                    }

                    ScoresWithoutFirstAndLastScore.Add(Scores[i]);
                }
            }
            else
            {
                return(Scores);
            }

            return(ScoresWithoutFirstAndLastScore);
        }
Exemple #2
0
        private void buttonGiveScore_Click(object sender, EventArgs e)
        {
            if (lvJudges.SelectedItems.Count == 1)
            {
                foreach (var judge in judgeList)
                {
                    if (judge.GetFullName() == lvJudges.SelectedItems[0].SubItems[0].Text)
                    {
                        int i = 0;

                        foreach (var score in ScoreList)
                        {
                            if (score.Judge == judge)
                            {
                                break;
                            }
                            i++;
                        }

                        if (i == ScoreList.Count)
                        {
                            ScoreList.Add(new Score(double.Parse(labelPoints.Text), judge));
                        }
                        else
                        {
                            ScoreList[i].Value = double.Parse(labelPoints.Text);
                        }
                    }
                }

                lvJudges.Items.Clear();

                foreach (var j in judgeList)
                {
                    ListViewItem item = new ListViewItem(j.GetFullName());

                    foreach (var score in ScoreList)
                    {
                        if (score.Judge == j)
                        {
                            item.SubItems.Add(score.Value.ToString());
                        }
                    }

                    lvJudges.Items.Add(item);
                }
            }

            labelJudge.Text = judgeList[index].GetFullName();
            lvJudges.Items[index++].Selected = true;
            lvJudges.Select();


            if (index == lvJudges.Items.Count)
            {
                index = 0;
            }
        }
Exemple #3
0
        // Public Methods
        public void TestData()
        {
            ScoreList scoreList = new ScoreList();

            scoreList.Add(new Score(2.5));
            scoreList.Add(new Score(7.5));
            scoreList.Add(new Score(3));
            scoreList.Add(new Score(10));
            scoreList.Add(new Score(5.5));


            ScoreList scoreList2 = new ScoreList();

            scoreList2.Add(new Score(2.5));
            scoreList2.Add(new Score(3));
            scoreList2.Add(new Score(2));
            scoreList2.Add(new Score(8.5));
            scoreList2.Add(new Score(5.5));

            Dive dive = new Dive(new DiveCode(2.0, "10mbakåtvolt"), scoreList2);

            Dive dive2 = new Dive(new DiveCode(3.0, "10m"), scoreList);

            foreach (var sc in Model.SubContestBranches)
            {
                foreach (var c in sc.BranchContestants)
                {
                    if (c.FirstName == "pelle")
                    {
                        sc.AddNewDive(c, dive2);
                    }
                }
            }

            foreach (var sc in Model.SubContestBranches)
            {
                foreach (var c in sc.BranchContestants)
                {
                    if (c.FirstName == "kalle")
                    {
                        sc.AddNewDive(c, dive);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Gathers up the scores that have come in from the various judges
        /// However it will only create and store the ScoreList if all the scores have come in.
        /// </summary>
        public void CollectPoints()
        {
            bool AllPointsCollected = true;

            if (View.ListViewJudgeClients.Items.Count == CurrentContest.Judges.Count)
            {
                ScoreList scoreList = new ScoreList();
                foreach (ListViewItem clientItem in View.ListViewJudgeClients.Items)
                {
                    if (clientItem.SubItems[1].Text == "-1")
                    {
                        // One of the scores have not come in
                        AllPointsCollected = false;
                        break;
                    }
                    else
                    {
                        // Find the right Judge
                        foreach (var judge in CurrentContest.Judges)
                        {
                            if (judge.GetFullName() == clientItem.SubItems[0].Text)
                            {
                                double score = double.Parse(clientItem.SubItems[1].Text);
                                scoreList.Add(new Score(score, judge));
                                break;
                            }
                        }
                    }
                }

                // All scores are in, go ahead and add the new ScoreList
                if (AllPointsCollected)
                {
                    GetSelectedDive().Scores = scoreList;

                    CancelModifyDive();
                    ResetPoints();
                }
                else
                {
                    MessageBox.Show("Väntar fortfarande på poäng från domare!");
                }
            }
            else
            {
                MessageBox.Show("Alla domare måste ansuta först!");
            }
        }