public LiveScores() { int week = data.GetWeek(); games = controller.GetScores(week); InitializeComponent(); GameScore[] scores = new GameScore[games.Length]; for (int i = 0; i < games.Length; i++) { string score = games[i].Score1 + "-" + games[i].Score2; GameScore temp = new GameScore(games[i].Team1, games[i].Team2, score); panel.Children.Add(temp); } InitializeComponent(); /*DispatcherTimer timer = new DispatcherTimer(); * timer.Interval = TimeSpan.FromMinutes(1); * timer.Tick += timer_Tick; * timer.Start();*/ }
public Primary(User use, Controller controller) { this.controller = controller; us = use; week = data.GetWeek(); games = controller.GetScores(week); InitializeComponent(); GameScore[] scores = new GameScore[games.Length]; //InitializeComponent(); for (int i = 0; i < games.Length; i++) { if (games[i].Team1.Equals(us.FavTeam) || games[i].Team2.Equals(us.FavTeam)) { string score = games[i].Score1 + "-" + games[i].Score2; GameScore temp = new GameScore(games[i].Team1, games[i].Team2, score); panel.Children.Add(temp); game = i; break; } } //InitializeComponent(); p = controller.GetFavoritePlayers(games[game].Team1, week); p2 = controller.GetFavoritePlayers(games[game].Team2, week); data.UpdateWeeklyStats(week, p[x].Id); data.UpdateWeeklyStats(week, p2[x].Id); p = controller.GetFavoritePlayers(games[game].Team1, week); p2 = controller.GetFavoritePlayers(games[game].Team2, week); player1.Content = p[x].Name; yd1.Text += " " + p[x].SeasonStats.PassingYds.ToString(); td1.Text += " " + p[x].SeasonStats.PassingTds.ToString(); misc1.Text += " " + p[x].SeasonStats.Interceptions.ToString(); player2.Content = p2[x].Name; yd2.Text += "Passing Yards: " + p2[x].SeasonStats.PassingYds.ToString(); td2.Text += "Touchdowns: " + p2[x].SeasonStats.PassingTds.ToString(); misc2.Text += "Interceptions: " + p2[x].SeasonStats.Interceptions.ToString(); x++; timer2.Elapsed += timer2_Tick; timer2.AutoReset = true; timer2.Enabled = true; timer.Elapsed += timer2_Tick; timer.AutoReset = true; timer.Enabled = true; }
void timer_Tick(object sender, EventArgs e) { data.UpdateLiveScores(); int week = data.GetWeek(); games = controller.GetScores(week); GameScore[] scores = new GameScore[games.Length]; for (int i = 0; i < games.Length; i++) { if (games[i].Team1.Equals(us.FavTeam) || games[i].Team2.Equals(us.FavTeam)) { string score = games[i].Score1 + "-" + games[i].Score2; GameScore temp = new GameScore(games[i].Team1, games[i].Team2, score); panel.Children.Add(temp); break; } } InitializeComponent(); if (IsClosed) { timer2.Enabled = false; } }