예제 #1
0
        public List <CarboDataPoint> getMaterialTotals()
        {
            List <CarboDataPoint> valueList = new List <CarboDataPoint>();

            try
            {
                foreach (CarboGroup CarboGroup in this.groupList)
                {
                    CarboDataPoint newelement = new CarboDataPoint();
                    newelement.Name  = CarboGroup.MaterialName;
                    newelement.Value = CarboGroup.EC;

                    bool merged = false;

                    if (valueList.Count > 0)
                    {
                        foreach (CarboDataPoint pp in valueList)
                        {
                            if (pp.Name == newelement.Name)
                            {
                                pp.Value += newelement.Value;
                                merged    = true;
                                break;
                            }
                        }
                    }
                    if (merged == false)
                    {
                        valueList.Add(newelement);
                    }
                }
            }
            catch
            {
                return(null);
            }

            //Values should return now;
            return(valueList);
        }
예제 #2
0
        /// <summary>
        /// Returns a list of the project totals (9 items)
        /// A1-A3, A4, A5 (Material), A5(Global), B1-B7, C1-C4, C1(Global), D, Additional)
        /// These are net values(based on the corrected converted Total Volume
        /// </summary>
        /// <returns>Returns a list of the project totals (9 items) in kgCO₂</returns>
        public List <CarboDataPoint> getPhaseTotals()
        {
            List <CarboDataPoint> valueList = new List <CarboDataPoint>();

            try
            {
                CarboDataPoint cb_A1A3     = new CarboDataPoint("A1-A3", 0);
                CarboDataPoint cb_A4       = new CarboDataPoint("A4", 0);
                CarboDataPoint cb_A5       = new CarboDataPoint("A5(Material)", 0);
                CarboDataPoint cb_A5Global = new CarboDataPoint("A5(Global)", this.A5Global * 1000);
                CarboDataPoint cb_B1B5     = new CarboDataPoint("B1-B7", 0);
                CarboDataPoint cb_C1C4     = new CarboDataPoint("C1-C4", 0);
                CarboDataPoint cb_C1Global = new CarboDataPoint("C1(Global)", this.C1Global * 1000);
                CarboDataPoint cb_D        = new CarboDataPoint("D", 0);
                CarboDataPoint Added       = new CarboDataPoint("Additional", 0);

                valueList.Add(cb_A1A3);
                valueList.Add(cb_A4);
                valueList.Add(cb_A5);
                valueList.Add(cb_A5Global);
                valueList.Add(cb_B1B5);
                valueList.Add(cb_C1C4);
                valueList.Add(cb_C1Global);
                valueList.Add(cb_D);
                valueList.Add(Added);

                foreach (CarboGroup CarboGroup in this.groupList)
                {
                    double EC_A1A3 = CarboGroup.getTotalA1A3;
                    double EC_A4   = CarboGroup.getTotalA4;
                    double EC_A5   = CarboGroup.getTotalA5;
                    double EC_B1B7 = CarboGroup.getTotalB1B7;
                    double EC_C1C4 = CarboGroup.getTotalC1C4;
                    double EC_D    = CarboGroup.getTotalD;
                    double EC_Add  = CarboGroup.getTotalMix;

                    if (valueList.Count > 0)
                    {
                        foreach (CarboDataPoint pp in valueList)
                        {
                            string ppName = pp.Name;

                            if (ppName == "A1-A3")
                            {
                                pp.Value += EC_A1A3;
                            }
                            else if (ppName == "A4")
                            {
                                pp.Value += EC_A4;
                            }
                            else if (ppName == "A5(Material)")
                            {
                                pp.Value += EC_A5;
                            }
                            else if (ppName == "B1-B7")
                            {
                                pp.Value += EC_B1B7;
                            }
                            else if (ppName == "C1-C4")
                            {
                                pp.Value += EC_C1C4;
                            }
                            else if (ppName == "D")
                            {
                                pp.Value += EC_D;
                            }
                            else if (ppName == "Additional")
                            {
                                pp.Value += EC_Add;
                            }
                            else
                            {
                                pp.Value += 0;
                            }
                        }
                    }
                }
            }
            catch
            {
                return(null);
            }

            //Values should return now;
            return(valueList);
        }
예제 #3
0
        /// <summary>
        /// This returns the pie chart of the projects phases total A1-D and Mixed
        /// </summary>
        /// <param name="carboLifeProject"></param>
        /// <returns></returns>
        internal static SeriesCollection GetPieChartTotals(CarboProject carboLifeProject)
        {
            SeriesCollection result = new SeriesCollection();

            try
            {
                List <CarboDataPoint> PieceListLifePoint = new List <CarboDataPoint>();

                PieceListLifePoint = carboLifeProject.getPhaseTotals();

                //Remove the zero's
                for (int i = PieceListLifePoint.Count - 1; i >= 0; i--)
                {
                    CarboDataPoint cp = PieceListLifePoint[i] as CarboDataPoint;
                    if (cp.Value == 0)
                    {
                        PieceListLifePoint.RemoveAt(i);
                    }
                }

                //make positive if negative
                foreach (CarboDataPoint cp in PieceListLifePoint)
                {
                    if (cp.Value < 0)
                    {
                        cp.Name  = "(Negative)" + cp.Name;
                        cp.Value = cp.Value * -1;
                    }
                }


                Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} tCO₂", chartPoint.Y, chartPoint.Participation);


                foreach (CarboDataPoint ppin in PieceListLifePoint)
                {
                    PieSeries newSeries = new PieSeries
                    {
                        Title  = ppin.Name,
                        Values = new ChartValues <double> {
                            Math.Round(ppin.Value / 1000, 2)
                        },
                        PushOut    = 1,
                        DataLabels = true,
                        LabelPoint = labelPoint
                    };

                    newSeries.Foreground = Brushes.Black;
                    newSeries.FontWeight = FontWeights.Normal;
                    newSeries.FontStyle  = FontStyles.Normal;
                    newSeries.FontSize   = 12;

                    result.Add(newSeries);
                }
            }
            catch
            {
                return(null);
            }
            return(result);
        }
예제 #4
0
        internal static SeriesCollection GetPieChartMaterials(CarboProject carboLifeProject)
        {
            SeriesCollection result = new SeriesCollection();

            try
            {
                List <CarboDataPoint>     PieceListMaterial = new List <CarboDataPoint>();
                Func <ChartPoint, string> labelPoint        = chartPoint => string.Format("{0} tCO₂", chartPoint.Y, chartPoint.Participation);

                PieceListMaterial = carboLifeProject.getMaterialTotals();

                PieceListMaterial = PieceListMaterial.OrderByDescending(o => o.Value).ToList();

                //int total = monValues.Sum(x => Convert.ToInt32(x));

                double total = PieceListMaterial.Sum(x => x.Value);

                //Old Code:
                //if there are too many materials in the list combine any items over 8.

                /*
                 * if (PieceListMaterial.Count > 8)
                 * {
                 *  CarboDataPoint otherPoint = new CarboDataPoint();
                 *  otherPoint.Name = "Miscellaneous";
                 *
                 *  for (int i = PieceListMaterial.Count -1; i>7; i--)
                 *  {
                 *      CarboDataPoint cp = PieceListMaterial[i] as CarboDataPoint;
                 *      otherPoint.Value += cp.Value;
                 *      PieceListMaterial.RemoveAt(i);
                 *  }
                 *  PieceListMaterial.Add(otherPoint);
                 * }
                 */

                //New Code: Trim all values below 5%,
                List <int> counter = new List <int>();

                CarboDataPoint otherPoint = new CarboDataPoint();
                otherPoint.Name = "Miscellaneous";

                for (int i = PieceListMaterial.Count - 1; i >= 0; i--)
                {
                    CarboDataPoint cp     = PieceListMaterial[i] as CarboDataPoint;
                    double         pecent = cp.Value / total;
                    if (pecent <= 0.05 && pecent > 0)
                    {
                        //The item is too small for the graph:
                        otherPoint.Value += cp.Value;
                        counter.Add(i);
                    }
                }

                //If used, add to the list, only if more than one materials / elements were merged.
                if (otherPoint.Value > 0 && counter.Count > 1)
                {
                    PieceListMaterial.Add(otherPoint);
                    //Remove the items from the list
                    foreach (int i in counter)
                    {
                        PieceListMaterial.RemoveAt(i);
                    }
                }



                //make positive if negative
                foreach (CarboDataPoint cp in PieceListMaterial)
                {
                    if (cp.Value < 0)
                    {
                        cp.Name  = "(Negative)" + cp.Name;
                        cp.Value = cp.Value * -1;
                    }
                }


                foreach (CarboDataPoint ppin in PieceListMaterial)
                {
                    PieSeries newSeries = new PieSeries
                    {
                        Title  = ppin.Name,
                        Values = new ChartValues <double> {
                            Math.Round(ppin.Value, 2)
                        },
                        PushOut    = 1,
                        DataLabels = true,
                        LabelPoint = labelPoint
                    };
                    newSeries.Foreground = Brushes.Black;
                    newSeries.FontWeight = FontWeights.Normal;
                    newSeries.FontStyle  = FontStyles.Normal;
                    newSeries.FontSize   = 12;

                    result.Add(newSeries);
                }
            }
            catch
            {
                return(null);
            }
            return(result);
        }
예제 #5
0
        public List <CarboDataPoint> getTotals(string value)
        {
            List <CarboDataPoint> valueList = new List <CarboDataPoint>();

            if (value != "")
            {
                foreach (CarboGroup CarboGroup in this.groupList)
                {
                    CarboDataPoint newelement = new CarboDataPoint();
                    newelement.Name  = CarboGroup.MaterialName;
                    newelement.Value = CarboGroup.EC;

                    bool merged = false;

                    if (valueList.Count > 0)
                    {
                        foreach (CarboDataPoint pp in valueList)
                        {
                            if (pp.Name == newelement.Name)
                            {
                                pp.Value += newelement.Value;
                                merged    = true;
                                break;
                            }
                        }
                    }
                    if (merged == false)
                    {
                        valueList.Add(newelement);
                    }
                }
            }
            //Would be Per life
            else
            {
                CarboDataPoint cb_A1A3 = new CarboDataPoint("A1 A3", 0);
                CarboDataPoint cb_A4   = new CarboDataPoint("A4", 0);
                CarboDataPoint cb_A5   = new CarboDataPoint("A5", 0);
                //CarboDataPoint cb_B1B5 = new CarboDataPoint("B1 B5", 0);
                CarboDataPoint cb_C1C4 = new CarboDataPoint("C1 C4", 0);
                CarboDataPoint cb_D    = new CarboDataPoint("D", 0);

                valueList.Add(cb_A1A3);
                valueList.Add(cb_A4);
                valueList.Add(cb_A5);
                //valueList.Add(cb_B1B5);
                valueList.Add(cb_C1C4);
                valueList.Add(cb_D);


                foreach (CarboGroup CarboGroup in this.groupList)
                {
                    double ECI_A1A3 = CarboGroup.Material.ECI_A1A3;
                    double ECI_A4   = CarboGroup.Material.ECI_A4;
                    double ECI_A5   = CarboGroup.Material.ECI_A5;
                    //double ECI_B1B5 = CarboGroup.Material.ECI_B1B5;
                    double ECI_C1C4 = CarboGroup.Material.ECI_C1C4;
                    double ECI_D    = CarboGroup.Material.ECI_D;

                    if (valueList.Count > 0)
                    {
                        foreach (CarboDataPoint pp in valueList)
                        {
                            string ppName = pp.Name;

                            if (ppName == "A1 A3")
                            {
                                pp.Value += ECI_A1A3;
                            }
                            else if (ppName == "A4")
                            {
                                pp.Value += ECI_A4;
                            }
                            else if (ppName == "A5")
                            {
                                pp.Value += ECI_A5;
                            }
                            //else if (ppName == "B1 B5")
                            //{
                            //    pp.Value += ECI_B1B5;
                            //}
                            else if (ppName == "C1 C4")
                            {
                                pp.Value += ECI_C1C4;
                            }
                            else if (ppName == "D")
                            {
                                pp.Value += ECI_D;
                            }
                            else
                            {
                                pp.Value = 0;
                            }
                        }
                    }
                }
            }


            //ValidateData
            foreach (CarboDataPoint cp in valueList)
            {
                if (cp.Value < 0)
                {
                    cp.Value = cp.Value * -1;
                    cp.Name  = cp.Name + "[NEGATIVE]";
                }
            }

            //Values should return now;
            return(valueList);
        }