void DisplayTable()
        {
            lstLeague.Children.Clear();

            var currentLeague = LeagueHolder.LeagueList.ElementAt(leagueIndex);

            var badgeFetcher = new BadgeFetcher();

            imgCompetitionIcon.Source = badgeFetcher.GetLeagueIcon(currentLeague.Value.LeagueName);
            txtCompetitionName.Text   = currentLeague.Value.LeagueName;

            TableViewHeader lth = new TableViewHeader();

            lth.Height = 20;
            lstLeague.Children.Add(lth);

            var pos = 1;

            foreach (var team in currentLeague.Value.Table)
            {
                var view = new TableView();
                view.HorizontalAlignment = HorizontalAlignment.Stretch;
                view.lblTeam.Text        = team.Team;
                view.lblPosition.Text    = pos + ".";
                view.imgBadge.Source     = badgeFetcher.GetBadge(team.Team);
                view.lblGames.Text       = team.TableData[0].ToString();
                view.lblGoalDiff.Text    = team.TableData[6].ToString();
                view.lblPoints.Text      = team.TableData[7].ToString();

                pos++;

                lstLeague.Children.Add(view);
            }
        }
Beispiel #2
0
        void SetTopScoringTeam()
        {
            var list = statFetcher.GetTopScoringTeams(ResultsToShow);
            var top5 = list.Take(5);

            ScoringTeamHolder.Children.Clear();

            var badgeFetcher = new BadgeFetcher();

            foreach (var team in top5)
            {
                var view = new StatView();
                view.lblTeam.Text    = team.Team;
                view.imgBadge.Source = badgeFetcher.GetBadge(team.Team);
                view.lblScore.Text   = team.TableData[4].ToString();

                ScoringTeamHolder.Children.Add(view);
            }
        }
Beispiel #3
0
        void SetMostYellows()
        {
            var list = statFetcher.GetMostYellows(ResultsToShow);

            var top5 = list.Take(5);

            TopYellows.Children.Clear();

            var badgeFetcher = new BadgeFetcher();

            foreach (var team in top5)
            {
                var view = new StatView();
                view.lblTeam.Text    = team.Field.ToString();
                view.imgBadge.Source = badgeFetcher.GetBadge(team.Field.ToString());
                view.lblScore.Text   = team.Value.ToString();

                TopYellows.Children.Add(view);
            }
        }
Beispiel #4
0
        void DisplayTable(TableType tableType)
        {
            var table = statFetcher.GetTable(ResultsToShow, tableType);

            SelectedTableType = tableType;

            TableContainer.Children.Clear();

            LargeTableHeader lth = new LargeTableHeader();

            lth.Height = 20;
            TableContainer.Children.Add(lth);

            var badgeFetcher = new BadgeFetcher();

            int pos = 1;

            foreach (var team in table)
            {
                var view = new TableViewLarge();
                view.Height          = 28;
                view.lblTeam.Text    = team.Team;
                view.imgBadge.Source = badgeFetcher.GetBadge(team.Team);

                view.Tag = TableContainer.Children.Count - 1;
                view.lblPosition.Text = pos + ".";
                view.lblGames.Text    = team.TableData[0].ToString();
                view.lblWins.Text     = team.TableData[1].ToString();
                view.lblDraws.Text    = team.TableData[2].ToString();
                view.lblLosses.Text   = team.TableData[3].ToString();
                view.lblGf.Text       = team.TableData[4].ToString();
                view.lblGa.Text       = team.TableData[5].ToString();
                view.lblGd.Text       = team.TableData[6].ToString();
                view.MouseDown       += ViewTeam;
                view.lblPoints.Text   = team.TableData[7].ToString();

                pos++;

                TableContainer.Children.Add(view);
            }
        }
Beispiel #5
0
        List <TopScorer> SetTopScorers()
        {
            var sorted = statFetcher.GetTopScorers(SelectedLeague.Results);

            var top5 = sorted.Take(5).ToList();

            TopScorerStack.Children.Clear();

            BadgeFetcher badgeFetcher = new BadgeFetcher();

            foreach (var player in top5)
            {
                var view = new StatView();
                view.lblTeam.Text    = player.Player;
                view.imgBadge.Source = badgeFetcher.GetBadge(player.Team);
                view.lblScore.Text   = player.Goals.ToString();
                TopScorerStack.Children.Add(view);
            }

            return(top5);
        }
Beispiel #6
0
        void SetPartialTable()
        {
            var results = SelectedLeague.Results.Take(ResultsToShow.Count * SelectedLeague.Table.Count).ToList();

            var context = statFetcher.GetContextTable(SelectedTeam, results, TableType.FullTable);

            var table      = context[0] as List <TableItem>;
            var startIndex = (int)context[1] + 1;


            var lth = new TableViewHeader();

            lth.Height = 20;
            LeaguePosStack.Children.Add(lth);

            var badgeFetcher = new BadgeFetcher();

            foreach (var team in table)
            {
                var view = new TableView();
                view.Height = 25;
                view.HorizontalAlignment = HorizontalAlignment.Stretch;
                view.lblTeam.Text        = team.Team;
                view.lblPosition.Text    = startIndex + ".";
                view.imgBadge.Source     = badgeFetcher.GetBadge(team.Team);
                view.lblGames.Text       = team.TableData[0].ToString();
                view.lblGoalDiff.Text    = team.TableData[6].ToString();
                view.lblPoints.Text      = team.TableData[7].ToString();

                if (team.Team == SelectedTeam)
                {
                    view.Background = new SolidColorBrush(Color.FromArgb(70, 32, 195, 179));
                }

                startIndex++;

                LeaguePosStack.Children.Add(view);
            }
        }
Beispiel #7
0
        void SetRecentReds()
        {
            var list = ResultsToShow.Take(SelectedLeague.NumTeams).ToList();

            var badgeFetcher = new BadgeFetcher();

            RedCardStack.Children.Clear();

            if (list.Any())
            {
                foreach (var fixture in list)
                {
                    foreach (var red in fixture.HomeRedCards)
                    {
                        var view = new StatView();
                        view.lblTeam.Text    = red.Player;
                        view.imgBadge.Source = badgeFetcher.GetBadge(red.Team);
                        view.lblScore.Text   = "";
                        RedCardStack.Children.Add(view);
                    }
                    foreach (var red in fixture.AwayRedCards)
                    {
                        var view = new StatView();
                        view.lblTeam.Text    = red.Player;
                        view.imgBadge.Source = badgeFetcher.GetBadge(red.Team);
                        view.lblScore.Text   = "";
                        RedCardStack.Children.Add(view);
                    }
                }
            }
            else
            {
                NoDataLabel ndl = new NoDataLabel();
                RedCardStack.Children.Add(ndl);
            }
        }
Beispiel #8
0
        private void DisplayMatches()
        {
            GamesStack.Children.Clear();

            var date  = new DateTime(CurrentYear, CurrentMonth, 1);
            var month = date.ToString("MMMM");

            SelectedMonth.Content = month;

            var results  = Results.Where(result => result.KickOff.Contains(month)).ToList();
            var fixtures = Fixtures.Where(result => result.KickOff.Contains(month)).ToList();

            BadgeFetcher badgeFetcher = new BadgeFetcher();

            if (results.Any() || fixtures.Any())
            {
                foreach (var res in results)
                {
                    TeamFixtureView view = new TeamFixtureView();
                    view.Height          = 40;
                    view.txtKickoff.Text = res.KickOff.Split('@')[0];
                    var opponent = res.HomeTeam == SelectedTeam
                        ? res.AwayTeam
                        : res.HomeTeam;
                    view.txtScore.Text = res.HomeScore + " - " + res.AwayScore;

                    view.txtOpponent.Text = opponent;

                    if (res.GetOutcome(SelectedTeam) == Fixture.ResultType.Win)
                    {
                        view.ColorBlock.Background = new SolidColorBrush(Color.FromArgb(255, 45, 181, 43));
                    }
                    else if (res.GetOutcome(SelectedTeam) == Fixture.ResultType.Loss)
                    {
                        view.ColorBlock.Background = new SolidColorBrush(Color.FromArgb(255, 240, 40, 30));
                    }
                    else
                    {
                        view.ColorBlock.Background = new SolidColorBrush(Color.FromArgb(255, 249, 226, 14));
                    }

                    view.imgBadge.Source = badgeFetcher.GetBadge(opponent);

                    view.MouseDown += TeamClicked;

                    GamesStack.Children.Add(view);
                }

                foreach (var res in fixtures)
                {
                    TeamFixtureView view = new TeamFixtureView();
                    view.Height          = 40;
                    view.txtKickoff.Text = res.KickOff;
                    var opponent = res.HomeTeam == SelectedTeam
                        ? res.AwayTeam
                        : res.HomeTeam;
                    view.txtScore.Text = " vs. ";

                    view.txtOpponent.Text = opponent;

                    view.MouseDown += TeamClicked;

                    view.imgBadge.Source = badgeFetcher.GetBadge(opponent);

                    GamesStack.Children.Add(view);
                }
            }
            else
            {
                NoDataLabel ndl = new NoDataLabel();
                GamesStack.Children.Add(ndl);
            }
        }
Beispiel #9
0
        void MatchClicked(Fixture match, string id)
        {
            HomeGoalStack.Children.Clear();
            AwayGoalStack.Children.Clear();
            HomeYellowStack.Children.Clear();
            AwayYellowStack.Children.Clear();

            BadgeFetcher badgeFetcher = new BadgeFetcher();

            int i = int.Parse(id);

            try
            {
                var items = MatchStack.Children.OfType <FixtureView>().ToList();

                ((FixtureView)items[currentlyClicked]).Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                ((FixtureView)items[i]).Background = new SolidColorBrush(Color.FromArgb(70, 32, 195, 179));
            }
            catch (Exception) { }

            currentlyClicked = i;

            ScoreView.Margin          = new Thickness(0, 0, 0, 1);
            ScoreView.txtKickoff.Text = match.KickOff.Split('@')[1];

            ScoreView.txtHomeTeam.Text    = match.HomeTeam;
            ScoreView.imgHomeBadge.Source = badgeFetcher.GetBadge(match.HomeTeam);
            ScoreView.imgHomeBadge.Tag    = match.HomeTeam;

            ScoreView.txtAwayTeam.Text    = match.AwayTeam;
            ScoreView.imgAwayBadge.Source = badgeFetcher.GetBadge(match.AwayTeam);
            ScoreView.imgAwayBadge.Tag    = match.AwayTeam;

            if (match.LoadingComplete)
            {
                ScoreView.txtScore.Text = match.HomeScore + " - " + match.AwayScore;
            }
            else
            {
                ScoreView.txtScore.Text = " vs. ";
            }

            Uri goalUri   = new Uri("pack://application:,,,/Insight;component/Resources/goal.png", UriKind.RelativeOrAbsolute);
            Uri redUri    = new Uri("pack://application:,,,/Insight;component/Resources/redCard.png", UriKind.RelativeOrAbsolute);
            Uri yellowUri = new Uri("pack://application:,,,/Insight;component/Resources/yellowCard.png", UriKind.RelativeOrAbsolute);

            foreach (var v in match.HomeScorers)
            {
                StatView view = new StatView();
                view.lblTeam.Text    = v.Scorer;
                view.imgBadge.Source = BitmapFrame.Create(goalUri);
                view.imgBadge.Margin = new Thickness(5);
                view.lblScore.Text   = v.Time.Length < 3
                    ? v.Time + "'"
                    : v.Time.Substring(0, 2) + "'";

                HomeGoalStack.Children.Add(view);
            }
            foreach (var v in match.AwayScorers)
            {
                StatView view = new StatView();
                view.lblTeam.Text    = v.Scorer;
                view.imgBadge.Source = BitmapFrame.Create(goalUri);
                view.imgBadge.Margin = new Thickness(5);
                view.lblScore.Text   = v.Time.Length < 3
                    ? v.Time + "'"
                    : v.Time.Substring(0, 2) + "'";

                AwayGoalStack.Children.Add(view);
            }


            foreach (var v in match.HomeRedCards)
            {
                StatView view = new StatView();
                view.lblTeam.Text    = v.Player;
                view.imgBadge.Source = BitmapFrame.Create(redUri);
                view.imgBadge.Margin = new Thickness(5);
                view.lblScore.Text   = "";

                HomeGoalStack.Children.Add(view);
            }
            foreach (var v in match.AwayRedCards)
            {
                StatView view = new StatView();
                view.lblTeam.Text    = v.Player;
                view.imgBadge.Source = BitmapFrame.Create(redUri);
                view.imgBadge.Margin = new Thickness(5);
                view.lblScore.Text   = "";

                AwayGoalStack.Children.Add(view);
            }

            if (match.LoadingComplete)
            {
                StatView viewHomeYellow = new StatView();
                viewHomeYellow.lblTeam.Text    = match.GetTeamYellows(match.HomeTeam).ToString();
                viewHomeYellow.imgBadge.Source = BitmapFrame.Create(yellowUri);
                viewHomeYellow.imgBadge.Margin = new Thickness(5);
                viewHomeYellow.lblScore.Text   = "";
                HomeYellowStack.Children.Add(viewHomeYellow);

                StatView viewAwayYellow = new StatView();
                viewAwayYellow.lblTeam.Text    = match.GetTeamYellows(match.AwayTeam).ToString();
                viewAwayYellow.imgBadge.Source = BitmapFrame.Create(yellowUri);
                viewAwayYellow.imgBadge.Margin = new Thickness(5);
                viewAwayYellow.lblScore.Text   = "";
                AwayYellowStack.Children.Add(viewAwayYellow);
            }
        }
Beispiel #10
0
        private void DisplayMatches()
        {
            MatchStack.Children.Clear();

            var date  = new DateTime(CurrentYear, CurrentMonth, 1);
            var month = date.ToString("MMMM");

            SelectedMonth.Content = month;

            var results = SelectedLeague.Results.Where(result => result.KickOff.Contains(month)).ToList();

            results.Reverse();
            var fixtures = SelectedLeague.Fixtures.Where(result => result.KickOff.Contains(month)).ToList();

            results.AddRange(fixtures);

            BadgeFetcher badgeFetcher = new BadgeFetcher();

            var sorted = results.GroupBy(res => res.KickOff.Split('@')[0]);

            if (sorted.Any())
            {
                foreach (var item in sorted)
                {
                    var lbl = new DateLabel();
                    lbl.LblDate.Text = item.Key;
                    MatchStack.Children.Add(lbl);

                    foreach (var res in item)
                    {
                        FixtureView view = new FixtureView();
                        view.Height          = 50;
                        view.Margin          = new Thickness(0, 0, 0, 1);
                        view.txtKickoff.Text = res.KickOff.Split('@')[1];

                        view.txtHomeTeam.Text    = res.HomeTeam;
                        view.imgHomeBadge.Source = badgeFetcher.GetBadge(res.HomeTeam);
                        view.txtAwayTeam.Text    = res.AwayTeam;
                        view.imgAwayBadge.Source = badgeFetcher.GetBadge(res.AwayTeam);

                        if (res.LoadingComplete)
                        {
                            view.txtScore.Text = res.HomeScore + " - " + res.AwayScore;
                        }
                        else
                        {
                            view.txtScore.Text = " vs. ";
                        }


                        int count = MatchStack.Children.OfType <FixtureView>().ToList().Count;

                        view.MouseDown += (sender, args) =>
                        {
                            MatchClicked(res, count.ToString());
                        };


                        MatchStack.Children.Add(view);
                    }
                }
            }
            else
            {
                NoDataLabel ndl = new NoDataLabel();
                MatchStack.Children.Add(ndl);
            }

            MatchScroller.ScrollToTop();
            MatchClicked(results.FirstOrDefault(), "0");
        }