public Form1() { tournament = new SingleElimination(); IRule bestof1 = new BestOf(1); IRule bestof3 = new BestOf(3); IRule BestOf5 = new BestOf(5); InitializeComponent(); RulesBox.Items.Add(bestof1); RulesBox.Items.Add(bestof3); RulesBox.Items.Add(BestOf5); MatchVisualizer.SetParent(this); //Set current colors for application colorFactory = ColorHandler.Instance; colors = colorFactory.GetColorTheme(); }
private void UpdateTournamentVisuals() { TournamentBox.Controls.Clear(); Size maxSize = this.Size; Size newSize = new Size(maxSize.Width - TournamentBox.Location.X - 32, maxSize.Height - TournamentBox.Location.Y - 48); TournamentBox.Size = newSize; Size box = TournamentBox.Size; tournament.ForceUpdate(); List <List <MatchNode> > rounds = tournament.GetRoundData(); int numberofRounds = rounds.Count - 1; Size roundBox = new Size(); roundBox.Height = box.Height; //fix division by 0 numberofRounds = Math.Max(1, numberofRounds); roundBox.Width = box.Width / numberofRounds; for (int i = 0; i < numberofRounds; i++) { GroupBox roundVis = new GroupBox(); roundVis.Location = new Point(roundBox.Width * i, 16); roundVis.Size = roundBox; roundVis.Text = "Round: " + (i + 1); int hegithMove = 16; int widthMove = 3; Label label = new Label(); if (rounds.Count > i + 1) { Point p = new Point(16, 32); foreach (MatchNode match in rounds[i + 1]) { Control c = MatchVisualizer.CreateVisualElement(match); GroupBox renderBox = new GroupBox(); Size e = c.Size; e.Width += widthMove * 2; renderBox.Size = e; renderBox.Text = match.ToString(); if (match.IsGameActive()) { //renderBox.BackColor = ColorTranslator.FromHtml("#658944"); renderBox.BackColor = colors.colorTwo; } else { //renderBox.BackColor = Color.DimGray; } Size s = renderBox.Size; s.Height += 4 * hegithMove / 3; renderBox.Size = s; c.Location = new Point(widthMove, hegithMove); renderBox.Location = p; renderBox.Controls.Add(c); roundVis.Controls.Add(renderBox); p.Y += renderBox.Size.Height + 12; } TournamentBox.Controls.Add(roundVis); } } }