private void LoadChart()
        {
            StringBuilder stringBuilder    = null;
            string        messageText      = "";
            Exception     exceptionDetails = null;
            string        path             = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.DefaultPath;
            string        fileName         = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.FileName;

            try
            {
                var chart = chart1.ChartAreas[0];
                chart.AxisX.IntervalType                 = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
                chart.AxisX.LabelStyle.Format            = "HH:mm";
                chart.AxisX.LabelStyle.IsEndLabelVisible = true;

                chart1.Series.Clear();

                chart1.Series.Add("BloodGlucose");
                chart1.Series["BloodGlucose"].ChartType  = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["BloodGlucose"].Color      = Color.Green;
                chart1.Series["BloodGlucose"].XValueType = ChartValueType.Time;

                if ((string.IsNullOrEmpty(path) == false) && (string.IsNullOrEmpty(fileName) == false))
                {
                    readFileLogic = new ReadFileLogic();
                    if (readFileLogic != null)
                    {
                        readFileLogic.PathName = path;
                        readFileLogic.FileName = fileName;
                        readFileLogic.GetFormattedFileName();

                        if (File.Exists(readFileLogic.FilePathName) == true)
                        {
                            readFileLogic.ReadFile();
                            readFileLogic.SetupListsByDay();


                            if (rbLast30Days.Checked == true)
                            {
                                if (readFileLogic.listBloodGlucoseLast30Days != null)
                                {
                                    foreach (BloodGlucose bloodGlucose in readFileLogic.listBloodGlucoseLast30Days)
                                    {
                                        chart1.Series["BloodGlucose"].Points.AddXY(bloodGlucose.TimeRead.ToOADate(), bloodGlucose.MGDL);
                                    }
                                }
                            }
                            if (rbLast7Days.Checked == true)
                            {
                                if (readFileLogic.listBloodGlucoseLast30Days != null)
                                {
                                    foreach (BloodGlucose bloodGlucose in readFileLogic.listBloodGlucoseLast7Days)
                                    {
                                        chart1.Series["BloodGlucose"].Points.AddXY(bloodGlucose.TimeRead.ToOADate(), bloodGlucose.MGDL);
                                    }
                                }
                            }

                            if (rbToday.Checked == true)
                            {
                                if (readFileLogic.listBloodGlucoseToday != null)
                                {
                                    foreach (BloodGlucose bloodGlucose in readFileLogic.listBloodGlucoseToday)
                                    {
                                        chart1.Series["BloodGlucose"].Points.AddXY(bloodGlucose.TimeRead.ToOADate(), bloodGlucose.MGDL);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                stringBuilder    = new StringBuilder();
                exceptionDetails = exception;

                while (exceptionDetails != null)
                {
                    messageText = "\r\nMessage: " + exceptionDetails.Message + "\r\nSource: " + exceptionDetails.Source + "\r\nStack Trace: " + exceptionDetails.StackTrace + "\r\n----------\r\n";

                    stringBuilder.Append(messageText);

                    exceptionDetails = exceptionDetails.InnerException;
                }

                messageText = stringBuilder.ToString();

                System.Diagnostics.Debug.WriteLine(messageText);
                MessageBox.Show(this, messageText, "Error");
            }
        }
コード例 #2
0
        private void LoadPII()
        {
            StringBuilder stringBuilder    = null;
            string        messageText      = "";
            Exception     exceptionDetails = null;
            string        path             = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.DefaultPath;
            string        fileName         = MS539_final_project_roderick_devalcourt.Properties.Settings.Default.FileName;

            try
            {
                readFileLogic = new ReadFileLogic();
                if (readFileLogic != null)
                {
                    readFileLogic.PathName = path;
                    readFileLogic.FileName = fileName;
                    readFileLogic.GetFormattedFileName();

                    if (File.Exists(readFileLogic.FilePathName) == true)
                    {
                        readFileLogic.ReadFile();
                        readFileLogic.SetupListsByDay();

                        firstNameTextbox.Text = readFileLogic.personallyIdentifiableInformation.FirstName;
                        lastNameTextbox.Text  = readFileLogic.personallyIdentifiableInformation.LastName;
                        switch (readFileLogic.personallyIdentifiableInformation.Gender)
                        {
                        case 0:
                            maleRadioButton.Checked   = true;
                            femaleRadioButton.Checked = false;
                            break;

                        case 1:
                            maleRadioButton.Checked   = false;
                            femaleRadioButton.Checked = true;
                            break;
                        }
                        datePicker1.Value = readFileLogic.personallyIdentifiableInformation.DateOfBirth;
                        personallyIdentifiableInformation = new PersonallyIdentifiableInformation(readFileLogic.personallyIdentifiableInformation);
                    }
                }
            }
            catch (ArgumentOutOfRangeException oops)
            {
                // do nothing
            }
            catch (Exception exception)
            {
                stringBuilder    = new StringBuilder();
                exceptionDetails = exception;

                while (exceptionDetails != null)
                {
                    messageText = "\r\nMessage: " + exceptionDetails.Message + "\r\nSource: " + exceptionDetails.Source + "\r\nStack Trace: " + exceptionDetails.StackTrace + "\r\n----------\r\n";

                    stringBuilder.Append(messageText);

                    exceptionDetails = exceptionDetails.InnerException;
                }

                messageText = stringBuilder.ToString();

                System.Diagnostics.Debug.WriteLine(messageText);
                MessageBox.Show(this, messageText, "Error");
            }
        }