Esempio n. 1
0
        private void RefreshTransferListPanel()
        {
            spTransferList.Children.Clear();
            foreach (Club c in Session.Instance.Game.club.Championship.rounds[0].clubs)
            {
                CityClub cc = c as CityClub;
                if (cc != null)
                {
                    foreach (ContractOffer co in cc.clubTransfersManagement.offersHistory)
                    {
                        StackPanel spT = new StackPanel();
                        spT.Orientation = Orientation.Horizontal;
                        Label lbPlayer = ViewUtils.CreateLabel(co.Player.lastName, "StyleLabel2", 8, 40);
                        lbPlayer.MouseLeftButtonUp += (object sender, System.Windows.Input.MouseButtonEventArgs e) =>
                        { Windows_Joueur wj = new Windows_Joueur(co.Player); wj.Show(); };
                        spT.Children.Add(lbPlayer);
                        string from = "Libre";
                        if (co.Origin != null)
                        {
                            from = co.Origin.shortName;
                        }
                        spT.Children.Add(ViewUtils.CreateLabel(from, "StyleLabel2", 8, 55));
                        Label labelClub = ViewUtils.CreateLabel(cc.shortName, "StyleLabel2", 8, 55);
                        labelClub.MouseLeftButtonUp += (object sender, System.Windows.Input.MouseButtonEventArgs e) =>
                        { Windows_Club wc = new Windows_Club(cc); wc.Show(); };
                        spT.Children.Add(labelClub);
                        spT.Children.Add(ViewUtils.CreateLabel(co.TransferIndemnity + "€", "StyleLabel2", 8, 60));


                        spT.Children.Add(ViewUtils.CreateLabel(co.Result.ToString(), "StyleLabel2", 8, 60));
                        spTransferList.Children.Add(spT);
                    }
                }
            }
        }
Esempio n. 2
0
        public void FillBudget()
        {
            DateTime beginSeason = (Session.Instance.Game.date.Month <= 6 || (Session.Instance.Game.date.Month == 6 && Session.Instance.Game.date.Day < 15)) ? new DateTime(Session.Instance.Game.date.Year - 1, 6, 15) : new DateTime(Session.Instance.Game.date.Year, 6, 15);
            CityClub cc          = _club as CityClub;

            if (cc != null)
            {
                Dictionary <BudgetModificationReason, double> depenses = new Dictionary <BudgetModificationReason, double>();
                Dictionary <BudgetModificationReason, double> incomes  = new Dictionary <BudgetModificationReason, double>();

                foreach (BudgetEntry be in cc.budgetHistory)
                {
                    StackPanel spEntry = new StackPanel();
                    spEntry.Orientation = Orientation.Horizontal;
                    spEntry.Children.Add(ViewUtils.CreateLabel(be.Date.ToShortDateString(), "StyleLabel2", 12, 90));
                    spEntry.Children.Add(ViewUtils.CreateLabel(Utils.FormatMoney(be.Amount), "StyleLabel2", 12, 100, be.Amount < 0 ? Brushes.Red : null));
                    spEntry.Children.Add(ViewUtils.CreateLabel(Utils.GetDescription(be.Reason), "StyleLabel2", 12, 125));
                    spBudget.Children.Add(spEntry);

                    if (Utils.IsBefore(beginSeason, be.Date))
                    {
                        AddValueToDictionnary(be.Amount < 0 ? depenses : incomes, be.Reason, be.Amount);
                    }
                }

                CreatePieChart(depenses);
                CreatePieChart(incomes);
            }
        }
        private void CreateCheckBox(Tournament t, StackPanel box, bool disable)
        {
            StackPanel spTournament = new StackPanel();

            spTournament.Orientation = Orientation.Horizontal;

            TextBlock l = new TextBlock();

            l.Text       = "   ";
            l.Margin     = new Thickness(0, 0, 5, 0);
            l.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom(t.color.ToHexa()));
            spTournament.Children.Add(l);

            if (!disable)
            {
                CheckBox cb = new CheckBox();
                cb.IsChecked  = true;
                cb.Content    = t.name;
                cb.Style      = FindResource("StyleCheckBox") as Style;
                cb.Foreground = Brushes.LightGreen;
                cb.Click     += CheckboxComp_Click;
                _checkbox.Add(cb);
                spTournament.Children.Add(cb);
            }
            else
            {
                spTournament.Children.Add(ViewUtils.CreateLabel(t.name, "StyleLabel2", -1, -1));
            }
            box.Children.Add(spTournament);
        }
Esempio n. 4
0
        private void SelectedRecords(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_biggestScore").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(_competition.statistics.LargerScore != null ? _competition.statistics.LargerScore.home.name + " " + _competition.statistics.LargerScore.score1 + "-" + _competition.statistics.LargerScore.score2 + " " + _competition.statistics.LargerScore.away.name : "Pas encore de match joué", "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_biggestWin").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(_competition.statistics.BiggerScore != null ? _competition.statistics.BiggerScore.home.name + " " + _competition.statistics.BiggerScore.score1 + "-" + _competition.statistics.BiggerScore.score2 + " " + _competition.statistics.BiggerScore.away.name : "Pas encore de match joué", "StyleLabel2", 12, -1));

            KeyValuePair <int, KeyValuePair <Club, int> > bestAttack   = new KeyValuePair <int, KeyValuePair <Club, int> >(-1, new KeyValuePair <Club, int>(null, -1));
            KeyValuePair <int, KeyValuePair <Club, int> > bestDefense  = new KeyValuePair <int, KeyValuePair <Club, int> >(-1, new KeyValuePair <Club, int>(null, -1));
            KeyValuePair <int, KeyValuePair <Club, int> > worstAttack  = new KeyValuePair <int, KeyValuePair <Club, int> >(-1, new KeyValuePair <Club, int>(null, -1));
            KeyValuePair <int, KeyValuePair <Club, int> > worstDefense = new KeyValuePair <int, KeyValuePair <Club, int> >(-1, new KeyValuePair <Club, int>(null, -1));

            foreach (KeyValuePair <int, Tournament> t in _baseTournament.previousEditions)
            {
                if (t.Value.isChampionship)
                {
                    Round r = t.Value.rounds[0];
                    foreach (Club c in r.clubs)
                    {
                        int goalsFor     = r.GoalsFor(c);
                        int goalsAgainst = r.GoalsAgainst(c);
                        if (goalsFor > bestAttack.Value.Value || bestAttack.Key == -1)
                        {
                            bestAttack = new KeyValuePair <int, KeyValuePair <Club, int> >(t.Key, new KeyValuePair <Club, int>(c, goalsFor));
                        }
                        if (goalsFor < worstAttack.Value.Value || worstAttack.Key == -1)
                        {
                            worstAttack = new KeyValuePair <int, KeyValuePair <Club, int> >(t.Key, new KeyValuePair <Club, int>(c, goalsFor));
                        }
                        if (goalsAgainst < bestDefense.Value.Value || bestDefense.Key == -1)
                        {
                            bestDefense = new KeyValuePair <int, KeyValuePair <Club, int> >(t.Key, new KeyValuePair <Club, int>(c, goalsAgainst));
                        }
                        if (goalsAgainst > worstDefense.Value.Value || worstDefense.Key == -1)
                        {
                            worstDefense = new KeyValuePair <int, KeyValuePair <Club, int> >(t.Key, new KeyValuePair <Club, int>(c, goalsAgainst));
                        }
                    }
                }
                else
                {
                    spRanking.Children.Add(ViewUtils.CreateLabel("Information non disponible pour une coupe", "StyleLabel2", 12, -1));
                }
            }

            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_bestAttack").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(bestAttack.Key == -1 ? "Pas encore de match joué" : bestAttack.Value.Key + " (" + bestAttack.Value.Value + " " + FindResource("str_mgoals").ToString() + ", " + bestAttack.Key + ")", "StyleLabel2", 12, -1));

            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_bestDefense").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(bestDefense.Key == -1 ? "Pas encore de match joué" : bestDefense.Value.Key + " (" + bestDefense.Value.Value + " " + FindResource("str_mgoals").ToString() + ", " + bestDefense.Key + ")", "StyleLabel2", 12, -1));

            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_worstAttack").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(worstAttack.Key == -1 ? "Pas encore de match joué" : worstAttack.Value.Key + " (" + worstAttack.Value.Value + " " + FindResource("str_mgoals").ToString() + ", " + worstAttack.Key + ")", "StyleLabel2", 12, -1));

            spRanking.Children.Add(ViewUtils.CreateLabel(FindResource("str_worstDefense").ToString(), "StyleLabel2", 12, -1));
            spRanking.Children.Add(ViewUtils.CreateLabel(worstDefense.Key == -1 ? "Pas encore de match joué" : worstDefense.Value.Key + " (" + worstDefense.Value.Value + " " + FindResource("str_mgoals").ToString() + ", " + worstDefense.Key + ")", "StyleLabel2", 12, -1));
        }
Esempio n. 5
0
        private void SelectedSeasonsClubs(object sender, RoutedEventArgs e)
        {
            Dictionary <Club, int> clubs = new Dictionary <Club, int>();

            spRanking.Children.Clear();
            foreach (KeyValuePair <int, Tournament> t in _competition.previousEditions)
            {
                if (t.Value.isChampionship)
                {
                    foreach (Club c in t.Value.rounds[0].clubs)
                    {
                        if (!clubs.ContainsKey(c))
                        {
                            clubs.Add(c, 0);
                        }
                        clubs[c]++;
                    }
                }
                else
                {
                    List <Club> clubsList = new List <Club>();
                    foreach (Round r in t.Value.rounds)
                    {
                        foreach (Club c in r.clubs)
                        {
                            if (!clubsList.Contains(c))
                            {
                                clubsList.Add(c);
                            }
                        }
                    }
                    foreach (Club c in clubsList)
                    {
                        if (!clubs.ContainsKey(c))
                        {
                            clubs.Add(c, 0);
                        }
                        clubs[c]++;
                    }
                }
            }
            List <KeyValuePair <Club, int> > list = clubs.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));
            foreach (KeyValuePair <Club, int> club in list)
            {
                StackPanel spClub = new StackPanel();
                spClub.Orientation = Orientation.Horizontal;
                spClub.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                spClub.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                spClub.Children.Add(ViewUtils.CreateLabel(club.Value.ToString(), "StyleLabel2", 12, 50, null, null, true));
                spRanking.Children.Add(spClub);
            }
        }
        private void FillContinent(Continent c)
        {
            StackPanel spContinent = _order < 3 ? (spWorld.Children[_order] as Border).Child as StackPanel : ((spWorld.Children[3] as StackPanel).Children[_order - 3] as Border).Child as StackPanel;

            spContinent.Children.Add(ViewUtils.CreateLabel(c.Name(), "StyleLabel2Center", 16, -1));

            StackPanel box = new StackPanel();

            box.Orientation = Orientation.Vertical;

            if (c.Tournaments().Count > 0)
            {
                Label lb = new Label();
                lb.Content    = c.Name();
                lb.Style      = FindResource("StyleLabel2") as Style;
                lb.FontWeight = FontWeights.Bold;
                box.Children.Add(lb);
                foreach (Tournament cp in c.Tournaments())
                {
                    CreateCheckBox(cp, box, true);
                }
            }
            foreach (Country p in c.countries)
            {
                if (p.Tournaments().Count > 0)
                {
                    Label lb = new Label();
                    lb.Content = p.Name();
                    lb.Style   = FindResource("StyleLabel2") as Style;
                    Image i = new Image();
                    i.Source = new BitmapImage(new Uri(Utils.Flag(p), UriKind.RelativeOrAbsolute));
                    i.Width  = 30;
                    i.Height = 15;
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Children.Add(i);
                    sp.Children.Add(lb);
                    box.Children.Add(sp);
                    foreach (Tournament cp in p.Tournaments())
                    {
                        if (cp.isChampionship)
                        {
                            CreateCheckBox(cp, box, false);
                        }
                    }
                }
            }
            spContinent.Children.Add(box);

            _order++;
        }
        private void ActionsMatch()
        {
            List <KeyValuePair <string, string> > reversedActions = new List <KeyValuePair <string, string> >(_matchs[0].actions);

            reversedActions.Reverse();
            spActions.Children.Clear();
            foreach (KeyValuePair <string, string> kvp in reversedActions)
            {
                StackPanel spAction = new StackPanel();
                spAction.Orientation = Orientation.Horizontal;
                spAction.Children.Add(ViewUtils.CreateLabel(kvp.Key, "StyleLabel2", 11, 30, System.Windows.Media.Brushes.Salmon, null, true));
                spAction.Children.Add(ViewUtils.CreateLabel(kvp.Value, "StyleLabel2", 11, -1));
                spActions.Children.Add(spAction);
            }
        }
Esempio n. 8
0
        private void Map_ShapeIdentified(object sender, AxMapWinGIS._DMapEvents_ShapeIdentifiedEvent e)
        {
            if (e.shapeIndex > -1)
            {
                spJournalistInfo.Children.Clear();

                Journalist j = _media.journalists[_indexOrders[e.shapeIndex]];
                spJournalistInfo.Children.Add(ViewUtils.CreateLabel(j.ToString() + " (" + j.age + " ans)", "StyleLabel2", 12, -1));
                spJournalistInfo.Children.Add(ViewUtils.CreateLabel("Basé à " + j.baseCity.Name, "StyleLabel2", 12, -1));
                List <Match> commentedGames = j.CommentedGames;
                commentedGames.Sort(new MatchDateComparator());
                ViewMatches view = new ViewMatches(commentedGames, true, false, false, false, false, true);
                view.Full(spMatches);
            }
        }
Esempio n. 9
0
 private void FillSubstitutions(Match match)
 {
     foreach (Substitution s in match.substitutions)
     {
         StackPanel spSub = new StackPanel();
         spSub.Orientation = Orientation.Horizontal;
         spSub.Children.Add(ViewUtils.CreateLabel(s.PlayerOut.firstName + " " + s.PlayerOut.lastName, "StyleLabel2", 11, 120, Brushes.LightSalmon));
         spSub.Children.Add(ViewUtils.CreateLabel(s.PlayerIn.firstName + " " + s.PlayerIn.lastName, "StyleLabel2", 11, 120, Brushes.Lime));
         spSub.Children.Add(ViewUtils.CreateLabel((s.Minute + 45).ToString() + "°", "StyleLabel2", 11, 30));
         if (match.compo1.Contains(s.PlayerOut))
         {
             spHomeSubstitutions.Children.Add(spSub);
         }
         else
         {
             spAwaySubstitutions.Children.Add(spSub);
         }
     }
 }
Esempio n. 10
0
        private void SelectedStatShot(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, float> tirs        = new Dictionary <Club, float>();
            Dictionary <Club, int>   playedGames = new Dictionary <Club, int>();

            foreach (Round r in _competition.rounds)
            {
                foreach (Match m in r.matches)
                {
                    if (!tirs.ContainsKey(m.home))
                    {
                        tirs.Add(m.home, 0);
                        playedGames.Add(m.home, 0);
                    }
                    if (!tirs.ContainsKey(m.away))
                    {
                        tirs.Add(m.away, 0);
                        playedGames.Add(m.away, 0);
                    }
                    tirs[m.home] += m.statistics.HomeShoots;
                    tirs[m.away] += m.statistics.AwayShoots;
                    playedGames[m.home]++;
                    playedGames[m.away]++;
                }
            }
            List <KeyValuePair <Club, float> > list = tirs.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            foreach (KeyValuePair <Club, float> kvp in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(kvp.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(kvp.Key.name, "StyleLabel2", 12, 250));
                sp.Children.Add(ViewUtils.CreateLabel(kvp.Value.ToString(), "StyleLabel2", 12, 100));
                sp.Children.Add(ViewUtils.CreateLabel((kvp.Value / playedGames[kvp.Key]).ToString("0.00") + "/m", "StyleLabel2", 12, 100));
                sp.Children.Add(ViewUtils.CreateLabel(playedGames[kvp.Key].ToString(), "StyleLabel2", 12, 100));
                spRanking.Children.Add(sp);
            }
        }
Esempio n. 11
0
        private void CreateChart(string[] years, string title, IChartValues values, bool isMoney, string axisYtitle, double minValue, double maxValue, string axisXtitle)
        {
            Label labelTitle = ViewUtils.CreateLabel(title, "StyleLabel2Center", 18, -1);

            spMain.Children.Add(labelTitle);

            SeriesCollection averageClubLevelInGameCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = title,
                    Values = values,
                }
            };

            CartesianChart cc = new CartesianChart();

            cc.Width  = 800;
            cc.Height = 375;

            cc.Series = averageClubLevelInGameCollection;

            Axis axisY = new Axis();

            axisY.Title    = axisYtitle;
            axisY.MinValue = minValue;
            axisY.MaxValue = maxValue;

            if (isMoney)
            {
                axisY.LabelFormatter = YFormatter;
            }


            Axis axisX = new Axis();

            axisX.Title  = axisXtitle;
            axisX.Labels = years;

            cc.AxisY.Add(axisY);
            cc.AxisX.Add(axisX);
            spMain.Children.Add(cc);
        }
Esempio n. 12
0
        private void SelectedStatsYears(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            StackPanel spTitle = new StackPanel();

            spTitle.Orientation = Orientation.Horizontal;
            spTitle.Children.Add(ViewUtils.CreateLabel(FindResource("str_year").ToString(), "StyleLabel2", 12, 150));
            spTitle.Children.Add(ViewUtils.CreateLabel(FindResource("str_goalsByGame").ToString(), "StyleLabel2", 12, 80));
            spTitle.Children.Add(ViewUtils.CreateLabel(FindResource("str_goals").ToString(), "StyleLabel2", 12, 80));
            spTitle.Children.Add(ViewUtils.CreateLabel(FindResource("str_YCByGame").ToString(), "StyleLabel2", 12, 80));
            spTitle.Children.Add(ViewUtils.CreateLabel(FindResource("str_RCByGame").ToString(), "StyleLabel2", 12, 80));
            spRanking.Children.Add(spTitle);


            foreach (KeyValuePair <int, Tournament> t in _baseTournament.previousEditions)
            {
                int gameCount   = 0;
                int goalCount   = 0;
                int yellowCards = 0;
                int redCards    = 0;

                foreach (Round r in t.Value.rounds)
                {
                    foreach (Match m in r.matches)
                    {
                        gameCount++;
                        goalCount   += m.score1 + m.score2;
                        yellowCards += m.YellowCards;
                        redCards    += m.RedCards;
                    }
                }

                StackPanel spYear = new StackPanel();
                spYear.Orientation = Orientation.Horizontal;
                spYear.Children.Add(ViewUtils.CreateLabel(t.Key.ToString(), "StyleLabel2", 12, 150));
                spYear.Children.Add(ViewUtils.CreateLabel((goalCount / (gameCount + 0.0)).ToString("0.00"), "StyleLabel2", 12, 80));
                spYear.Children.Add(ViewUtils.CreateLabel(goalCount.ToString(), "StyleLabel2", 12, 80));
                spYear.Children.Add(ViewUtils.CreateLabel((yellowCards / (gameCount + 0.0)).ToString("0.00"), "StyleLabel2", 12, 80));
                spYear.Children.Add(ViewUtils.CreateLabel((redCards / (gameCount + 0.0)).ToString("0.00"), "StyleLabel2", 12, 80));
                spRanking.Children.Add(spYear);
            }
        }
Esempio n. 13
0
        private void SelectedPotential(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();
            List <Club> clubs = new List <Club>(_competition.rounds[_indexTour].clubs);

            clubs.Sort(new ClubComparator(ClubAttribute.POTENTIEL, false));
            int i = 0;

            foreach (Club c in clubs)
            {
                i++;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", 12, 30));
                sp.Children.Add(ViewUtils.CreateLogo(c, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(c.Potential().ToString("0.0"), "StyleLabel2", 12, 50));
                spRanking.Children.Add(sp);
            }
        }
Esempio n. 14
0
        private void SelectedGoalscorers(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            foreach (KeyValuePair <Player, int> goalscorer in _competition.Goalscorers())
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                if (goalscorer.Key.Club != null)
                {
                    sp.Children.Add(ViewUtils.CreateLogo(goalscorer.Key.Club, 25, 25));
                }
                else
                {
                    sp.Children.Add(ViewUtils.CreateFlag(goalscorer.Key.nationality, 25, 18));
                }
                sp.Children.Add(ViewUtils.CreateLabel(goalscorer.Key.Name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(goalscorer.Value.ToString(), "StyleLabel2", 12, 50));
                spRanking.Children.Add(sp);
            }
        }
Esempio n. 15
0
        private void SelectedAttendance(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, int> attendances = new Dictionary <Club, int>();

            Round r = _competition.rounds[_indexTour];

            foreach (Club c in r.clubs)
            {
                attendances.Add(c, 0);
                int count = 0;
                foreach (Match m in r.matches)
                {
                    if (m.home == c)
                    {
                        count++;
                        attendances[c] += m.attendance;
                    }
                }
                if (count > 0)
                {
                    attendances[c] /= count;
                }
            }

            List <KeyValuePair <Club, int> > list = attendances.ToList();

            list.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

            foreach (KeyValuePair <Club, int> club in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(club.Value.ToString(), "StyleLabel2", 12, 75, null, null, true));
                spRanking.Children.Add(sp);
            }
        }
Esempio n. 16
0
        private void SelectedPalmaresClubs(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            Dictionary <Club, List <int> > palmares = new Dictionary <Club, List <int> >();

            foreach (KeyValuePair <int, Tournament> arc in _competition.previousEditions)
            {
                Club winner = arc.Value.Winner();
                if (winner != null)
                {
                    if (!palmares.ContainsKey(winner))
                    {
                        palmares.Add(winner, new List <int>());
                    }
                    palmares[winner].Add(arc.Key);
                }
            }

            List <KeyValuePair <Club, List <int> > > list = palmares.ToList();

            list.Sort((pair1, pair2) => pair2.Value.Count.CompareTo(pair1.Value.Count));

            foreach (KeyValuePair <Club, List <int> > club in list)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(ViewUtils.CreateLogo(club.Key, 25, 25));
                sp.Children.Add(ViewUtils.CreateLabel(club.Key.name, "StyleLabel2", 12, 200));
                sp.Children.Add(ViewUtils.CreateLabel(club.Value.Count.ToString(), "StyleLabel2", 12, 50, null, null, true));
                StringBuilder bld = new StringBuilder();
                foreach (float years in club.Value)
                {
                    bld.Append(years + ", ");
                }
                string yearList = bld.ToString();
                sp.Children.Add(ViewUtils.CreateLabel(yearList, "StyleLabel2", 12, 250));
                spRanking.Children.Add(sp);
            }
        }
Esempio n. 17
0
        private void SelectedPalmaresYears(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();

            foreach (KeyValuePair <int, Tournament> arc in _competition.previousEditions)
            {
                Club winner = arc.Value.Winner();

                Round t = arc.Value.rounds[arc.Value.rounds.Count - 1];
                //If the final round was not inactive, we can make the palmares
                if (t.matches.Count > 0)
                {
                    int        year = arc.Key;
                    StackPanel sp   = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Children.Add(ViewUtils.CreateLabel(year.ToString(), "StyleLabel2", 12, 100));
                    sp.Children.Add(ViewUtils.CreateLogo(winner, 25, 25));
                    sp.Children.Add(ViewUtils.CreateLabel(winner.name, "StyleLabel2", 12, 200));
                    spRanking.Children.Add(sp);
                }
            }
        }
Esempio n. 18
0
        private void SelectedBudget(object sender, RoutedEventArgs e)
        {
            spRanking.Children.Clear();
            List <Club> clubs = new List <Club>(_competition.rounds[_indexTour].clubs);

            clubs.Sort(new ClubComparator(ClubAttribute.BUDGET, false));
            int i = 0;

            foreach (Club c in clubs)
            {
                if (c as CityClub != null)
                {
                    i++;
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;
                    sp.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2", 12, 30));
                    sp.Children.Add(ViewUtils.CreateLogo(c, 25, 25));
                    sp.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 200));
                    sp.Children.Add(ViewUtils.CreateLabel(Utils.FormatMoney((c as CityClub).budget), "StyleLabel2", 12, 100));
                    spRanking.Children.Add(sp);
                }
            }
        }
Esempio n. 19
0
        private void FillFifaRanking()
        {
            int i = 0;

            StackPanel spHead = new StackPanel();

            spHead.Orientation = Orientation.Horizontal;
            spHead.Children.Add(ViewUtils.CreateLabel("", "StyleLabel2Center", -1, 50, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("Nation", "StyleLabel2", -1, 315, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("Points", "StyleLabel2Center", -1, 75, null, null, true));
            spFIFARanking.Children.Add(spHead);

            foreach (NationalTeam nt in Session.Instance.Game.kernel.FifaRanking())
            {
                i++;
                StackPanel spTeam = new StackPanel();
                spTeam.Orientation = Orientation.Horizontal;
                spTeam.Children.Add(ViewUtils.CreateLabel(i.ToString(), "StyleLabel2Center", -1, 50));
                spTeam.Children.Add(ViewUtils.CreateFlag(nt.country, 40, 25));
                spTeam.Children.Add(ViewUtils.CreateLabel(nt.name, "StyleLabel2", -1, 275));
                spTeam.Children.Add(ViewUtils.CreateLabel(nt.officialFifaPoints.ToString("0.00"), "StyleLabel2Center", -1, 75));
                spFIFARanking.Children.Add(spTeam);
            }
        }
Esempio n. 20
0
 public void Palmares(CityClub club)
 {
     foreach (Tournament c in Session.Instance.Game.kernel.Competitions)
     {
         int    nombre = 0;
         string annees = "";
         foreach (KeyValuePair <int, Tournament> archive in c.previousEditions)
         {
             if (archive.Value.isChampionship)
             {
                 if (archive.Value.rounds[0].Winner() == club)
                 {
                     nombre++;
                 }
             }
             else
             {
                 Round t = archive.Value.rounds[archive.Value.rounds.Count - 1];
                 if (t.Winner() == club)
                 {
                     nombre++;
                 }
             }
         }
         if (nombre > 0)
         {
             StackPanel spPalmaresEntry = new StackPanel()
             {
                 Orientation = Orientation.Horizontal
             };
             spPalmaresEntry.Children.Add(ViewUtils.CreateLabel(c.name, "StyleLabel2", 12, 175));
             spPalmaresEntry.Children.Add(ViewUtils.CreateLabel(nombre.ToString(), "StyleLabel2", 12, 75));
             spPalmares.Children.Add(spPalmaresEntry);
         }
     }
 }
Esempio n. 21
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. 22
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);
                }
            }
        }
Esempio n. 23
0
        private void DrawTimeline(Match match)
        {
            string strOg  = FindResource("str_og").ToString();
            string strPen = FindResource("str_pen").ToString();

            double canvasWidth = 700;

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
            rect.Width  = canvasWidth;
            rect.Height = 8;
            Canvas.SetTop(rect, 46);
            rect.Stroke = System.Windows.Media.Brushes.Gray;
            canvasEvents.Children.Add(rect);

            MatchEvent last = null;

            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 eventText = "";
                string eventImg  = "";
                eventImg  = Utils.Image(icone);
                eventText = em.player.firstName + " " + em.player.lastName;
                if (em.type == GameEvent.PenaltyGoal)
                {
                    eventText += " (" + strPen + ")";
                }

                if (em.type == GameEvent.AgGoal)
                {
                    eventText += " (" + strOg + ")";
                }

                eventText += " (" + em.EventMinute + "')";

                if (em.type != GameEvent.Shot)
                {
                    Label labelEvent = ViewUtils.CreateLabel(eventText, "StyleLabel2Center", 10, 150);

                    Image imEvent = new Image();
                    imEvent.Width  = 20;
                    imEvent.Source = new BitmapImage(new Uri(eventImg));

                    Canvas.SetLeft(labelEvent, ((em.EventMinute / 90.0) * canvasWidth) - 75);
                    Canvas.SetLeft(imEvent, ((em.EventMinute / 90.0) * canvasWidth));
                    if (em.club == match.home)
                    {
                        Canvas.SetTop(labelEvent, (last != null && em.EventMinute - last.EventMinute < 5 && em.club == last.club) ? 10 : 20);
                        Canvas.SetTop(imEvent, 36);
                    }
                    else
                    {
                        Canvas.SetTop(imEvent, 52);
                        Canvas.SetTop(labelEvent, (last != null && em.EventMinute - last.EventMinute < 5 && em.club == last.club) ? 80 : 70);
                    }

                    canvasEvents.Children.Add(labelEvent);
                    canvasEvents.Children.Add(imEvent);
                }
                last = em;
            }
        }
Esempio n. 24
0
        private void FillNextMatchPanel()
        {
            spNextMatch.Children.Clear();

            Match next = Session.Instance.Game.club.NextGame;

            if (next != null)
            {
                //Create the 3 stacks panels
                StackPanel spHomeTeam = new StackPanel();
                spHomeTeam.Orientation         = Orientation.Vertical;
                spHomeTeam.HorizontalAlignment = HorizontalAlignment.Center;
                StackPanel spAwayTeam = new StackPanel();
                spAwayTeam.Orientation         = Orientation.Vertical;
                spAwayTeam.HorizontalAlignment = HorizontalAlignment.Center;
                StackPanel spInfos = new StackPanel();
                spInfos.Orientation         = Orientation.Vertical;
                spInfos.HorizontalAlignment = HorizontalAlignment.Center;
                spInfos.Width = 150;

                //Infos stack panel
                Round      r   = next.Round;
                Tournament trn = r.Tournament;

                TextBox tbTournament = new TextBox();
                tbTournament.Text                = next.Round.Tournament.name;
                tbTournament.Style               = FindResource("StyleTextBox") as Style;
                tbTournament.IsEnabled           = false;
                tbTournament.FontSize            = 16;
                tbTournament.HorizontalAlignment = HorizontalAlignment.Center;
                tbTournament.Background          = (SolidColorBrush)(new BrushConverter().ConvertFrom(trn.color.ToHexa()));
                tbTournament.Foreground          = Brushes.AntiqueWhite;

                spInfos.Children.Add(tbTournament);
                spInfos.Children.Add(ViewUtils.CreateLabel(r.name, "StyleLabel2Center", -1, -1));
                spInfos.Children.Add(ViewUtils.CreateLabel(next.day.ToShortTimeString(), "StyleLabel2Center", -1, -1));
                spInfos.Children.Add(ViewUtils.CreateLabel(next.home.stadium.name, "StyleLabel2Center", -1, -1));

                //Home team stack panel
                spHomeTeam.Children.Add(ViewUtils.CreateLogo(next.home, 125, 125));
                Label homeLabel = ViewUtils.CreateLabel(next.home.shortName, "StyleLabel2Center", 16, -1);
                homeLabel.HorizontalAlignment = HorizontalAlignment.Center;
                spHomeTeam.Children.Add(homeLabel);
                StackPanel homeStars = ViewUtils.CreateStarNotation(next.home.Stars, 25);
                homeStars.HorizontalAlignment = HorizontalAlignment.Center;
                spHomeTeam.Children.Add(homeStars);

                //Away team stack panel
                spAwayTeam.Children.Add(ViewUtils.CreateLogo(next.away, 125, 125));
                Label awayLabel = ViewUtils.CreateLabel(next.away.shortName, "StyleLabel2Center", 16, -1);
                awayLabel.HorizontalAlignment = HorizontalAlignment.Center;
                spAwayTeam.Children.Add(awayLabel);
                StackPanel awayStars = ViewUtils.CreateStarNotation(next.away.Stars, 25);
                awayStars.HorizontalAlignment = HorizontalAlignment.Center;
                spAwayTeam.Children.Add(awayStars);

                spNextMatch.Children.Add(spHomeTeam);
                spNextMatch.Children.Add(spInfos);
                spNextMatch.Children.Add(spAwayTeam);
            }
        }
        async Task Match(Match game)
        {
            List <RetourMatch> res = game.NextMinute();

            if (Utils.RetoursContient(RetourMatchEvenement.FIN_MATCH, res))
            {
                _enCours[_matchs.IndexOf(game)] = false;
            }
            //Si y a un évenement
            if (Utils.RetoursContient(RetourMatchEvenement.EVENEMENT, res))
            {
                MatchEvent em             = game.events[game.events.Count - 1];
                string     icone          = "";
                bool       afficherAction = false;

                if (em.type == GameEvent.Goal || em.type == GameEvent.PenaltyGoal || em.type == GameEvent.AgGoal)
                {
                    icone          = "goal.png";
                    afficherAction = true;
                    if (em.club == game.home)
                    {
                        _media.But(game);
                    }

                    if (cbJingleBut.IsChecked == true)
                    {
                        _media.AjouterSon("jingle", false);
                    }

                    //Refresh en cas de but
                    Matchs();
                    Classement();
                }
                else if (em.type == GameEvent.YellowCard)
                {
                    icone          = "yellow_card.png";
                    afficherAction = true;
                }
                else if (em.type == GameEvent.RedCard)
                {
                    icone          = "red_card.png";
                    afficherAction = true;
                }

                if (afficherAction)
                {
                    StackPanel spAction = new StackPanel();
                    spAction.Orientation = Orientation.Horizontal;

                    spAction.Children.Add(ViewUtils.CreateImage(Utils.Image(icone), 20, 20));
                    spAction.Children.Add(ViewUtils.CreateLabel(em.MinuteToString, "StyleLabel2", 11, 25, System.Windows.Media.Brushes.LightSalmon, null, true));
                    spAction.Children.Add(ViewUtils.CreateLabel(game.home.shortName + " - " + game.away.shortName + " : " + game.score1 + " - " + game.score2, "StyleLabel2", 11, 210, icone == "red_card.png" ? System.Windows.Media.Brushes.LightSalmon : null, null, icone == "goal.png" || icone == "red_card.png"));
                    spAction.Children.Add(ViewUtils.CreateLabel(em.player.lastName + " (" + em.player.Club.shortName + ")", "StyleLabel2", 11, 125, null, null, icone == "goal.png"));
                    spOtherActions.Children.Insert(0, spAction);
                }

                if (game == _matchs[0])
                {
                    ActionsMatch();
                }
            }


            //Refresh
            if (game == _matchs[0])
            {
                lbTemps.Content  = game.Time;
                lbScore1.Content = game.score1;
                lbScore2.Content = game.score2;
                lbTirs1.Content  = game.statistics.HomeShoots;
                lbTirs2.Content  = game.statistics.AwayShoots;
                pbTirs.Maximum   = game.statistics.HomeShoots + game.statistics.AwayShoots;
                pbTirs.Value     = game.statistics.HomeShoots;
            }
            //Thread t = new Thread(new ThreadStart(ThreadClassement));
            //t.Start();


            await Task.Delay((int)sliderVitesseSimulation.Value) /*.ConfigureAwait(false)*/;
        }
Esempio n. 26
0
        private void RemplirTreeView()
        {
            tvClubs.Items.Clear();

            foreach (Continent c in Session.Instance.Game.kernel.continents)
            {
                foreach (Country p in c.countries)
                {
                    foreach (Tournament cp in p.Tournaments())
                    {
                        if (cp.isChampionship)
                        {
                            TreeViewItem tv = new TreeViewItem();
                            tv.Header = cp.name;

                            if ((cp.rounds[0] as InactiveRound) == null)
                            {
                                foreach (Club club in cp.rounds[0].clubs)
                                {
                                    StackPanel sp = new StackPanel();
                                    sp.Orientation = Orientation.Horizontal;
                                    Image logo = new Image();
                                    logo.Width  = 20;
                                    logo.Height = 20;
                                    logo.Source = new BitmapImage(new Uri(Utils.Logo(club)));
                                    Button btnClub = new Button();
                                    btnClub.Content    = club.name;
                                    btnClub.Style      = Application.Current.FindResource("StyleButtonLabel") as Style;
                                    btnClub.FontSize   = 11;
                                    btnClub.Foreground = Brushes.Black;
                                    btnClub.Name       = "club_" + Session.Instance.Game.kernel.Clubs.IndexOf(club).ToString();
                                    if (club as CityClub != null)
                                    {
                                        btnClub.Click += new RoutedEventHandler(BtnClub_Click);
                                    }
                                    else
                                    {
                                        btnClub.Foreground = Brushes.DarkGray;
                                    }
                                    sp.Children.Add(logo);
                                    sp.Children.Add(btnClub);
                                    tv.Items.Add(sp);
                                }
                            }
                            else
                            {
                                tv.Items.Add(ViewUtils.CreateLabel("Compétition inactive", "StyleLabel2", 12, 100, Brushes.DarkGray));
                            }

                            tvClubs.Items.Add(tv);
                        }
                    }
                }
            }

            /*
             * <TreeViewItem Header="Employee1">
             *                          <TreeViewItem Header="Jesper Aaberg">
             *                                  <StackPanel Orientation="Horizontal">
             *                                          <Label Content="ha"/>
             *                                          <Label Content="ha"/>
             *                                  </StackPanel>
             *                          </TreeViewItem>
             */
        }
Esempio n. 27
0
        private void FillPlayerHistory()
        {
            StackPanel firstLine = new StackPanel();

            firstLine.Orientation = Orientation.Horizontal;
            firstLine.Children.Add(ViewUtils.CreateLabel(FindResource("str_duration").ToString(), "StyleLabel2", 11, 80));
            firstLine.Children.Add(ViewUtils.CreateLabel(FindResource("str_club").ToString(), "StyleLabel2", 11, 100));
            firstLine.Children.Add(ViewUtils.CreateLabel(FindResource("str_games").ToString(), "StyleLabel2", 11, 40));
            firstLine.Children.Add(ViewUtils.CreateLabel(FindResource("str_goals").ToString(), "StyleLabel2", 11, 40));
            spPlayerHistory.Children.Add(firstLine);

            int cumulativeGoals         = 0;
            int cumulativeMatchesPlayed = 0;

            if (_player.history.Count > 0)
            {
                Club last    = null;
                int  arrival = _player.history[0].Year;
                foreach (PlayerHistory hj in _player.history)
                {
                    if (last != hj.Club)
                    {
                        string nameClub = "";
                        if (last == null)
                        {
                            nameClub = FindResource("str_free").ToString();
                        }
                        else
                        {
                            nameClub = last.name;
                        }
                        int depart = hj.Year;

                        StackPanel line = new StackPanel();
                        line.Orientation = Orientation.Horizontal;
                        line.Children.Add(ViewUtils.CreateLabel((arrival - 1).ToString() + " - " + _player.history[_player.history.Count - 1].Year.ToString(), "StyleLabel2", 11, 80));
                        line.Children.Add(ViewUtils.CreateLabel(nameClub, "StyleLabel2", 11, 100));
                        line.Children.Add(ViewUtils.CreateLabel(cumulativeMatchesPlayed.ToString(), "StyleLabel2", 11, 40));
                        line.Children.Add(ViewUtils.CreateLabel(cumulativeGoals.ToString(), "StyleLabel2", 11, 40));
                        spPlayerHistory.Children.Add(line);

                        cumulativeGoals         = 0;
                        cumulativeMatchesPlayed = 0;
                        arrival = hj.Year;
                    }
                    cumulativeGoals         += hj.Goals;
                    cumulativeMatchesPlayed += hj.GamesPlayed;
                    last = hj.Club;
                }

                string clubName = "";
                if (last == null)
                {
                    clubName = FindResource("str_free").ToString();
                }
                else
                {
                    clubName = last.name;
                }


                StackPanel lastLine = new StackPanel();
                lastLine.Orientation = Orientation.Horizontal;
                lastLine.Children.Add(ViewUtils.CreateLabel((arrival - 1).ToString() + " - " + _player.history[_player.history.Count - 1].Year.ToString(), "StyleLabel2", 11, 80));
                lastLine.Children.Add(ViewUtils.CreateLabel(clubName, "StyleLabel2", 11, 100));
                lastLine.Children.Add(ViewUtils.CreateLabel(cumulativeMatchesPlayed.ToString(), "StyleLabel2", 11, 40));
                lastLine.Children.Add(ViewUtils.CreateLabel(cumulativeGoals.ToString(), "StyleLabel2", 11, 40));
                spPlayerHistory.Children.Add(lastLine);
            }
        }
Esempio n. 28
0
        private void AddContinentalCountryRanking(Continent c)
        {
            TabItem tab = new TabItem();

            tab.Header = FindResource("str_ranking").ToString() + " " + c.Name() + " (associations)";
            tab.Style  = Application.Current.FindResource("StyleTabHeader") as Style;
            ScrollViewer scrollViewer = new ScrollViewer();

            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.Height = 650;
            tab.Content         = scrollViewer;
            StackPanel spRanking = new StackPanel();

            spRanking.Orientation = Orientation.Vertical;
            scrollViewer.Content  = spRanking;
            StackPanel spHead = new StackPanel();

            spHead.Orientation = Orientation.Horizontal;
            spHead.Children.Add(ViewUtils.CreateLabel("", "StyleLabel2Center", -1, 30, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("Nation", "StyleLabel2", -1, 250, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("-5", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-4", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-3", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-2", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-1", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("Total", "StyleLabel2Center", -1, 50, null, null, true));
            for (int i = 0; i < c.ContinentalTournamentsCount; i++)
            {
                spHead.Children.Add(ViewUtils.CreateLabel(c.GetContinentalClubTournament(i + 1).shortName, "StyleLabel2Center", 10, 20, null, null, false));
            }
            spRanking.Children.Add(spHead);

            int            rank      = 0;
            List <Country> countries = c.associationRanking;

            foreach (Country ctr in countries)
            {
                rank++;
                Dictionary <int, int> qualifications = new Dictionary <int, int>();
                foreach (Qualification q in c.continentalQualifications)
                {
                    if (q.ranking == rank)
                    {
                        if (!qualifications.ContainsKey(q.tournament.level))
                        {
                            qualifications.Add(q.tournament.level, 0);
                        }
                        qualifications[q.tournament.level] += q.qualifies;
                    }
                }
                StackPanel spLine = new StackPanel();
                spLine.Orientation = Orientation.Horizontal;
                spLine.Children.Add(ViewUtils.CreateLabel(rank.ToString(), "StyleLabel2", -1, 30, null, null, true));
                spLine.Children.Add(ViewUtils.CreateFlag(ctr, 20, 13));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.Name(), "StyleLabel2", -1, 220, null, null, true));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.YearAssociationCoefficient(-5).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.YearAssociationCoefficient(-4).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.YearAssociationCoefficient(-3).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.YearAssociationCoefficient(-2).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.YearAssociationCoefficient(-1).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.AssociationCoefficient.ToString("0.00"), "StyleLabel2Center", -1, 50, null, null, true));
                for (int i = 0; i < c.ContinentalTournamentsCount; i++)
                {
                    spLine.Children.Add(ViewUtils.CreateLabel(qualifications.ContainsKey(i + 1) ? qualifications[i + 1].ToString() : "0", "StyleLabel2Center", 9, 20, null, null, true));
                }
                spRanking.Children.Add(spLine);
            }

            tcMain.Items.Add(tab);
        }
Esempio n. 29
0
        private void AddContinentalClubRanking(Continent c)
        {
            TabItem tab = new TabItem();

            tab.Header = FindResource("str_ranking").ToString() + " " + c.Name() + " (clubs)";
            tab.Style  = Application.Current.FindResource("StyleTabHeader") as Style;
            ScrollViewer scrollViewer = new ScrollViewer();

            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.Height = 650;
            tab.Content         = scrollViewer;
            StackPanel spRanking = new StackPanel();

            spRanking.Orientation = Orientation.Vertical;
            scrollViewer.Content  = spRanking;

            int        i      = 0;
            StackPanel spHead = new StackPanel();

            spHead.Orientation = Orientation.Horizontal;
            spHead.Children.Add(ViewUtils.CreateLabel("", "StyleLabel2Center", -1, 30, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("Club", "StyleLabel2", -1, 250, null, null, true));
            spHead.Children.Add(ViewUtils.CreateLabel("-5", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-4", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-3", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-2", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("-1", "StyleLabel2Center", -1, 35, null, null, false));
            spHead.Children.Add(ViewUtils.CreateLabel("Total", "StyleLabel2Center", -1, 50, null, null, true));
            spRanking.Children.Add(spHead);

            List <Club> clubs = new List <Club>();

            foreach (Country ctr in c.countries)
            {
                foreach (Tournament championship in ctr.Tournaments())
                {
                    if (championship.isChampionship)
                    {
                        foreach (Club club in championship.rounds[0].clubs)
                        {
                            if (club.ClubCoefficient() > 0)
                            {
                                clubs.Add(club);
                            }
                        }
                    }
                }
            }

            clubs.Sort(new ClubComparator(ClubAttribute.CONTINENTAL_COEFFICIENT));
            int rank = 0;

            foreach (Club ctr in clubs)
            {
                rank++;
                StackPanel spLine = new StackPanel();
                spLine.Orientation = Orientation.Horizontal;
                spLine.Children.Add(ViewUtils.CreateLabel(rank.ToString(), "StyleLabel2", -1, 30, null, null, true));
                spLine.Children.Add(ViewUtils.CreateFlag(Session.Instance.Game.kernel.LocalisationTournament(ctr.Championship) as Country, 20, 13));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.name, "StyleLabel2", -1, 220, null, null, true));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubYearCoefficient(-5).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubYearCoefficient(-4).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubYearCoefficient(-3).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubYearCoefficient(-2).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubYearCoefficient(-1).ToString("0.00"), "StyleLabel2Center", 10, 35, null, null, false));
                spLine.Children.Add(ViewUtils.CreateLabel(ctr.ClubCoefficient().ToString("0.00"), "StyleLabel2Center", -1, 50, null, null, true));
                spRanking.Children.Add(spLine);
            }

            tcMain.Items.Add(tab);
        }