TournamentViewer is working but no save yet
Interface cganged
This commit is contained in:
@ -59,7 +59,7 @@ namespace TrackerUI
|
||||
|
||||
private void roundDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
LoadMatchups( (int)roundDropDown.SelectedItem);
|
||||
LoadMatchups((int)roundDropDown.SelectedItem);
|
||||
}
|
||||
|
||||
|
||||
@ -73,13 +73,34 @@ namespace TrackerUI
|
||||
selectedMatchups.Clear();
|
||||
foreach (MatchupModel mm in matchups)
|
||||
{
|
||||
selectedMatchups.Add(mm);
|
||||
if (mm.Winner == null || !unplayedOnlyCheckbox.Checked)
|
||||
{
|
||||
selectedMatchups.Add(mm);
|
||||
}
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
LoadMatchup(selectedMatchups.First());
|
||||
if (selectedMatchups.Count > 0)
|
||||
{
|
||||
LoadMatchup(selectedMatchups.First());
|
||||
}
|
||||
|
||||
DisplayMatchupInfo();
|
||||
}
|
||||
|
||||
private void DisplayMatchupInfo()
|
||||
{
|
||||
bool isVisible = (selectedMatchups.Count > 0);
|
||||
teamOneName.Visible = isVisible;
|
||||
teamOneScoreLabel.Visible = isVisible;
|
||||
teamOneScoreValue.Visible = isVisible;
|
||||
teamTwoName.Visible = isVisible;
|
||||
teamTwoScoreLabel.Visible = isVisible;
|
||||
teamTwoScoreValue.Visible = isVisible;
|
||||
versusLabel.Visible = isVisible;
|
||||
scoreButton.Visible = isVisible;
|
||||
}
|
||||
|
||||
private void LoadMatchup(MatchupModel m)
|
||||
@ -93,15 +114,15 @@ namespace TrackerUI
|
||||
if (m.Entries[0].TeamCompeting != null)
|
||||
{
|
||||
teamOneName.Text = m.Entries[0].TeamCompeting.TeamName;
|
||||
teamOneScoeValue.Text = m.Entries[0].Score.ToString();
|
||||
teamOneScoreValue.Text = m.Entries[0].Score.ToString();
|
||||
|
||||
teamTwoName.Text = "<bye>";
|
||||
teamTwoScoeValue.Text = "0";
|
||||
teamTwoScoreValue.Text = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
teamOneName.Text = "Not Yet Set";
|
||||
teamOneScoeValue.Text = "";
|
||||
teamOneScoreValue.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,21 +131,90 @@ namespace TrackerUI
|
||||
if (m.Entries[1].TeamCompeting != null)
|
||||
{
|
||||
teamTwoName.Text = m.Entries[1].TeamCompeting.TeamName;
|
||||
teamTwoScoeValue.Text = m.Entries[1].Score.ToString();
|
||||
teamTwoScoreValue.Text = m.Entries[1].Score.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
teamTwoName.Text = "Not Yet Set";
|
||||
teamTwoScoeValue.Text = "";
|
||||
teamTwoScoreValue.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MatchUpListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
LoadMatchup((MatchupModel)MatchUpListBox.SelectedItem);
|
||||
}
|
||||
|
||||
private void unplayedOnlyCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
LoadMatchups((int)roundDropDown.SelectedItem);
|
||||
}
|
||||
|
||||
|
||||
private void scoreButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
MatchupModel m = (MatchupModel)MatchUpListBox.SelectedItem;
|
||||
double teamOneScore = 0;
|
||||
double teamTwoScore = 0;
|
||||
|
||||
for (int i = 0; i < m.Entries.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (m.Entries[0].TeamCompeting != null)
|
||||
{
|
||||
var scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
|
||||
if (scoreValid)
|
||||
{
|
||||
m.Entries[0].Score = teamOneScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please enter a valid score for team 1.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
if (m.Entries[1].TeamCompeting != null)
|
||||
{
|
||||
var scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
|
||||
if (scoreValid)
|
||||
{
|
||||
m.Entries[1].Score = teamTwoScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please enter a valid score for team 2.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (teamOneScore > teamTwoScore)
|
||||
{
|
||||
// Team one winns
|
||||
m.Winner = m.Entries[0].TeamCompeting;
|
||||
}
|
||||
else
|
||||
if (teamTwoScore > teamOneScore)
|
||||
{
|
||||
// Team one winns
|
||||
m.Winner = m.Entries[1].TeamCompeting;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("I dont handle tie games.");
|
||||
}
|
||||
|
||||
LoadMatchups((int)roundDropDown.SelectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user