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

@ -109,6 +109,7 @@
this.MatchUpListBox.Name = "MatchUpListBox"; this.MatchUpListBox.Name = "MatchUpListBox";
this.MatchUpListBox.Size = new System.Drawing.Size(338, 272); this.MatchUpListBox.Size = new System.Drawing.Size(338, 272);
this.MatchUpListBox.TabIndex = 5; this.MatchUpListBox.TabIndex = 5;
this.MatchUpListBox.SelectedIndexChanged += new System.EventHandler(this.MatchUpListBox_SelectedIndexChanged);
// //
// teamOneName // teamOneName
// //

View File

@ -14,12 +14,16 @@ namespace TrackerUI
public partial class TournamentViewerForm : Form public partial class TournamentViewerForm : Form
{ {
private readonly TournamentModel tournament; private readonly TournamentModel tournament;
List<int> rounds = new List<int>(); BindingList<int> rounds = new BindingList<int>();
List<MatchupModel> selectedMatchups = new List<MatchupModel>(); BindingList<MatchupModel> selectedMatchups = new BindingList<MatchupModel>();
bool loading = false;
public TournamentViewerForm(TournamentModel tournamentModel) public TournamentViewerForm(TournamentModel tournamentModel)
{ {
InitializeComponent(); InitializeComponent();
tournament = tournamentModel; tournament = tournamentModel;
WireUpLists();
LoadFormData(); LoadFormData();
LoadRounds(); LoadRounds();
} }
@ -29,21 +33,16 @@ namespace TrackerUI
tournamentName.Text = tournament.TournamentName; tournamentName.Text = tournament.TournamentName;
} }
private void WireUpRoundsLists() private void WireUpLists()
{ {
roundDropDown.DataSource = null;
roundDropDown.DataSource = rounds; roundDropDown.DataSource = rounds;
}
private void WireUpMatchupsLists()
{
MatchUpListBox.DataSource = null;
MatchUpListBox.DataSource = selectedMatchups; MatchUpListBox.DataSource = selectedMatchups;
MatchUpListBox.DisplayMember = "DisplayName"; MatchUpListBox.DisplayMember = "DisplayName";
} }
private void LoadRounds() private void LoadRounds()
{ {
rounds = new List<int>(); rounds.Clear();
rounds.Add(1); rounds.Add(1);
int currRound = 1; int currRound = 1;
@ -55,26 +54,77 @@ namespace TrackerUI
rounds.Add(currRound); rounds.Add(currRound);
} }
} }
WireUpRoundsLists(); LoadMatchups(1);
} }
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e) 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) foreach (List<MatchupModel> matchups in tournament.Rounds)
{ {
if (matchups.First().MatchupRound == round) 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);
} }
} }
} }