Пример #1
0
        public LabListing(IPpnRepo ppnRepo)
        {
            _ppnRepo = ppnRepo;
            InitializeComponent();

            LabsGrid.ItemsSource = _ppnRepo.GetLabs();
        }
Пример #2
0
        public LabReport(IPpnRepo ppnRepo, int labId)
        {
            _ppnRepo = ppnRepo;
            InitializeComponent();

            var lab = _ppnRepo.GetLab(labId);

            if (lab == null)
            {
                throw new NullReferenceException($"There is no lab in the database with a LabId of {labId}");
            }

            ProcessCharForEachNutrient(lab);
        }
Пример #3
0
        public LabChart(IPpnRepo ppnRepo, string nutrientName, double nutrientValue, string horseName, List <NutrientBulletPoint> bulletPoints)
        {
            _ppnRepo = ppnRepo;
            var nutrientAverage    = _ppnRepo.NutrientAverage(nutrientName);
            var nutrientTolerances = _ppnRepo.HighLowTolerance(nutrientAverage);

            Nutrient = nutrientName;


            SeriesCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = horseName,
                    Values = new ChartValues <double> {
                        Math.Round(nutrientValue, 2)
                    },
                    FontFamily = new FontFamily("./Fonts/#Open Sans Condensed Light"),
                    DataLabels = true
                },
                new ColumnSeries
                {
                    Title  = "All Horses Average",
                    Values = new ChartValues <double> {
                        Math.Round(nutrientAverage, 2)
                    },
                    FontFamily = new FontFamily("./Fonts/#Open Sans Condensed Light"),
                    DataLabels = true
                }
            };

            DataContext  = this;
            NutrientName = nutrientName;
            if (bulletPoints.Any() && bulletPoints[0].Range == "Heavy Metal")
            {
                BulletPoints = bulletPoints;
            }
            else if (nutrientValue > nutrientTolerances.HighTolerance)
            {
                BulletPoints = bulletPoints.Where(bp => bp.Range == "Excessive").ToList();
            }
            else if (nutrientValue < nutrientTolerances.LowTolerance)
            {
                BulletPoints = bulletPoints.Where(bp => bp.Range == "Deficient").ToList();
            }
            else
            {
                BulletPoints = new List <NutrientBulletPoint>
                {
                    new NutrientBulletPoint
                    {
                        NutrientName = nutrientName,
                        BulletPoint  = $"{nutrientName} is within tolerance"
                    }
                }
            };


            Formatter = value => Math.Round(value, 2).ToString();
            //Labels = new string[] { nutrientValue.ToString(), Math.Round(nutrientAverage,0).ToString() };

            InitializeComponent();

            if (nutrientValue != 0 && nutrientAverage != 0)
            {
                NutrientChart.AxisY.Clear();
                NutrientChart.AxisY.Add(
                    new Axis
                {
                    Separator = new LiveCharts.Wpf.Separator
                    {
                        Step = nutrientAverage > nutrientValue
                                ? nutrientAverage * 0.30
                                : nutrientValue * 0.30
                    },
                    LabelFormatter = Formatter
                }
                    );
            }
        }