Example #1
0
        private TaggedObject CalculatorToTaggedObject(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calculator)
        {
            string first  = _translator.Translate("playerStatLong_" + calculator.Identifier);
            string second = _translator.Translate("playerStatShort_" + calculator.Identifier);

            return(new TaggedObject(string.Format("{0} ({1})", first, second), calculator));
        }
Example #2
0
 protected MatchFilterBase(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc)
 {
     if (calc == null)
     {
         throw new ArgumentNullException("calc");
     }
     _calc = calc;
 }
Example #3
0
        private static IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > GetCalculatorsListFromDialog(Dialogs.ChooseColumnsDialog ccd)
        {
            IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > myList = new List <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > >();

            foreach (object o in ccd.Right.SafeEnum())
            {
                TaggedObject to = o as TaggedObject;
                if (to != null)
                {
                    IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > c = to.Tag as IPlayerStatisticCalculator <IEnumerable <MatchAppearance> >;
                    if (c != null)
                    {
                        myList.Add(c);
                    }
                }
            }
            return(myList);
        }
Example #4
0
        public Lineup GetFor(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > theStatistic,
                             IDictionary <Player, IEnumerable <MatchAppearance> > matchAppearances)
        {
            //TODO: just a brute force 4-4-2 implementation
            var goalieStat = new MatchFilterPositionGoalkeeper(theStatistic);

            var results = matchAppearances.Select(pair => new PlayerResult()
            {
                Player = pair.Key, Result = null
            });

            //var results = matchAppearances.Keys.Select(player => player.Name);


            foreach (var pair in matchAppearances)
            {
                //playersAndResults.Add(pair.Key, goalieStat.Calculate(pair.Value));
            }

            return(null);
        }
Example #5
0
 public MatchFilterOther(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc) : base(calc)
 {
 }
Example #6
0
 public MatchFilterPositionGoalkeeper(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc) : base(calc)
 {
 }
Example #7
0
 public MatchFilterSeason(int season, IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc) : base(calc)
 {
     _season = season;
 }
Example #8
0
        private void FillListView(ResultData data, ListView listView)
        {
            if (data == null || listView == null)
            {
                return;
            }

            if (data.Infos == null)
            {
                data.Infos = GetForMatches(data.TeamId, data.Matches);
            }

            listView.Tag = data;
            listView.Items.Clear();

            foreach (var pmd in data.Infos.SafeEnum())
            {
                Player player = pmd.Key;
                if (player == null)
                {
                    continue;
                }

                ListViewItem item = new ListViewItem("(invalid)")
                {
                    Tag = pmd
                };
                item.ToolTipText = pmd.Key.ToString();

                // highlight current players
                if (data.CurrentPlayers != null &&
                    data.CurrentPlayers.FirstOrDefault(p => (p.ID == player.ID)) != null)
                {
                    item.Font = new Font(item.Font, FontStyle.Bold);
                }

                // team dummy player
                if (player.ID == 0)
                {
                    item.BackColor = Color.Gray;
                }

                bool firstCol = true;
                foreach (ColumnHeader ch in listView.Columns)
                {
                    IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > psc = ch.Tag as IPlayerStatisticCalculator <IEnumerable <MatchAppearance> >;
                    object   value = (psc == null) ? "(invalid)" : psc.Calculate(pmd.Value);
                    IPrinter fp    = (psc == null) ? new ToStringPrinter <object>() : psc.GetPrinter();
                    //if (value == null) value = "-";

                    if (firstCol)
                    {
                        item.Text            = fp.Print(value);
                        item.SubItems[0].Tag = value;
                        firstCol             = false;
                    }
                    else
                    {
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, fp.Print(value))
                        {
                            Tag = value
                        });
                    }
                }

                listView.Items.Add(item);
            }
        }
Example #9
0
        private void FillDetailsSeason()
        {
            try
            {
                sortableListViewDetails1.Items.Clear();

                if (sortableListViewOverview.SelectedItems.Count == 0)
                {
                    return;
                }

                KeyValuePair <Player, IList <MatchAppearance> > sitem;

                if (sortableListViewOverview.SelectedItems[0].Tag is KeyValuePair <Player, IList <MatchAppearance> > )
                {
                    sitem = (KeyValuePair <Player, IList <MatchAppearance> >)sortableListViewOverview.SelectedItems[0].Tag;
                }
                else
                {
                    return;
                }

                IDictionary <int, IEnumerable <MatchAppearance> > appearancesBySeason = sitem.Value.Split(m => new HtTime(m.Match.Date).Season);

                foreach (var v in appearancesBySeason)
                {
                    var m = v.Value;

                    ListViewItem item = new ListViewItem(string.Format("Season {0,02}", v.Key));
                    item.Tag             = m;
                    item.SubItems[0].Tag = item.Tag;

                    bool firstCol = true;
                    foreach (ColumnHeader ch in sortableListViewDetails1.Columns)
                    {
                        IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > psc = ch.Tag as IPlayerStatisticCalculator <IEnumerable <MatchAppearance> >;
                        object   value = (psc == null) ? "(invalid)" : psc.Calculate(v.Value);
                        IPrinter fp    = (psc == null) ? new ToStringPrinter <object>() : psc.GetPrinter();
                        //if (value == null) value = "-";

                        if (firstCol)
                        {
                            firstCol = false;
                            continue; //skip
                        }
                        else
                        {
                            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, fp.Print(value))
                            {
                                Tag = value
                            });
                        }
                    }

                    sortableListViewDetails1.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #10
0
 public MatchFilterPositionCentralDefender(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc) : base(calc)
 {
 }
 public MatchFilterPositionInnerMidfield(IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > calc) : base(calc)
 {
 }