Esempio n. 1
0
        public Windows_Club(CityClub c)
        {
            InitializeComponent();

            imgBudget.Source        = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\budget.png"));
            imgCurrentBudget.Source = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\budget.png"));
            imgBtnQuitter.Source    = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\return.png"));
            imgManager.Source       = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\manager.png"));

            _club          = c;
            lbClub.Content = c.name;

            if (c.manager != null)
            {
                lbEntraineur.Content = c.manager.ToString();
            }
            else
            {
                lbEntraineur.Content = FindResource("str_noManager").ToString();
            }

            lbBudget.Content        = Utils.FormatMoney(c.budget);
            lbCurrentBudget.Content = Utils.FormatMoney(c.budget);

            try
            {
                imgLogo.Source = new BitmapImage(new Uri(Utils.Logo(c)));
            }
            catch (Exception e)
            {
                Utils.Debug(e.ToString());
            }
            Palmares(c);
            FillGames();
            FillBudget();



            List <Player> newContracts = new List <Player>();

            foreach (Contract ct in c.allContracts)
            {
                if ((ct.beginning.Year == Session.Instance.Game.date.Year - 1 && ct.beginning.Month < 7) ||
                    (ct.beginning.Year == Session.Instance.Game.date.Year && ct.beginning.Month >= 7))
                {
                    newContracts.Add(ct.player);
                }
            }

            /*TODO
             * ViewPlayers viewNewPlayers = new ViewPlayers(newContracts, 11, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false);
             * viewNewPlayers.Full(spArrivees);
             */
            ViewPlayers viewPlayers = new ViewPlayers(c.Players(), 12, true, true, true, true, true, false, false, true, false, true, false, false, false, false, false, true, true, true);

            viewPlayers.Full(spPlayers);

            List <HistoriqueClubElement> lhce = new List <HistoriqueClubElement>();

            foreach (Tournament competition in Session.Instance.Game.kernel.Competitions)
            {
                foreach (KeyValuePair <int, Tournament> ancienne in competition.previousEditions)
                {
                    if (ancienne.Value.isChampionship && ancienne.Value.rounds[0].clubs.Contains(c))
                    {
                        int classement = 0;
                        //Si la compétition était active (tour 0 un tour de type championnat, pas inactif)
                        if ((ancienne.Value.rounds[0] as ChampionshipRound) != null)
                        {
                            classement = (ancienne.Value.rounds[0] as ChampionshipRound).Ranking().IndexOf(c) + 1;
                        }
                        else if ((ancienne.Value.rounds[0] as GroupsRound) != null)
                        {
                            GroupsRound rnd = (ancienne.Value.rounds[0] as GroupsRound);
                            for (int j = 0; j < rnd.groupsCount; j++)
                            {
                                if (rnd.groups[j].Contains(c))
                                {
                                    classement = rnd.Ranking(j).IndexOf(c);
                                }
                            }
                        }
                        lhce.Add(new HistoriqueClubElement {
                            Competition = ancienne.Value, Classement = classement, Annee = ancienne.Key
                        });
                    }
                }
            }
            lhce.Sort(new HistoriqueClubComparator());
            foreach (HistoriqueClubElement hce in lhce)
            {
                StackPanel spHistoryEntry = new StackPanel();
                spHistoryEntry.Orientation = Orientation.Horizontal;
                spHistoryEntry.Children.Add(ViewUtils.CreateLabelOpenWindow <Tournament>(hce.Competition, OpenTournament, hce.Annee.ToString(), "StyleLabel2", 11, 75));
                spHistoryEntry.Children.Add(ViewUtils.CreateLabelOpenWindow <Tournament>(hce.Competition, OpenTournament, hce.Competition.name, "StyleLabel2", 11, 125));
                spHistoryEntry.Children.Add(ViewUtils.CreateLabel(hce.Classement.ToString(), "StyleLabel2", 11, 50));
                spHistory.Children.Add(spHistoryEntry);
            }


            ChartValues <int> budgets         = new ChartValues <int>();
            ChartValues <int> centreFormation = new ChartValues <int>();
            ChartValues <int> attendance      = new ChartValues <int>();

            foreach (HistoricEntry eh in c.history.elements)
            {
                budgets.Add(eh.budget);
                centreFormation.Add(eh.formationFacilities);
                attendance.Add(eh.averageAttendance);
            }

            BudgetsCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_budget").ToString(),
                    Values = budgets,
                }
            };

            //Formation facilities

            CFCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_level").ToString(),
                    Values = centreFormation,
                }
            };

            //Average attendance

            AttendanceCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = FindResource("str_averageAttendance").ToString(),
                    Values = attendance,
                }
            };

            LabelsAnnees = new string[c.history.elements.Count];
            int i = 0;

            foreach (HistoricEntry eh in c.history.elements)
            {
                LabelsAnnees[i] = c.history.elements[i].date.Year.ToString();
                i++;
            }
            YFormatter = value => value.ToString("C");

            DataContext = this;

            if (c.records.BiggestWin != null)
            {
                lbBiggestWin.Content = c.records.BiggestWin.home.name + " " + c.records.BiggestWin.score1 + " - " + c.records.BiggestWin.score2 + " " + c.records.BiggestWin.away.name;
            }
            if (c.records.BiggestLose != null)
            {
                lbBiggestLose.Content = c.records.BiggestLose.home.name + " " + c.records.BiggestLose.score1 + " - " + c.records.BiggestLose.score2 + " " + c.records.BiggestLose.away.name;
            }
        }
Esempio n. 2
0
        public Windows_Match(Match match)
        {
            InitializeComponent();
            imgBtnQuitter.Source = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + "\\" + Utils.imagesFolderName + "\\return.png"));
            try
            {
                imgCompetition.Source = new BitmapImage(new Uri(Utils.LogoTournament(match.Tournament)));
            }
            catch
            {
                //If there is no image, a empty image is let
            }
            lbCompetition.Content = match.Tournament.name;
            imgLogoHome.Source    = new BitmapImage(new Uri(Utils.Logo(match.home)));
            imgLogoAway.Source    = new BitmapImage(new Uri(Utils.Logo(match.away)));
            lbStade.Content       = match.stadium.name;
            lbAffluence.Content   = match.attendance + " " + FindResource("str_spectators").ToString();
            lbEquipe1.Content     = match.home.name;
            lbEquipe2.Content     = match.away.name;
            lbScore1.Content      = match.score1;
            lbScore2.Content      = match.score2;
            lbScoreMt1.Content    = match.ScoreHalfTime1;
            lbScoreMt2.Content    = match.ScoreHalfTime2;
            lbTirs1.Content       = match.statistics.HomeShoots;
            lbTirs2.Content       = match.statistics.AwayShoots;
            pbTirs.Maximum        = match.statistics.HomeShoots + match.statistics.AwayShoots;
            pbTirs.Value          = match.statistics.HomeShoots;
            lbPossession1.Content = match.statistics.HomePossession + "%";
            lbPossession2.Content = match.statistics.AwayPossession + "%";
            pbPossession.Maximum  = match.statistics.HomePossession + match.statistics.AwayPossession;
            pbPossession.Value    = match.statistics.HomePossession;
            lbOdd1.Content        = match.odd1.ToString("0.00");
            lbOddD.Content        = match.oddD.ToString("0.00");
            lbOdd2.Content        = match.odd2.ToString("0.00");
            if (match.prolongations)
            {
                spScoreLine.Children.Insert(3, ViewUtils.CreateLabel("ap", "StyleLabel2", 10, 20));
            }
            if (match.PenaltyShootout)
            {
                StackPanel spTab = new StackPanel();
                spTab.Orientation         = Orientation.Vertical;
                spTab.HorizontalAlignment = HorizontalAlignment.Center;
                spTab.Height = 40;

                StackPanel spTab1 = new StackPanel();
                spTab1.Orientation = Orientation.Horizontal;
                spTab1.Children.Add(ViewUtils.CreateLabel(match.penaltyShootout1.ToString(), "StyleLabel2", 10, 20));
                foreach (bool b in match.penaltyShoots1)
                {
                    Border border = new Border();
                    border.Style        = Application.Current.FindResource("StyleBorderCalendar") as Style;
                    border.CornerRadius = new CornerRadius(3);
                    border.Height       = 10;
                    border.Width        = 10;
                    border.Margin       = new Thickness(5);
                    border.Background   = b == true ? Brushes.Lime : Brushes.Red;
                    spTab1.Children.Add(border);
                }

                StackPanel spTab2 = new StackPanel();
                spTab2.Orientation = Orientation.Horizontal;
                spTab2.Children.Add(ViewUtils.CreateLabel(match.penaltyShootout2.ToString(), "StyleLabel2", 10, 20));
                foreach (bool b in match.penaltyShoots2)
                {
                    Border border = new Border();
                    border.Style        = Application.Current.FindResource("StyleBorderCalendar") as Style;
                    border.CornerRadius = new CornerRadius(3);
                    border.Height       = 10;
                    border.Width        = 10;
                    border.Margin       = new Thickness(5);
                    border.Background   = b == true ? Brushes.Lime : Brushes.Red;
                    spTab2.Children.Add(border);
                }

                spTab.Children.Add(spTab1);
                spTab.Children.Add(spTab2);

                spMain.Children.Insert(2, spTab);
            }

            spCompositions.Children.Add(ViewUtils.CreateCompositionPanel(match.compo1, false, match, match.Subs1));
            spCompositions.Children.Add(ViewUtils.CreateCompositionPanel(match.compo2, false, match, match.Subs2));

            string strOg  = FindResource("str_og").ToString();
            string strPen = FindResource("str_pen").ToString();

            foreach (MatchEvent em in match.events)
            {
                string icone = "";
                switch (em.type)
                {
                case GameEvent.Goal: icone = "goal.png";
                    break;

                case GameEvent.PenaltyGoal: icone = "goal.png";
                    break;

                case GameEvent.AgGoal:
                    icone = "goal.png";
                    break;

                case GameEvent.YellowCard:
                    icone = "yellow_card.png";
                    break;

                case GameEvent.RedCard:
                    icone = "red_card.png";
                    break;
                }
                string c1   = "";
                string c2   = "";
                string c3   = "";
                string c4   = "";
                string img1 = "";
                string img2 = "";
                if (em.club == match.home)
                {
                    img1 = Utils.Image(icone);
                    c1   = em.MinuteToString;
                    c2   = em.player.firstName + " " + em.player.lastName;
                    if (em.type == GameEvent.PenaltyGoal)
                    {
                        c2 += " (" + strPen + ")";
                    }

                    if (em.type == GameEvent.AgGoal)
                    {
                        c2 += " (" + strOg + ")";
                    }
                }
                else
                {
                    img2 = Utils.Image(icone);
                    c4   = em.MinuteToString;
                    c3   = em.player.firstName + " " + em.player.lastName;
                    if (em.type == GameEvent.PenaltyGoal)
                    {
                        c3 += " (" + strPen + ")";
                    }

                    if (em.type == GameEvent.AgGoal)
                    {
                        c3 += " (" + strOg + ")";
                    }
                }
                if (em.type != GameEvent.Shot)
                {
                    StackPanel spEv = new StackPanel();
                    spEv.Orientation = Orientation.Horizontal;
                    spEv.Width       = 400;

                    Image im1 = new Image();
                    im1.Width = 25;
                    if (img1 != "")
                    {
                        im1.Source = new BitmapImage(new Uri(img1));
                    }

                    Label l1 = ViewUtils.CreateLabel(c1, "StyleLabel2", 11, 40);
                    l1.HorizontalContentAlignment = HorizontalAlignment.Center;

                    Label l2 = ViewUtils.CreateLabel(c2, "StyleLabel2", 11, 130);
                    l2.HorizontalContentAlignment = HorizontalAlignment.Left;

                    Label l3 = ViewUtils.CreateLabel(c3, "StyleLabel2", 11, 130);
                    l3.HorizontalContentAlignment = HorizontalAlignment.Right;

                    Label l4 = ViewUtils.CreateLabel(c4, "StyleLabel2", 11, 40);
                    l4.HorizontalContentAlignment = HorizontalAlignment.Center;

                    Image im2 = new Image();
                    im2.Width = 25;
                    if (img2 != "")
                    {
                        im2.Source = new BitmapImage(new Uri(img2));
                    }

                    spEv.Children.Add(im1);
                    spEv.Children.Add(l1);
                    spEv.Children.Add(l2);
                    spEv.Children.Add(l3);
                    spEv.Children.Add(l4);
                    spEv.Children.Add(im2);
                    spEvenements.Children.Add(spEv);
                }
            }

            FillSubstitutions(match);
            DrawTimeline(match);

            List <Media> presentsMedias = new List <Media>();

            foreach (KeyValuePair <TheManager.Media, Journalist> j in match.journalists)
            {
                StackPanel spJournalists = new StackPanel();
                spJournalists.Orientation = Orientation.Vertical;
                spJournalists.Children.Add(ViewUtils.CreateMediaLogo(j.Key, 80, 40));
                spJournalists.Margin = new Thickness(15);
                Label labelJournalist = ViewUtils.CreateLabelOpenWindow <Media>(j.Key, OpenMedia, j.Value.ToString(), "StyleLabel2", 11, -1);
                labelJournalist.VerticalContentAlignment = VerticalAlignment.Center;

                if (presentsMedias.Contains(j.Key))
                {
                    (spMedias.Children[presentsMedias.IndexOf(j.Key)] as StackPanel).Children.Add(labelJournalist);
                }
                else
                {
                    spJournalists.Children.Add(labelJournalist);
                    presentsMedias.Add(j.Key);
                    spMedias.Children.Add(spJournalists);
                }
            }
        }