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

@ -20,9 +20,7 @@ namespace TrackerUI
// Initialize the database connections
GlobalConfig.InitializeConnections(DatabaseType.Sql);
Application.Run(new CreateTournamentForm());
//Application.Run(new TournamentDashboardForm());
Application.Run(new TournamentDashboardForm());
}
}
}

View File

@ -80,6 +80,7 @@
this.loadTournamentButton.TabIndex = 25;
this.loadTournamentButton.Text = "Load Tournament";
this.loadTournamentButton.UseVisualStyleBackColor = true;
this.loadTournamentButton.Click += new System.EventHandler(this.loadTournamentButton_Click);
//
// createTournamentButton
//
@ -94,6 +95,7 @@
this.createTournamentButton.TabIndex = 26;
this.createTournamentButton.Text = "Create Tournament";
this.createTournamentButton.UseVisualStyleBackColor = true;
this.createTournamentButton.Click += new System.EventHandler(this.createTournamentButton_Click);
//
// TournamentDashboardForm
//

View File

@ -7,14 +7,37 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TrackerLibrary;
using TrackerLibrary.Models;
namespace TrackerUI
{
public partial class TournamentDashboardForm : Form
{
List<TournamentModel> tournaments = GlobalConfig.Connection.GetTournament_All();
public TournamentDashboardForm()
{
InitializeComponent();
WireUpLists();
}
private void WireUpLists()
{
loadExistingTournamentDropDown.DataSource = tournaments;
loadExistingTournamentDropDown.DisplayMember = "TournamentName";
}
private void createTournamentButton_Click(object sender, EventArgs e)
{
CreateTournamentForm frm = new CreateTournamentForm();
frm.Show();
}
private void loadTournamentButton_Click(object sender, EventArgs e)
{
TournamentModel tm = (TournamentModel)loadExistingTournamentDropDown.SelectedItem;
TournamentViewerForm frm = new TournamentViewerForm(tm);
frm.Show();
}
}
}

View File

@ -86,6 +86,7 @@
this.roundDropDown.Name = "roundDropDown";
this.roundDropDown.Size = new System.Drawing.Size(245, 38);
this.roundDropDown.TabIndex = 3;
this.roundDropDown.SelectedIndexChanged += new System.EventHandler(this.roundDropDown_SelectedIndexChanged);
//
// unplayedOnlyCheckbox
//

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();
}
}
}