Tournament Dashboard fixed, started to wire up tournamentviewer form

This commit is contained in:
2020-04-12 21:17:01 +02:00
parent dee234408d
commit 8d3e6fdfa4
11 changed files with 294 additions and 29 deletions

View File

@ -7,14 +7,74 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TrackerLibrary.Models;
namespace TrackerUI
{
public partial class TournamentViewerForm : Form
{
public TournamentViewerForm()
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();
}
}
}