private void LoadSweet16Treeview(List <Racer> racers)
        {
            this.treeViewSweet16.Nodes.Clear();

            // Build the Root Node
            TreeNode rootNode = this.treeViewSweet16.Nodes.Add("Sweet 16 Qualifiers");

            int placeIndex = 1;

            // Iterate over the racers and display the top 16
            foreach (Racer racer in racers)
            {
                TreeNode node = new TreeNode(racer.GetScoreboardDisplay());

                // Build a node for the average heat time
                TreeNode avgHeatNode = new TreeNode(racer.AverageHeatTime.ToString("0.####"));
                avgHeatNode.Tag = racer;

                node.Nodes.Add(avgHeatNode);
                rootNode.Nodes.Add(node);

                // Build a new Sweet16 object
                Sweet16Racer sweet16 = new Sweet16Racer(racer, placeIndex);

                // Add to our Sweet 16 collection
                RaceDataStore.Sweet16Racers.Add(sweet16);

                placeIndex++;

                if (placeIndex > 16)
                {
                    break;
                }
            }
        }
Example #2
0
        public bool AdvanceWinner(TournamentRace activeRace)
        {
            bool moreRaces = true;

            string winnerKey = activeRace.WinnerKey;

            Sweet16Racer winningRacer = activeRace.Racer1.IsEliminated == false ? activeRace.Racer1 : activeRace.Racer2;

            if (winnerKey == string.Empty)
            {
                System.Windows.Forms.MessageBox.Show(winningRacer.Racer.GetScoreboardDisplay(), "We have a winner!");

                moreRaces = false;

                return(moreRaces);
            }

            // Get a reference to the tournament race mathing the
            // winnners key
            TournamentRace race = RaceDataStore.TournamentRaces[winnerKey];

            // Is racer1 empty?
            if (race.Racer1 == null)
            {
                race.Racer1 = winningRacer;
            }
            else
            {
                race.Racer2 = winningRacer;
            }

            if (race.Racer1 != null && race.Racer2 != null)
            {
                RaceDataStore.RaceKeyQueue.Enqueue(winnerKey);
            }

            return(moreRaces);
        }