Exemplo n.º 1
0
        public void TestMasterclassButton()
        {
            var form   = new Form();
            var button = new MasterclassButton();

            form.Controls.Add(button);
        }
Exemplo n.º 2
0
        private void ReloadData()
        {
            TournamentController    tournamentController  = new TournamentController();
            List <TournamentModel>  tournaments           = tournamentController.GetTournaments();
            MasterclassController   masterclassController = new MasterclassController();
            List <MasterclassModel> masterclasses         = masterclassController.GetMasterclasses();
            PlayerController        playerController      = new PlayerController();
            List <PlayerModel>      players = playerController.GetPlayers();

            this.pnlTournaments.Controls.Clear();

            for (int i = 0; i < tournaments.Count; i++)
            {
                TournamentButton button =
                    new TournamentButton {
                    Tournament = tournaments[i], Location = new Point(i * 150, 0)
                };

                // If tournament has finished
                if (tournaments[i].Date < DateTime.Now)
                {
                    button.BackColor = Color.FromArgb(240, 240, 240);
                    button.ForeColor = Color.Gray;
                }

                // If tournament is coming up
                if (tournaments[i].Date.ToShortDateString() == DateTime.Now.ToShortDateString())
                {
                    button.FlatAppearance.BorderColor = Color.FromArgb(33, 150, 243);
                }

                this.pnlTournaments.Controls?.Add(button);
            }

            this.pnlMasterclasses.Controls.Clear();

            for (int i = 0; i < masterclasses.Count; i++)
            {
                MasterclassButton button =
                    new MasterclassButton {
                    Masterclass = masterclasses[i], Location = new Point(i * 260, 0)
                };

                // If tournament has finished
                if (masterclasses[i].Date < DateTime.Now)
                {
                    button.BackColor = Color.FromArgb(240, 240, 240);
                    button.ForeColor = Color.Gray;
                }

                // If tournament is coming up
                if (masterclasses[i].Date == DateTime.Now)
                {
                    button.FlatAppearance.BorderColor = Color.FromArgb(33, 150, 243);
                }

                this.pnlMasterclasses.Controls?.Add(button);
            }

            this.dgPlayers.DataSource               = players.OrderBy(player => player.FirstName).ToList();
            this.dgPlayers.Columns[7].Visible       = false;
            this.dgPlayers.Columns[8].DisplayIndex  = 0;
            this.dgPlayers.Columns[9].DisplayIndex  = 1;
            this.dgPlayers.Columns[10].DisplayIndex = 2;
            this.dgPlayers.Columns[11].DisplayIndex = 3;
        }