Example #1
0
        public void LoadPlotModel(HandType type)
        {
            string title = $"{Report.Spot.Action} {Report.Spot.AggPos}vs{Report.Spot.CllPos} {Report.Spot.BoardType} {Report.Spot.BoardSubtype} {type}";

            PlotModel = new PlotModel {
                Title           = title, TitleColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour,
                LegendTextColor = ThemeModel.OxyForegroundColour, PlotAreaBorderColor = ThemeModel.OxyForegroundColour
            };
            OxyPlot.Axes.LinearAxis yAxis = new OxyPlot.Axes.LinearAxis {
                Position = AxisPosition.Left, MajorStep = 10, MinorStep = 10, Minimum = 0, Maximum = 100, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour
            };
            OxyPlot.Axes.LinearAxis xAxis = new OxyPlot.Axes.LinearAxis {
                Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1, AxislineColor = ThemeModel.OxyForegroundColour, TextColor = ThemeModel.OxyForegroundColour
            };
            // CategoryAxis catAxis = new CategoryAxis( {Position = AxisPosition.Bottom, MajorStep = 1, MinorStep = 1);
            xAxis.LabelFormatter = getXLabel;
            PlotModel.Axes.Add(xAxis);
            PlotModel.Axes.Add(yAxis);

            handGroup = Report.GetHandGroup(type);
            string[] frequencyLabels = handGroup.GetFrequencyLabels();
            foreach (string frequencyLabel in frequencyLabels)
            {
                List <DataPoint> pointsList = new List <DataPoint>();
                FrequencyValues  freqValues = handGroup.GetFrequencyValues(frequencyLabel);
                foreach (int order in freqValues.GetHandStrengthOrders())
                {
                    pointsList.Add(new DataPoint(order, freqValues.GetFrequency(order)));
                }
                LineSeries series = new LineSeries()
                {
                    InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline,
                    Title       = frequencyLabel,
                    ItemsSource = pointsList,

                    MarkerSize = 5,
                    MarkerType = MarkerType.Circle
                };

                PlotModel.Series.Add(series);
            }
        }
Example #2
0
        // Reads in the data from the CSV file and parses it to the Data collection
        protected void loadData()
        {
            DeterminePotsize();
            freqLabels = new List <string>();
            using (var file = new FileStream(@filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (var reader = new StreamReader(file))
                {
                    staticTimer.start("ReportReading");
                    if (!reader.EndOfStream)
                    {
                        headers = reader.ReadLine().Split(',');
                        for (int i = 0; i < headers.Length; i++)
                        {
                            if (headers[i].EndsWith("Freq"))
                            {
                                freqColumns.Add(i);
                                freqLabels.Add(getFrequencyLabel(headers[i]));
                            }
                        }
                    }
                    staticTimer.stop("ReportReading");

                    int rownumber = 2;
                    while (!reader.EndOfStream)
                    {
                        staticTimer.start("ReportReading");
                        string   line   = reader.ReadLine();
                        string[] values = line.Split(',');
                        data.Add(values);
                        Dictionary <string, float> frequencies = new Dictionary <string, float>();

                        int i = 0;
                        foreach (int freqColumn in freqColumns)
                        {
                            frequencies.Add(freqLabels[i], float.Parse(values[freqColumn]));
                            i++;
                        }
                        Hand hand = new Hand(values[Mappings.ReportColumns["Flop"]], values[Mappings.ReportColumns["Hand"]], float.Parse(values[Mappings.ReportColumns["Weight"]]), frequencies, rownumber++);
                        hands.Add(hand);
                        staticTimer.stop("ReportReading");
                        HandGroup group;
                        if (handTypes.TryGetValue(hand.Strength.Type, out group))
                        {
                            group.addHand(hand);
                        }
                        else
                        {
                            HandGroup newGroup = new HandGroup(spot, hand.Strength.Category, hand.Strength.Type);
                            newGroup.addHand(hand);
                            handTypes.Add(hand.Strength.Type, newGroup);
                        }

                        HashSet <HandType> typeSet;
                        if (handCategories.TryGetValue(hand.Strength.Category, out typeSet))
                        {
                            typeSet.Add(hand.Strength.Type);
                        }
                        else
                        {
                            HashSet <HandType> newSet = new HashSet <HandType>();
                            newSet.Add(hand.Strength.Type);
                            handCategories.Add(hand.Strength.Category, newSet);
                        }
                    }
                }
            staticTimer.log("ReportReading");
            staticTimer.log("HandStrength");

            isLoaded = true;
        }