/// <param name="athleteName">Name of the athlete</param>
        /// <param name="status">Placing the athlete got "Medal":"Final":"Other"</param>
        /// <param name="data">List of Points of the athletes Dates and Performances</param>
        public Athletes(string athleteName, string status, List<fPoint> data,string eventType)
        {
            this.AthleteName = athleteName;
            this.Status = status;
            this.Data = new List<fPoint>();
            this.List = new PointPairList();
            if (eventType.CompareTo("e.g. mm:ss.ss") == 0) { this.Event = "Track"; }
            else { this.Event = "Field"; }

            if (data[0].getX_Age().CompareTo(1111) != 0)
            {
                CreateTrendline ct = new CreateTrendline(data,this.Event);
                List = ct.getTrendList();
            }
            AthleteName = athleteName;
            Status = status;
            Data = data;
        }
Example #2
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            FormSaved = false;
            try
            {
                if (!setUP)
                {

                    if (checkFormat().CompareTo("working") == 0)
                    {

                        string locationColumn = LocateLocation();

                        excelWrapper1.Workbook.ActiveSheet.Unprotect("1500kosmin");

                        if (dataGridView1.CurrentCell.Value != null)
                        {
                            if (dataGridView1.CurrentCell.Value.ToString().Contains("e.g."))
                            {
                                //value in this field is an e.g.
                            }
                            else
                            {
                                //this cell has a value but it is not an e.g.

                                ///need to find out the location, if date then do the date thing
                                ///so that means...
                                ///if(dd/mm/yyyy where mm < 12) split the date and export it to excel as mm/dd/yyyy //turns it into mm/dd/yyyy format
                                ///if(dd/mm/yyyy where mm > 12) export it to excel as dd/mm/yyyy <-so leave it how it is. //its already in mm/dd/yyyy format

                                string valueToAddToExcel = dataGridView1.CurrentCell.Value.ToString();
                                string tempValueForTimes = valueToAddToExcel;
                                //working in the DateOfPerformanceColumn
                                if (locationColumn.Contains("AI"))
                                {
                                    string[] tempDate = valueToAddToExcel.Split('/');
                                    if (Convert.ToInt32(tempDate[1]) <= 12)
                                    {
                                        valueToAddToExcel = tempDate[1] + "/" + tempDate[0] + "/" + tempDate[2];
                                    }
                                    else
                                    {

                                        dataGridView1.CurrentCell.Value = tempDate[1] + "/" + tempDate[0] + "/" + tempDate[2];
                                    }
                                }
                                //working in the Performance
                                if (locationColumn.Contains("AK") && PerformanceEG.Contains("e.g. mm:ss.ss"))
                                {
                                    //if its not in the form MM:SS.ss then{
                                    if (valueToAddToExcel.Contains(":") && valueToAddToExcel.Contains(".")) { }
                                    else
                                    {
                                        if (valueToAddToExcel.CompareTo("") != 0)
                                        {
                                            string[] tempDate = valueToAddToExcel.Split(':', '.');

                                            switch (eventName)
                                            {
                                                case "W100m":
                                                case "M100m":
                                                case "W100m Hurdles":
                                                case "M110m Hurdles":
                                                case "W200m":
                                                case "M200m":
                                                case "M400m":
                                                    //if its in the form aa:bb then { assume 00:aa.bb }
                                                    //if its in the form aa.bb then { assume 00:aa.bb }
                                                        valueToAddToExcel = "00:" + tempDate[0] + "." + tempDate[1];
                                                        tempValueForTimes = tempDate[0] + "." + tempDate[1];
                                                    break;
                                                default:
                                                    //if its in the form aa:bb then { assume aa:bb.00 }
                                                    //if its in the form aa.bb then { assume 00:aa.bb }
                                                    if (valueToAddToExcel.Contains(":"))
                                                    {
                                                        valueToAddToExcel = tempDate[0] + ":" + tempDate[1] + ".00";
                                                        double temp = Convert.ToDouble(tempDate[0]) * 60 + Convert.ToDouble(tempDate[1]);
                                                        tempValueForTimes = temp.ToString();
                                                    }
                                                    else
                                                    {
                                                        valueToAddToExcel = "00:" + tempDate[0] + "." + tempDate[1];
                                                        tempValueForTimes = tempDate[0] + "." + tempDate[1];
                                                    }
                                                    break;
                                            }
                                        }
                                    }

                                    dataGridView1.CurrentCell.Value = valueToAddToExcel;
                                    string[] tempDate1 = valueToAddToExcel.Split(':', '.');
                                    double temp1 = Convert.ToDouble(tempDate1[0]) * 60 + Convert.ToDouble(tempDate1[1]);
                                    tempValueForTimes = temp1.ToString()+"."+tempDate1[2];

                                }
                                dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[dataGridView1.CurrentCellAddress.X].Style.ForeColor = Color.Black;
                                excelWrapper1.Workbook.ActiveSheet.Range(locationColumn).Value = valueToAddToExcel;
                                //add data to ListOfUserDataPoints
                                if (dataGridView1.CurrentCellAddress.X == 0)
                                {
                                    //age of the athlete
                                    ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y].setX_Age(dateFromNow(valueToAddToExcel));

                                    //checks if its partner exists. If it does, add to UserDataPoints list
                                    if (ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y].getY_Value_Asdouble().CompareTo((decimal)11111) != 0)
                                    {
                                        UserDataPoints.Add(ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y]);

                                    }
                                }
                                //if y_val needs changing
                                if (dataGridView1.CurrentCellAddress.X == 1)
                                {
                                    if (Event.CompareTo("Track") == 0)
                                    {
                                        double tt = ((Convert.ToDouble(tempValueForTimes) / 60) / 60) / 24;
                                        ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y].setY_Value(Convert.ToDecimal(tt));
                                    }
                                    else
                                    {
                                        ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y].setY_Value(Convert.ToDecimal(valueToAddToExcel));
                                    }

                                    //checks if its partner exists. If it does, add to UserDataPoints list
                                    if (ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y].getX_Age().CompareTo((decimal)11111) != 0)
                                    {
                                        UserDataPoints.Add(ListOfUserDataPoints[dataGridView1.CurrentCellAddress.Y]);
                                    }
                                }
                            }
                        }
                        else
                        {
                            //MessageBox.Show("this cell is Null");
                            excelWrapper1.Workbook.ActiveSheet.Range(locationColumn).Value = dataGridView1.CurrentCell.Value;
                        }
                        excelWrapper1.Workbook.ActiveSheet.Protect("1500kosmin", false);

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        if (UserDataPoints.Count > 0)
                        {
                            if (Event.CompareTo("Track") == 0)
                            {
                                list.Add(Convert.ToDouble(UserDataPoints[UserDataPoints.Count - 1].getX_Age()), new XDate(UserDataPoints[UserDataPoints.Count - 1].getY_Value_AsDate()));
                            }
                            else
                            {
                                list.Add(Convert.ToDouble(UserDataPoints[UserDataPoints.Count - 1].getX_Age()), Convert.ToDouble(UserDataPoints[UserDataPoints.Count - 1].getY_Value_Asdouble()));
                            }
                        }
                        LineItem myPoints = myPane.AddCurve("Points", list, Color.Black, SymbolType.Circle);
                        myPoints.Line.IsVisible = false;
                        myPoints.Symbol.Size = symbolSize;

                        if (UserDataPoints.Count > 2)
                        {
                            if (addedUserData)
                            {
                                myPane.CurveList.RemoveAt(myPane.CurveList.Count() - 1);
                                myPane.CurveList.RemoveAt(myPane.CurveList.Count() - 1);
                            }
                            CreateTrendline ct = new CreateTrendline(UserDataPoints, Event);
                            LineItem myCurve = myPane.AddCurve("Curve", ct.getTrendList(), Color.Black, SymbolType.None);
                            addedUserData = true;
                            zg1.Invalidate();
                        }
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                    }
                    else { MessageBox.Show(checkFormat()); dataGridView1.CurrentCell.Value = tempValueInCell; }
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("" + ee);
            }
        }
Example #3
0
        /// <summary>
        /// gets the values from the excel Document and adds it to the dataGridView
        /// </summary>
        private void addValuesToDataGridView()
        {
            if (PerformanceEG.CompareTo("e.g. mm:ss.ss") == 0) { Event = "Track"; }
            else { Event = "Field"; }

            progressBar1.Value = 80;
            for (int i = 3; i <= 150; i++)
            {
                string AIName = "AI" + i;
                string AKName = "AK" + i;
                string tempValueX = "11111", tempValueY = "11111";
                if (excelWrapper1.Workbook.ActiveSheet.Range[AIName].Value != null)
                {//Left hand Column
                    DataGridViewCell cell = dataGridView1.Rows[(i - 3)].Cells[0];
                    dataGridView1.CurrentCell = cell;
                    //gets the date out of Excel
                    string DateOfEventTemp = excelWrapper1.Workbook.ActiveSheet.Range[AIName].Value.ToString();
                    //splits the date off from time
                    string[] Temp = DateOfEventTemp.Split(' ');

                    //splits the date up into 3
                    string[] dateOut = Temp[0].Split('/');
                    //changes mm/dd/yyyy to dd/mm/yyyy
                    string disp = dateOut[1] + "/" + dateOut[0] + "/" + dateOut[2];
                    //Xvalue placement
                    tempValueX = Convert.ToString(dateFromNow(dateOut[0] + "/" + dateOut[1] + "/" + dateOut[2]));

                    dataGridView1.CurrentCell.Value = disp;
                    dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[dataGridView1.CurrentCellAddress.X].Style.ForeColor = Color.Black;
                }
                if (excelWrapper1.Workbook.ActiveSheet.Range[AKName].Value != null)
                {//Right hand Column
                    DataGridViewCell cell = dataGridView1.Rows[(i - 3)].Cells[1];
                    dataGridView1.CurrentCell = cell;
                    if (PerformanceEG.CompareTo("e.g. mm:ss.ss") == 0)
                    {
                        double ipet = ((24 * excelWrapper1.Workbook.ActiveSheet.Range[AKName].Value) * 60) * 60;
                        double seconds = ipet % 60;
                        int mins = Convert.ToInt32((ipet - seconds) / 60);
                        dataGridView1.CurrentCell.Value = mins + ":" + Math.Round(seconds, 2);
                    }
                    else
                    {
                        dataGridView1.CurrentCell.Value = "" + excelWrapper1.Workbook.ActiveSheet.Range[AKName].Value;
                    }
                    tempValueY = excelWrapper1.Workbook.ActiveSheet.Range[AKName].Value.ToString();
                    //dataGridView1.Columns[1].DefaultCellStyle.Format = "HH:mm:ss";
                    dataGridView1.Rows[dataGridView1.CurrentCellAddress.Y].Cells[dataGridView1.CurrentCellAddress.X].Style.ForeColor = Color.Black;
                }

                if (progressBar1.Value <= 99)
                    progressBar1.Value = progressBar1.Value + (i / 100);

                ListOfUserDataPoints.Add(new fPoint(Convert.ToDecimal(tempValueX), Convert.ToDecimal(tempValueY)));
            }
            //adds any data in the excel file to the user data storage
            createNewList();
            for (int j = 0; j < UserDataPoints.Count; j++)
            {
                if (Event.CompareTo("Track") == 0)
                {
                    list.Add(Convert.ToDouble(UserDataPoints[j].getX_Age()), new XDate(UserDataPoints[j].getY_Value_AsDate()));
                }
                else
                {
                    list.Add(Convert.ToDouble(UserDataPoints[j].getX_Age()), Convert.ToDouble(UserDataPoints[j].getY_Value_Asdouble()));
                }
            }
            //myPane.CurveList.RemoveAt(myPane.CurveList.Count());
            if (UserDataPoints.Count > 2)
            {
                addedUserData = true;
                LineItem myPoints = myPane.AddCurve("Points", list, Color.Black, SymbolType.Circle);
                myPoints.Line.IsVisible = false;
                myPoints.Symbol.Size = symbolSize;
                CreateTrendline ct = new CreateTrendline(UserDataPoints, Event);
                //myPane.CurveList.RemoveAt(myPane.CurveList.Count());
                LineItem myCurve = myPane.AddCurve("Curve", ct.getTrendList(), Color.Black, SymbolType.None);
                zg1.Invalidate();
            }
            DataGridViewCell cellwe = dataGridView1.Rows[0].Cells[0];
            dataGridView1.CurrentCell = cellwe;
            progressBar1.Value = 100;
            progressBar1.Hide();
            panelLoad.Hide();
            setUP = false;
        }
Example #4
0
        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();
        }