コード例 #1
0
        private void UpdateBasedOnTournamentsSeries(Dictionary <TournamentChartSeries, List <ChartSeriesItem> > chartSeriesItems, IList <Tournaments> tournaments)
        {
            var chartItemDataBuilder = CreateTournamentChartItemDataBuilder(ChartDisplayRange);

            var tournamentRecords = chartItemDataBuilder.Create(tournaments, TournamentChartFilterType);

            foreach (var tournament in tournamentRecords)
            {
                foreach (var chartSerie in ChartCollection.Where(x => !x.IsBasedOnStatistic))
                {
                    ChartSeriesItem previousChartSeriesItem = null;
                    ChartSeriesItem chartSeriesItem         = null;

                    if (!chartSeriesItems.ContainsKey(chartSerie))
                    {
                        chartSeriesItems.Add(chartSerie, new List <ChartSeriesItem>());
                    }

                    chartSeriesItem = new ChartSeriesItem
                    {
                        Format                 = chartSerie.Format,
                        Category               = tournament.Started,
                        PointColor             = chartSerie.ColorsPalette.PointColor,
                        TrackBallColor         = chartSerie.ColorsPalette.TrackBallColor,
                        TooltipColor           = chartSerie.ColorsPalette.TooltipColor,
                        TooltipForegroundColor = chartSerie.ColorsPalette.TooltipForeground
                    };

                    previousChartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                    chartSeriesItems[chartSerie].Add(chartSeriesItem);

                    chartSerie.UpdateChartSeriesItemByTournament?.Invoke(chartSeriesItem, previousChartSeriesItem, tournament);
                }
            }
        }
コード例 #2
0
        private void UpdateBasedOnStatisticSeries(Dictionary <TournamentChartSeries, List <ChartSeriesItem> > chartSeriesItems, IList <Tournaments> tournaments)
        {
            if (tournaments == null || tournaments.Count == 0)
            {
                return;
            }

            var chartItemDataBuilder           = CreateChartItemDataBuilder(ChartDisplayRange);
            var tournamentChartItemDataBuilder = CreateTournamentChartItemDataBuilder(ChartDisplayRange);

            var firstDate = tournamentChartItemDataBuilder.GetFirstDate(tournaments.Max(x => x.Firsthandtimestamp));

            var groupedTournaments = tournaments
                                     .Where(x => x.Firsthandtimestamp >= firstDate && (tournamentChartFilterType == TournamentChartFilterType.All ||
                                                                                       tournamentChartFilterType == TournamentChartFilterType.MTT && x.Tourneytagscsv == TournamentsTags.MTT.ToString() ||
                                                                                       tournamentChartFilterType == TournamentChartFilterType.STT && x.Tourneytagscsv == TournamentsTags.STT.ToString()))
                                     .GroupBy(x => x.BuildKey()).ToDictionary(x => x.Key, x => x.FirstOrDefault());

            var filteredTournamentPlayerStatistic = StorageModel
                                                    .GetFilteredTournamentPlayerStatistic()
                                                    .Where(x => groupedTournaments.ContainsKey(new TournamentKey(x.PokersiteId, x.TournamentId)))
                                                    .ToArray();

            // filter and orders
            var stats = chartItemDataBuilder.PrepareStatistic(filteredTournamentPlayerStatistic);

            object previousGroupKey = null;

            var itemsCounter = 0;

            for (var statIndex = 0; statIndex < stats.Length; statIndex++)
            {
                var stat = stats[statIndex];

                var currentGroupKey = chartItemDataBuilder.BuildGroupKey(stat, statIndex);

                var isNew = !currentGroupKey.Equals(previousGroupKey);

                if (isNew)
                {
                    itemsCounter++;
                }

                previousGroupKey = currentGroupKey;

                foreach (var chartSerie in ChartCollection.Where(x => x.IsBasedOnStatistic))
                {
                    ChartSeriesItem previousChartSeriesItem = null;
                    ChartSeriesItem chartSeriesItem         = null;

                    if (!chartSeriesItems.ContainsKey(chartSerie))
                    {
                        chartSeriesItems.Add(chartSerie, new List <ChartSeriesItem>());
                    }

                    if (isNew)
                    {
                        chartSeriesItem = new ChartSeriesItem
                        {
                            Format                 = chartSerie.Format,
                            Category               = chartItemDataBuilder.GetValueFromGroupKey(currentGroupKey),
                            PointColor             = chartSerie.ColorsPalette.PointColor,
                            TrackBallColor         = chartSerie.ColorsPalette.TrackBallColor,
                            TooltipColor           = chartSerie.ColorsPalette.TooltipColor,
                            TooltipForegroundColor = chartSerie.ColorsPalette.TooltipForeground
                        };

                        previousChartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                        chartSeriesItems[chartSerie].Add(chartSeriesItem);
                    }
                    else
                    {
                        previousChartSeriesItem = chartSeriesItem = chartSeriesItems[chartSerie].LastOrDefault();
                    }

                    chartSerie.UpdateChartSeriesItemByStatistic?.Invoke(chartSeriesItem, previousChartSeriesItem, stat);
                }
            }
        }