Small changes

This commit is contained in:
2020-04-13 13:52:58 +02:00
parent 8d3e6fdfa4
commit 7a6280b6f4
2 changed files with 67 additions and 16 deletions

View File

@ -14,12 +14,16 @@ namespace TrackerUI
public partial class TournamentViewerForm : Form
{
private readonly TournamentModel tournament;
List<int> rounds = new List<int>();
List<MatchupModel> selectedMatchups = new List<MatchupModel>();
BindingList<int> rounds = new BindingList<int>();
BindingList<MatchupModel> selectedMatchups = new BindingList<MatchupModel>();
bool loading = false;
public TournamentViewerForm(TournamentModel tournamentModel)
{
InitializeComponent();
tournament = tournamentModel;
WireUpLists();
LoadFormData();
LoadRounds();
}
@ -29,21 +33,16 @@ namespace TrackerUI
tournamentName.Text = tournament.TournamentName;
}
private void WireUpRoundsLists()
private void WireUpLists()
{
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.Clear();
rounds.Add(1);
int currRound = 1;
@ -55,26 +54,77 @@ namespace TrackerUI
rounds.Add(currRound);
}
}
WireUpRoundsLists();
LoadMatchups(1);
}
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
LoadMatchups();
LoadMatchups( (int)roundDropDown.SelectedItem);
}
private void LoadMatchups()
private void LoadMatchups(int round)
{
int round = (int)roundDropDown.SelectedItem;
foreach (List<MatchupModel> matchups in tournament.Rounds)
{
if (matchups.First().MatchupRound == round)
{
selectedMatchups = matchups;
loading = true;
selectedMatchups.Clear();
foreach (MatchupModel mm in matchups)
{
selectedMatchups.Add(mm);
}
loading = false;
}
}
WireUpMatchupsLists();
LoadMatchup(selectedMatchups.First());
}
private void LoadMatchup(MatchupModel m)
{
if (!loading)
{
for (int i = 0; i < m.Entries.Count; i++)
{
if (i == 0)
{
if (m.Entries[0].TeamCompeting != null)
{
teamOneName.Text = m.Entries[0].TeamCompeting.TeamName;
teamOneScoeValue.Text = m.Entries[0].Score.ToString();
teamTwoName.Text = "<bye>";
teamTwoScoeValue.Text = "0";
}
else
{
teamOneName.Text = "Not Yet Set";
teamOneScoeValue.Text = "";
}
}
if (i == 1)
{
if (m.Entries[1].TeamCompeting != null)
{
teamTwoName.Text = m.Entries[1].TeamCompeting.TeamName;
teamTwoScoeValue.Text = m.Entries[1].Score.ToString();
}
else
{
teamTwoName.Text = "Not Yet Set";
teamTwoScoeValue.Text = "";
}
}
}
}
}
private void MatchUpListBox_SelectedIndexChanged(object sender, EventArgs e)
{
LoadMatchup((MatchupModel)MatchUpListBox.SelectedItem);
}
}
}