Beispiel #1
0
        public SpinSection(PlotStyle plotStyle, IDictionary <string, List <Rally> > sets, Match match, object player)
        {
            SpinPlots = new List <PlotModel>();

            foreach (var set in sets.Keys)
            {
                if (sets[set].Count > 0)
                {
                    var statistics = new SpinStatistics(match, player, sets[set]);
                    var dataMax = new[] { statistics.NoSpin, statistics.SpinDown, statistics.SpinUp, statistics.NotAnalysed }.Max();

                    var plot = plotStyle.CreatePlot();
                    plot.LegendOrientation       = LegendOrientation.Horizontal;
                    plot.LegendPlacement         = LegendPlacement.Outside;
                    plot.LegendPosition          = LegendPosition.BottomCenter;
                    plot.Title                   = GetSetTitleString(set);
                    plot.TitleFontSize           = 16;
                    plot.PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);

                    var categoryAxis1 = new CategoryAxis
                    {
                        Position  = AxisPosition.Left,
                        MinorStep = 1
                    };

                    var linearAxis1 = new LinearAxis
                    {
                        Position  = AxisPosition.Bottom,
                        MajorStep = Math.Max(Math.Ceiling(dataMax / 4d), 1)
                    };
                    linearAxis1.MinorStep       = linearAxis1.MajorStep / 4d;
                    linearAxis1.AbsoluteMinimum = 0;
                    linearAxis1.MaximumPadding  = 0.06;
                    linearAxis1.MinimumPadding  = 0;

                    var barSeries1 = new BarSeries();
                    var barSeries2 = new BarSeries();
                    barSeries1.IsStacked         = true;
                    barSeries2.IsStacked         = true;
                    barSeries1.StrokeThickness   = 1;
                    barSeries2.StrokeThickness   = 1;
                    barSeries1.Title             = Properties.Resources.section_stroke_won;
                    barSeries2.Title             = Properties.Resources.section_stroke_lost;
                    barSeries1.LabelPlacement    = LabelPlacement.Inside;
                    barSeries2.LabelPlacement    = LabelPlacement.Inside;
                    barSeries1.LabelMargin       = 8;
                    barSeries2.LabelMargin       = 8;
                    barSeries1.LabelFormatString = "{0}";
                    barSeries2.LabelFormatString = "{0}";

                    int categoryNr = 0;

                    if (statistics.NotAnalysed > 0)
                    {
                        categoryAxis1.Labels.Add(string.Format("{0} ({1})", Properties.Resources.section_spin_hidden, statistics.NotAnalysed));
                        barSeries1.Items.Add(new BarItem(statistics.NotAnalysedWon, categoryNr));
                        var notAnalysedLost = statistics.NotAnalysed - statistics.NotAnalysedWon;
                        if (notAnalysedLost > 0)
                        {
                            barSeries2.Items.Add(new BarItem(notAnalysedLost, categoryNr));
                        }
                        categoryNr++;
                    }

                    categoryAxis1.Labels.Add(string.Format("{0} ({1})", Properties.Resources.section_spin_down, statistics.SpinDown));
                    barSeries1.Items.Add(new BarItem(statistics.SpinDownWon, categoryNr));
                    var spinDownLost = statistics.SpinDown - statistics.SpinDownWon;
                    if (spinDownLost > 0)
                    {
                        barSeries2.Items.Add(new BarItem(spinDownLost, categoryNr));
                    }
                    categoryNr++;

                    categoryAxis1.Labels.Add(string.Format("{0} ({1})", Properties.Resources.section_spin_no, statistics.NoSpin));
                    barSeries1.Items.Add(new BarItem(statistics.NoSpinWon, categoryNr));
                    var noSpinLost = statistics.NoSpin - statistics.NoSpinWon;
                    if (noSpinLost > 0)
                    {
                        barSeries2.Items.Add(new BarItem(noSpinLost, categoryNr));
                    }
                    categoryNr++;

                    categoryAxis1.Labels.Add(string.Format("{0} ({1})", Properties.Resources.section_spin_up, statistics.SpinUp));
                    barSeries1.Items.Add(new BarItem(statistics.SpinUpWon, categoryNr));
                    var spinUpLost = statistics.SpinUp - statistics.SpinUpWon;
                    if (spinUpLost > 0)
                    {
                        barSeries2.Items.Add(new BarItem(spinUpLost, categoryNr));
                    }

                    plot.Series.Add(barSeries1);
                    plot.Series.Add(barSeries2);

                    plot.Axes.Add(categoryAxis1);
                    plot.Axes.Add(linearAxis1);

                    SpinPlots.Add(plot);

                    Debug.WriteLine("{1} for stroke 1 of set {0} ready.", set, SectionName);
                }
            }
        }
        public StrokeNumberSection(PlotStyle plotStyle, int strokeNumber, IDictionary <string, List <Models.Rally> > sets, Models.Match match, object p)
        {
            NumberPlots = new List <PlotModel>();

            foreach (var set in sets.Keys)
            {
                if (sets[set].Count > 0)
                {
                    var statistics = new TechniqueStatistics(match, p, sets[set], strokeNumber);

                    PlotModel plot = plotStyle.CreatePlot();
                    plot.Title                   = GetSetTitleString(set);
                    plot.TitleFontSize           = 16;
                    plot.LegendOrientation       = LegendOrientation.Horizontal;
                    plot.LegendPlacement         = LegendPlacement.Outside;
                    plot.LegendPosition          = LegendPosition.BottomCenter;
                    plot.PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);

                    var categoryAxis = new CategoryAxis();
                    categoryAxis.Position  = AxisPosition.Bottom;
                    categoryAxis.MinorStep = 1;

                    var linearAxis = new LinearAxis();
                    linearAxis.Position        = AxisPosition.Left;
                    linearAxis.MinorStep       = 1;
                    linearAxis.MajorStep       = 4;
                    linearAxis.AbsoluteMinimum = 0;
                    linearAxis.MaximumPadding  = 0.06;
                    linearAxis.MinimumPadding  = 0;

                    var techniqueToSeries = new Dictionary <string, ColumnSeries>();

                    int index = 0;
                    foreach (var number in statistics.NumberToTechniqueCountDict.Keys)
                    {
                        var numberCount = 0;
                        foreach (var count in statistics.NumberToTechniqueCountDict[number].Values)
                        {
                            numberCount += count;
                        }

                        if (numberCount > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", number, numberCount));

                            foreach (var technique in statistics.NumberToTechniqueCountDict[number].Keys)
                            {
                                var techniqueCount = statistics.NumberToTechniqueCountDict[number][technique];
                                if (techniqueCount > 0)
                                {
                                    ColumnSeries series;
                                    if (techniqueToSeries.ContainsKey(technique))
                                    {
                                        series = techniqueToSeries[technique];
                                    }
                                    else
                                    {
                                        series = GetNewSeries(technique);
                                        techniqueToSeries[technique] = series;
                                    }
                                    series.Items.Add(new ColumnItem(techniqueCount, categoryIndex: index));
                                }
                            }
                            index++;
                        }
                    }

                    foreach (var series in techniqueToSeries.Values)
                    {
                        plot.Series.Add(series);
                    }

                    plot.Axes.Add(categoryAxis);
                    plot.Axes.Add(linearAxis);

                    NumberPlots.Add(plot);

                    Debug.WriteLine("{2} for stroke {0} of set {1} ready.", GetStrokeNumberString(strokeNumber), set, SectionName);
                }
            }
        }
Beispiel #3
0
        public TechniqueSection(PlotStyle plotStyle, int strokeNumber, IDictionary <string, List <Rally> > sets, Match match, object p)
        {
            Debug.WriteLine("New Technique section");

            if (strokeNumber == 1)
            {
                base.GetImageBitmapFrames(strokeNumber, sets, match, p, typeof(ServiceTechniqueStatisticsGridView));
            }
            else
            {
                base.GetImageBitmapFrames(strokeNumber, sets, match, p, typeof(TechniqueStatisticsGridView));
                Debug.WriteLine("Got TechniqueGridView image");

                foreach (var set in sets.Keys)
                {
                    if (sets[set].Count > 0)
                    {
                        var statistics = new TechniqueStatistics(match, p, sets[set], strokeNumber);
                        Debug.WriteLine("Got TechniqueStatistics (set={0})", args: set);

                        PlotModel plot = plotStyle.CreatePlot();
                        plot.LegendOrientation       = LegendOrientation.Horizontal;
                        plot.LegendPlacement         = LegendPlacement.Outside;
                        plot.LegendPosition          = LegendPosition.BottomCenter;
                        plot.PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);

                        var categoryAxis = new CategoryAxis();
                        categoryAxis.Position  = AxisPosition.Bottom;
                        categoryAxis.MinorStep = 1;

                        var linearAxis = new LinearAxis();
                        linearAxis.Position        = AxisPosition.Left;
                        linearAxis.MinorStep       = 1;
                        linearAxis.MajorStep       = 4;
                        linearAxis.AbsoluteMinimum = 0;
                        linearAxis.MaximumPadding  = 0.06;
                        linearAxis.MinimumPadding  = 0;

                        var barSeries1 = new ColumnSeries();
                        var barSeries2 = new ColumnSeries();
                        barSeries1.IsStacked         = true;
                        barSeries2.IsStacked         = true;
                        barSeries1.StrokeThickness   = 1;
                        barSeries2.StrokeThickness   = 1;
                        barSeries1.Title             = Properties.Resources.section_stroke_won;
                        barSeries2.Title             = Properties.Resources.section_stroke_lost;
                        barSeries1.LabelPlacement    = LabelPlacement.Inside;
                        barSeries2.LabelPlacement    = LabelPlacement.Inside;
                        barSeries1.LabelMargin       = 4;
                        barSeries2.LabelMargin       = 4;
                        barSeries1.LabelFormatString = "{0}";
                        barSeries2.LabelFormatString = "{0}";

                        int categoriesCount = 0;
                        foreach (var tec in statistics.GetType().GetProperties())
                        {
                            Models.Util.Enums.Stroke.TechniqueBasic tb;
                            if (Enum.TryParse(tec.Name, out tb))
                            {
                                categoriesCount += (int)tec.GetValue(statistics) > 0 ? 1 : 0;
                            }
                        }
                        bool useShortCatNames = categoriesCount > 4;

                        int categoryNr = 0;

                        if (statistics.Push > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_push_short : Properties.Resources.section_technique_push, statistics.Push));
                            barSeries1.Items.Add(new ColumnItem(statistics.PushWon, categoryNr));
                            var pushLost = statistics.Push - statistics.PushWon;
                            if (pushLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(pushLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Flip > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_flip_short : Properties.Resources.section_technique_flip, statistics.Flip));
                            barSeries1.Items.Add(new ColumnItem(statistics.FlipWon, categoryNr));
                            var flipLost = statistics.Flip - statistics.FlipWon;
                            if (flipLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(flipLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Topspin > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_topspin_short : Properties.Resources.section_technique_topspin, statistics.Topspin));
                            barSeries1.Items.Add(new ColumnItem(statistics.TopspinWon, categoryNr));
                            var topspinLost = statistics.Topspin - statistics.TopspinWon;
                            if (topspinLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(topspinLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Block > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_block_short : Properties.Resources.section_technique_block, statistics.Block));
                            barSeries1.Items.Add(new ColumnItem(statistics.BlockWon, categoryNr));
                            var blockLost = statistics.Block - statistics.BlockWon;
                            if (blockLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(blockLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Counter > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_counter_short : Properties.Resources.section_technique_counter, statistics.Counter));
                            barSeries1.Items.Add(new ColumnItem(statistics.CounterWon, categoryNr));
                            var counterLost = statistics.Counter - statistics.CounterWon;
                            if (counterLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(counterLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Smash > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_smash_short : Properties.Resources.section_technique_smash, statistics.Smash));
                            barSeries1.Items.Add(new ColumnItem(statistics.SmashWon, categoryNr));
                            var smashLost = statistics.Smash - statistics.SmashWon;
                            if (smashLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(smashLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Lob > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_lob_short : Properties.Resources.section_technique_lob, statistics.Lob));
                            barSeries1.Items.Add(new ColumnItem(statistics.LobWon, categoryNr));
                            var lobLost = statistics.Lob - statistics.LobWon;
                            if (lobLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(lobLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Chop > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_chop_short : Properties.Resources.section_technique_chop, statistics.Chop));
                            barSeries1.Items.Add(new ColumnItem(statistics.ChopWon, categoryNr));
                            var chopLost = statistics.Chop - statistics.ChopWon;
                            if (chopLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(chopLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Special > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_special_short : Properties.Resources.section_technique_special, statistics.Special));
                            barSeries1.Items.Add(new ColumnItem(statistics.SpecialWon, categoryNr));
                            var specialLost = statistics.Special - statistics.SpecialWon;
                            if (specialLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(specialLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        if (statistics.Miscellaneous > 0)
                        {
                            categoryAxis.Labels.Add(string.Format("{0} ({1})", useShortCatNames ? Properties.Resources.technique_miscellaneous_short : Properties.Resources.section_technique_miscellaneous, statistics.Miscellaneous));
                            barSeries1.Items.Add(new ColumnItem(statistics.MiscellaneousWon, categoryNr));
                            var miscellaneousLost = statistics.Miscellaneous - statistics.MiscellaneousWon;
                            if (miscellaneousLost > 0)
                            {
                                barSeries2.Items.Add(new ColumnItem(miscellaneousLost, categoryNr));
                            }
                            categoryNr++;
                        }

                        plot.Series.Add(barSeries1);
                        plot.Series.Add(barSeries2);

                        plot.Axes.Add(categoryAxis);
                        plot.Axes.Add(linearAxis);

                        var setTitle      = GetSetTitleString(set);
                        var sectionImages = new List <object>()
                        {
                            plot
                        };
                        if (ExistingStatisticsImageBitmapFrames.ContainsKey(setTitle))
                        {
                            sectionImages.Add(ExistingStatisticsImageBitmapFrames[setTitle]);
                        }
                        else
                        {
                            sectionImages.Add(null);
                        }
                        ExistingStatisticsImageBitmapFrames[setTitle] = sectionImages;

                        Debug.WriteLine("{2} for stroke {0} of set {1} ready.", GetStrokeNumberString(strokeNumber), set, SectionName);
                    }
                }
            }
        }
Beispiel #4
0
        public SideSection(PlotStyle plotStyle, int strokeNr, bool stepAround, IDictionary <string, List <Rally> > sets, Match match, object player)
        {
            SidePlots     = new List <PlotModel>();
            HasStepAround = stepAround;

            bool multipleSets = sets.Count > 1;

            foreach (var set in sets.Keys)
            {
                if (sets[set].Count > 0)
                {
                    var statistics = new SideStatistics(match, player, strokeNr, sets[set]);
                    int dataMax    = Enumerable.Max(new int[] { statistics.Backhand, statistics.BackhandStepAround, statistics.Forehand, statistics.ForehandStepAround, statistics.NotAnalysed });

                    PlotModel plot = plotStyle.CreatePlot();
                    plot.LegendOrientation       = LegendOrientation.Horizontal;
                    plot.LegendPlacement         = LegendPlacement.Outside;
                    plot.LegendPosition          = LegendPosition.BottomCenter;
                    plot.Title                   = GetSetTitleString(set);
                    plot.TitleFontSize           = 16;
                    plot.PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1);

                    var categoryAxis1 = new CategoryAxis();
                    categoryAxis1.Position  = AxisPosition.Left;
                    categoryAxis1.MinorStep = 1;

                    var linearAxis1 = new LinearAxis();
                    linearAxis1.Position        = AxisPosition.Bottom;
                    linearAxis1.MajorStep       = Math.Ceiling(dataMax / 4d);
                    linearAxis1.MinorStep       = linearAxis1.MajorStep / 4d;
                    linearAxis1.AbsoluteMinimum = 0;
                    linearAxis1.MaximumPadding  = 0.06;
                    linearAxis1.MinimumPadding  = 0;

                    var wonSeries  = new BarSeries();
                    var lostSeries = new BarSeries();
                    wonSeries.IsStacked          = true;
                    lostSeries.IsStacked         = true;
                    wonSeries.StrokeThickness    = 1;
                    lostSeries.StrokeThickness   = 1;
                    wonSeries.Title              = Properties.Resources.section_stroke_won;
                    lostSeries.Title             = Properties.Resources.section_stroke_lost;
                    wonSeries.LabelPlacement     = LabelPlacement.Inside;
                    lostSeries.LabelPlacement    = LabelPlacement.Inside;
                    wonSeries.LabelMargin        = 8;
                    lostSeries.LabelMargin       = 8;
                    wonSeries.LabelFormatString  = "{0}";
                    lostSeries.LabelFormatString = "{0}";

                    int categoryNr = 0;

                    if (statistics.NotAnalysed > 0)
                    {
                        categoryAxis1.Labels.Add(string.Format("{0} ({1})", Properties.Resources.stat_not_analysed, statistics.NotAnalysed));
                        wonSeries.Items.Add(new BarItem(statistics.NotAnalysedWon, categoryNr));
                        var notAnalysedLost = statistics.NotAnalysed - statistics.NotAnalysedWon;
                        if (notAnalysedLost > 0)
                        {
                            lostSeries.Items.Add(new BarItem(notAnalysedLost, categoryNr));
                        }
                        categoryNr++;
                    }

                    if (stepAround)
                    {
                        categoryAxis1.Labels.Add(string.Format("{0} ({1})", multipleSets ? Properties.Resources.side_backhand_steparound_short : Properties.Resources.side_backhand_steparound, statistics.BackhandStepAround));
                        wonSeries.Items.Add(new BarItem(statistics.BackhandStepAroundWon, categoryNr));
                        var bhSaLost = statistics.BackhandStepAround - statistics.BackhandStepAroundWon;
                        if (bhSaLost > 0)
                        {
                            lostSeries.Items.Add(new BarItem(bhSaLost, categoryNr));
                        }
                        categoryNr++;
                    }

                    categoryAxis1.Labels.Add(string.Format("{0} ({1})", multipleSets ? Properties.Resources.side_backhand_short : Properties.Resources.side_backhand, statistics.Backhand));
                    wonSeries.Items.Add(new BarItem(statistics.BackhandWon, categoryNr));
                    var noSpinLost = statistics.Backhand - statistics.BackhandWon;
                    if (noSpinLost > 0)
                    {
                        lostSeries.Items.Add(new BarItem(noSpinLost, categoryNr));
                    }
                    categoryNr++;

                    if (stepAround)
                    {
                        categoryAxis1.Labels.Add(string.Format("{0} ({1})", multipleSets ? Properties.Resources.side_forehand_steparound_short : Properties.Resources.side_forehand_steparound, statistics.ForehandStepAround));
                        wonSeries.Items.Add(new BarItem(statistics.ForehandStepAroundWon, categoryNr));
                        var fhSaLost = statistics.ForehandStepAround - statistics.ForehandStepAroundWon;
                        if (fhSaLost > 0)
                        {
                            lostSeries.Items.Add(new BarItem(fhSaLost, categoryNr));
                        }
                        categoryNr++;
                    }

                    categoryAxis1.Labels.Add(string.Format("{0} ({1})", multipleSets ? Properties.Resources.side_forehand_short : Properties.Resources.side_forehand, statistics.Forehand));
                    wonSeries.Items.Add(new BarItem(statistics.ForehandWon, categoryNr));
                    var spinUpLost = statistics.Forehand - statistics.ForehandWon;
                    if (spinUpLost > 0)
                    {
                        lostSeries.Items.Add(new BarItem(spinUpLost, categoryNr));
                    }
                    categoryNr++;

                    plot.Series.Add(wonSeries);
                    plot.Series.Add(lostSeries);

                    plot.Axes.Add(categoryAxis1);
                    plot.Axes.Add(linearAxis1);

                    SidePlots.Add(plot);

                    Debug.WriteLine("{2} for stroke {0} of set {1} ready.", GetStrokeNumberString(strokeNr), set, SectionName);
                }
            }
        }