private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedIndex = comboBox1.SelectedIndex + 1;

            dataGridView2.Rows.Clear();

            var a = _hrData["data" + selectedIndex] as Dictionary <string, List <string> >;
            var b = a.ToDictionary(k => k.Key, k => k.Value as object);


            var data = new TableFiller().FillDataInSumaryTable(b, "19:12:15", null);

            dataGridView2.Rows.Add(data);
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fileOneText) || string.IsNullOrEmpty(fileTwoText))
            {
                MessageBox.Show("Both file are required");
                return;
            }

            var firstTableData  = new TableFiller().FillTable(fileOneText, dataGridView1);
            var secondTableData = new TableFiller().FillTable(fileTwoText, dataGridView2);


            //show data using data grid view
            dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(firstTableData, firstTableData["endTime"] as string, firstTableData["params"] as Dictionary <string, string>));
            dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(secondTableData, secondTableData["endTime"] as string, secondTableData["params"] as Dictionary <string, string>));
            //dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(firstTableData, firstTableData["params"] as Dictionary<string, string>, firstTableData["endTime"] as string));
            //dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(secondTableData, secondTableData["params"] as Dictionary<string, string>, secondTableData["endTime"] as string));
        }
コード例 #3
0
        //private string[] SplitString(string text)
        //{
        //    var splitString = new string[] { "[Params]", "[Note]", "[IntTimes]", "[IntNotes]",
        //        "[ExtraData]", "[LapNames]", "[Summary-123]",
        //        "[Summary-TH]", "[HRZones]", "[SwapTimes]", "[Trip]", "[HRData]"};

        //    var splittedText = text.Split(splitString, StringSplitOptions.RemoveEmptyEntries);

        //    return splittedText;
        //}

        //private string[] SplitStringByEnter(string text)
        //{
        //    return text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
        //}

        //private string[] SplitStringBySpace(string text)
        //{
        //    var formattedText = string.Join(" ", text.Split().Where(x => x != ""));
        //    return formattedText.Split(' ');
        //}


        /// <summary>
        /// making open tool working
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string text = File.ReadAllText(openFileDialog1.FileName);
                Dictionary <string, object> hrData = new TableFiller().FillTable(text, dataGridView1);
                _hrData = hrData.ToDictionary(k => k.Key, k => k.Value as List <string>);
                var param = hrData["params"] as Dictionary <string, string>;
                //header file
                lblStartTime.Text = lblStartTime.Text + "= " + param["StartTime"];
                lblInterval.Text  = lblInterval.Text + "= " + Regex.Replace(param["Interval"], @"\t|\n|\r", "") + " Sec ";
                lblMonitor.Text   = lblMonitor.Text + "= " + param["Monitor"];
                lblSMode.Text     = lblSMode.Text + "= " + param["SMode"];
                lblDate.Text      = lblDate.Text + "= " + param["Date"];
                lblLength.Text    = lblLength.Text + "= " + param["Length"];
                lblWeight.Text    = lblWeight.Text + "= " + Regex.Replace(param["Weight"], @"\t|\n|\r", "") + " KG";

                //Fetching Smode Data from file


                List <string> cadence   = new List <string>();
                List <string> altitude  = new List <string>();
                List <string> heartRate = new List <string>();
                List <string> watt      = new List <string>();
                List <string> speed     = new List <string>();

                var metricsCalculation = new AdvancedCalculationOfMatrix();

                //advance mettrics calculation
                double np = metricsCalculation.CalculateNormalizedPower(hrData);
                label4.Text = "Normalized power = " + Summary.RoundUp(np, 2);

                double ftp = metricsCalculation.CalculateFunctionalThresholdPower(hrData);
                label5.Text = "Training Stress Score = " + Summary.RoundUp(ftp, 2);

                double ifa = metricsCalculation.CalculateIntensityFactor(hrData);
                label6.Text = "Intensity Factor = " + Summary.RoundUp(ifa, 2);

                double pb = metricsCalculation.CalculatePowerBalance(hrData);
                label3.Text = "Power balance = " + Summary.RoundUp(pb, 2);

                var sMode = param["SMode"];
                for (int i = 0; i < sMode.Length; i++)
                {
                    smode.Add((int)Char.GetNumericValue(param["SMode"][i]));
                }
                if (smode[0] == 0)
                {
                    dataGridView1.Columns[0].Visible = false;
                }
                else if (smode[1] == 0)
                {
                    dataGridView1.Columns[1].Visible = false;
                }
                else if (smode[2] == 0)
                {
                    dataGridView1.Columns[2].Visible = false;
                }
                else if (smode[3] == 0)
                {
                    dataGridView1.Columns[3].Visible = false;
                }
                else if (smode[4] == 0)
                {
                    dataGridView1.Columns[4].Visible = false;
                }
                dataGridView2.Rows.Clear();
                //dataGridView2.Rows.Add(new TableFiller().FillDataInSumaryTable(hrData, hrData["params"] as Dictionary<string, string>, hrData["endTime"] as string));
                dataGridView2.Rows.Add(new TableFiller().FillDataInSumaryTable(hrData, hrData["endTime"] as string, hrData["params"] as Dictionary <string, string>));
            }

            //DialogResult result = openFileDialog1.ShowDialog();
            //if (result == DialogResult.OK)
            //{
            //    Cursor.Current = Cursors.WaitCursor;
            //    _param = new Dictionary<string, string>();
            //    _hrData = new Dictionary<string, List<string>>();
            //    string text = File.ReadAllText(openFileDialog1.FileName);
            //    var splittedString = SplitString(text);

            //    var splittedParamsData = SplitStringByEnter(splittedString[0]);

            //    foreach (var data in splittedParamsData)
            //    {
            //        if (data != "\r")
            //        {
            //            string[] parts = data.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
            //            _param.Add(parts[0], parts[1]);
            //        }
            //    }

            //    //To extract file from source and shhowing them
            //    //lblStartTime.AutoSize = false;
            //    //lblStartTime.Size = new Size(2000, 50);

            //    lblStartTime.Text = "Start Time" + "= " + Regex.Replace(_param["StartTime"], @"\t|\n|\r", "") + " ";
            //    lblInterval.Text = "Interval" + "= " + Regex.Replace(_param["Interval"], @"\t|\n|\r", "") + " Sec ";
            //    /*lblStartTimeUnit.Show();*/
            //    lblMonitor.Text = "Monitor" + "= " + Regex.Replace(_param["Monitor"], @"\t|\n|\r", "") + " " ;
            //    lblSMode.Text = "SMode" + "= " + _param["SMode"];
            //    lblDate.Text = "Date" + "= " + ConvertToDate(_param["Date"]);
            //    lblLength.Text = "Length" + "= " + _param["Length"];
            //    lblWeight.Text = "Weight" + "= " + Regex.Replace(_param["Weight"], @"\t|\n|\r", "") + " KG";

            //    //Fetching Smode Data from file
            //    var sMode = _param["SMode"];
            //    for (int i = 0; i < sMode.Length; i++)
            //    {
            //        smode.Add((int)Char.GetNumericValue(_param["SMode"][i]));
            //    }

            //    List<string> cadence = new List<string>();
            //    List<string> altitude = new List<string>();
            //    List<string> heartRate = new List<string>();
            //    List<string> watt = new List<string>();
            //    List<string> speed = new List<string>();

            //    //adding data for datagrid
            //    var splittedHrData = SplitStringByEnter(splittedString[11]);
            //    DateTime dateTime = DateTime.Parse(_param["StartTime"]);

            //    int temp = 0;
            //    foreach (var data in splittedHrData)
            //    {
            //        temp++;
            //        var value = SplitStringBySpace(data);

            //        if (value.Length >= 5)
            //        {
            //            cadence.Add(value[0]);
            //            altitude.Add(value[1]);
            //            heartRate.Add(value[2]);
            //            watt.Add(value[3]);
            //            speed.Add(value[4]);

            //            if (temp > 2) dateTime = dateTime.AddSeconds(Convert.ToInt32(_param["Interval"]));
            //            endTime = dateTime.TimeOfDay.ToString();
            //            string[] hrData = new string[] { value[0], value[1], value[2], value[3], value[4], dateTime.TimeOfDay.ToString() };
            //            dataGridView1.Rows.Add(hrData);
            //        }
            //    }

            //    _hrData.Add("cadence", cadence);
            //    _hrData.Add("altitude", altitude);
            //    _hrData.Add("heartRate", heartRate);
            //    _hrData.Add("watt", watt);
            //    _hrData.Add("speed", speed);

            //    //
            //    if (smode[0] == 0)
            //    {
            //        dataGridView1.Columns[0].Visible = false;
            //    }
            //    else if (smode[1] == 0)
            //    {
            //        dataGridView1.Columns[1].Visible = false;
            //    }
            //    else if (smode[2] == 0)
            //    {
            //        dataGridView1.Columns[2].Visible = false;
            //    }
            //    else if (smode[3] == 0)
            //    {
            //        dataGridView1.Columns[3].Visible = false;
            //    }
            //    else if (smode[4] == 0)
            //    {
            //        dataGridView1.Columns[4].Visible = false;
            //    }

            //    double startDate = TimeSpan.Parse(_param["StartTime"]).TotalSeconds;
            //    double endDate = TimeSpan.Parse(endTime).TotalSeconds;
            //    double totalTime = endDate - startDate;

            //    //string totalDistanceCovered = Summary.FindSum(_hrData["cadence"]).ToString();

            //    string averageSpeed = Summary.FindAverage(_hrData["speed"]).ToString();
            //    string totalDistanceCovered = ((Convert.ToDouble(averageSpeed) * totalTime) / 360).ToString();
            //    string maxSpeed = Summary.FindMax(_hrData["speed"]).ToString();

            //    string averageHeartRate = Summary.FindAverage(_hrData["heartRate"]).ToString();
            //    string maximumHeartRate = Summary.FindMax(_hrData["heartRate"]).ToString();
            //    string minHeartRate = Summary.FindMin(_hrData["heartRate"]).ToString();

            //    string averagePower = Summary.FindAverage(_hrData["watt"]).ToString();
            //    string maxPower = Summary.FindMax(_hrData["watt"]).ToString();

            //    string averageAltitude = Summary.FindAverage(_hrData["altitude"]).ToString();
            //    string maximumAltitude = Summary.FindAverage(_hrData["altitude"]).ToString();

            //    string[] summarydata = new string[] { totalDistanceCovered, averageSpeed, maxSpeed, averageHeartRate, maximumHeartRate, minHeartRate, averagePower, maxPower, averageAltitude, maximumAltitude };
            //    dataGridView2.Rows.Clear();
            //    dataGridView2.Rows.Add(summarydata);
            //    // radioButton2.Checked = true;
            //    checkBox2.Checked = true;
            //}
        }