public CreateTrendline(List<fPoint> searchMaxMin,string eventType)
        {
            EventType = eventType;
            MaxMin = new List<fPoint>(searchMaxMin.Count);
            foreach (fPoint a in searchMaxMin)
            {
                MaxMin.Add(a);
            }
            //MaxMin = searchMaxMin;

            if (MaxMin.Count >= 2)
            {
                //method to find the largest and smallest values
                fPoint smallest = MaxMin[0], largest = MaxMin[0];
                foreach (fPoint f in MaxMin)
                {
                    if (largest.getX_Age().CompareTo(f.getX_Age()) < 0 && f.getX_Age().CompareTo(1111) != 0) { largest = f; }
                    if (smallest.getX_Age().CompareTo(f.getX_Age()) > 0) { smallest = f; }
                }

                decimal x = smallest.getX_Age();                              //starting x value

                decimal range = largest.getX_Age() - smallest.getX_Age();     //range

                decimal maxRange = range * 50;                               //the maximum amount of range points

                decimal delta = (decimal)0.02;                                        //the increment of age

                //method to set hundreds of values in a list between the Min and Max values
                //double rangeMM = largest.getX_Age() - smallest.getX_Age();

                //double maxRange = rangeMM * 50;
                //rangeMM = 0.02;

                Range = new List<fPoint>((int)maxRange);
                for (int i = 0; i < maxRange; i++)
                {
                    Range.Add(fPoint.ConstructDefault());
                }

                //double percentValue = smallest.getX_Age() + rangeMM;

                //Range[0] = smallest;
                //Range[(int)(maxRange-1)] = largest;

                //get ABC off the x,y user data.
                PolynomialGraph pg = new PolynomialGraph();
                decimal[] tempABC = pg.Polynomial(MaxMin);

                for (int i = 0; i < maxRange; i++)
                {
                    decimal x_val = x;
                    Range[i] = new fPoint(x_val, tempABC[0] * (x_val * x_val) + tempABC[1] * x_val + tempABC[2]);
                    x = x_val + delta;
                }
                int p = 0;
                p++;
            }
        }
        public CreateTrendline(List<fPoint> searchMaxMin)
        {
            MaxMin = searchMaxMin;

            if (MaxMin.Count >= 2)
            {
                //method to find the largest and smallest values
                fPoint smallest = MaxMin[0], largest = MaxMin[0];
                foreach (fPoint f in MaxMin)
                {
                    if (largest.getX_Age().CompareTo(f.getX_Age()) < 0 && f.getX_Age().CompareTo(1111)!=0) { largest = f; }
                    if (smallest.getX_Age().CompareTo(f.getX_Age()) > 0) { smallest = f; }
                }

                //method to set hundreds of values in a list between the Min and Max values
                double rangeMM = largest.getX_Age() - smallest.getX_Age();

                double maxRange = rangeMM * 50;
                rangeMM = 0.02;

                Range = new List<fPoint>((int)maxRange);
                for (int i = 0; i < maxRange; i++)
                {
                    Range.Add(new fPoint());
                }

                double percentValue = smallest.getX_Age()+rangeMM;

                Range[0] = smallest;
                Range[(int)(maxRange - 1)] = largest;
                for (int i = 1; i < maxRange; i++)
                {
                    Range[i] = new fPoint((float)percentValue, 1111f);
                    percentValue += rangeMM;
                }

                //get ABC off the x,y user data.
                PolynomialGraph pg = new PolynomialGraph();
                float[] tempABC = pg.Polynomial(searchMaxMin);
                //MessageBox.Show(searchMaxMin[2].getX_Age()+"");

                //MessageBox.Show("A: "+tempABC[0] + " B: " + tempABC[1] + " C: " + tempABC[2]);

                //use ABC + equation on range to get Y
                string temp = "";
                foreach (fPoint p in Range)
                {
                    p.setY_Value(tempABC[0] * (p.getX_Age() * p.getX_Age()) + tempABC[1] * p.getX_Age() + tempABC[2]);
                    temp += "\r\n" + p.getX_Age()+ " " + p.getY_Value_AsFloat();
                }
                //MessageBox.Show(temp);
                //MessageBox.Show(Range.Count()+" "+ Range[Range.Count - 1].getX_Age());
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            createNewList();

            // Make up some data points from the Sine function

            PolynomialGraph pg = new PolynomialGraph();
            float[] abc = pg.Polynomial(UserDataPoints);

            PointPairList list = new PointPairList();
            for (int i = 0; i < UserDataPoints.Count; i++)
            {

                ////               //list.Add(UserDataPoints[i].getX_Age(), new XDate(UserDataPoints[i].getY_Value_AsDate()));
                list.Add(UserDataPoints[i].getX_Age(), UserDataPoints[i].getY_Value_AsFloat());
            }

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve = myPane.AddCurve("My Curve", list, Color.Blue, SymbolType.Circle);
            myCurve.Line.IsVisible = false;

            CreateTrendline ct = new CreateTrendline(ListOfUserDataPoints);

            LineItem myCurve2 = myPane.AddCurve("My Curve", ct.getTrendList(), Color.Red, SymbolType.None);
            //CurveItem myCurve = myPane.AddCurve("My Curve", list, Color.Blue, SymbolType.None);
            // Fill the area under the curve with a white-red gradient at 45 degrees
            //myCurve.Line.Fill = new Fill(Color.White, Color.Red, 45F);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
            // Fill the pane background with a color gradient
            myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
            // Calculate the Axis Scale Ranges
            zg1.AxisChange();
            zg1.IsEnableHPan = true;
            zg1.Invalidate();
        }
        public CreateTrendline(List<fPoint> searchMaxMin,string eventType)
        {
            EventType = eventType;
            MaxMin = new List<fPoint>(searchMaxMin.Count);
            foreach (fPoint a in searchMaxMin)
            {
                MaxMin.Add(a);
            }
            //MaxMin = searchMaxMin;

            if (MaxMin.Count >= 2)
            {
                //method to find the largest and smallest values
                fPoint smallest = MaxMin[0], largest = MaxMin[0];
                foreach (fPoint f in MaxMin)
                {
                    if (largest.getX_Age().CompareTo(f.getX_Age()) < 0 && f.getX_Age().CompareTo(1111) != 0) { largest = f; }
                    if (smallest.getX_Age().CompareTo(f.getX_Age()) > 0) { smallest = f; }
                }

                double x = smallest.getX_Age();                              //starting x value

                double range = largest.getX_Age() - smallest.getX_Age();     //range

                double maxRange = range * 50;                               //the maximum amount of range points

                double delta = 0.02f;                                        //the increment of age

                //method to set hundreds of values in a list between the Min and Max values
                //double rangeMM = largest.getX_Age() - smallest.getX_Age();

                //double maxRange = rangeMM * 50;
                //rangeMM = 0.02;

                Range = new List<fPoint>((int)maxRange);
                for (int i = 0; i < maxRange; i++)
                {
                    Range.Add(fPoint.ConstructDefault());
                }

                //double percentValue = smallest.getX_Age() + rangeMM;

                Range[0] = smallest;
                //Range[(int)(maxRange-1)] = largest;

                //get ABC off the x,y user data.
                PolynomialGraph pg = new PolynomialGraph();
                double[] tempABC = pg.Polynomial(MaxMin);

                for (int i = 1; i < maxRange; i++)
                {
                    double x_val = x;
                    Range[i] = new fPoint(x_val, tempABC[0] * (x_val * x_val) + tempABC[1] * x_val + tempABC[2]);
                    x = x_val + delta;
                }
                int p = 0;
                p++;

                //MessageBox.Show(searchMaxMin[2].getX_Age()+"");

                //MessageBox.Show("A: "+tempABC[0] + " B: " + tempABC[1] + " C: " + tempABC[2]);

                //use ABC + equation on range to get Y
                //string temp = "";
                //foreach (fPoint g in Range)
                //{
                //    temp += g.getX_Age() + " " + g.getY_Value_AsDate().Minute + ":" + g.getY_Value_AsDate().Second + "." + g.getY_Value_AsDate().Millisecond + "\r\n";
                //}
                //MessageBox.Show(temp);
            }
        }