81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using TrackerLibrary.Models;
|
|
|
|
namespace TrackerUI
|
|
{
|
|
public partial class TournamentViewerForm : Form
|
|
{
|
|
private readonly TournamentModel tournament;
|
|
List<int> rounds = new List<int>();
|
|
List<MatchupModel> selectedMatchups = new List<MatchupModel>();
|
|
public TournamentViewerForm(TournamentModel tournamentModel)
|
|
{
|
|
InitializeComponent();
|
|
tournament = tournamentModel;
|
|
LoadFormData();
|
|
LoadRounds();
|
|
}
|
|
|
|
private void LoadFormData()
|
|
{
|
|
tournamentName.Text = tournament.TournamentName;
|
|
}
|
|
|
|
private void WireUpRoundsLists()
|
|
{
|
|
roundDropDown.DataSource = null;
|
|
roundDropDown.DataSource = rounds;
|
|
|
|
}
|
|
private void WireUpMatchupsLists()
|
|
{
|
|
MatchUpListBox.DataSource = null;
|
|
MatchUpListBox.DataSource = selectedMatchups;
|
|
MatchUpListBox.DisplayMember = "DisplayName";
|
|
}
|
|
private void LoadRounds()
|
|
{
|
|
rounds = new List<int>();
|
|
|
|
rounds.Add(1);
|
|
int currRound = 1;
|
|
foreach (List<MatchupModel> matchups in tournament.Rounds)
|
|
{
|
|
if (matchups.First().MatchupRound > currRound)
|
|
{
|
|
currRound = matchups.First().MatchupRound;
|
|
rounds.Add(currRound);
|
|
}
|
|
}
|
|
WireUpRoundsLists();
|
|
}
|
|
|
|
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
LoadMatchups();
|
|
}
|
|
|
|
|
|
private void LoadMatchups()
|
|
{
|
|
int round = (int)roundDropDown.SelectedItem;
|
|
foreach (List<MatchupModel> matchups in tournament.Rounds)
|
|
{
|
|
if (matchups.First().MatchupRound == round)
|
|
{
|
|
selectedMatchups = matchups;
|
|
}
|
|
}
|
|
WireUpMatchupsLists();
|
|
}
|
|
}
|
|
}
|