//Add Row to DataGridView private void AddRow(VO2MaxStage Stage, VO2MaxSet Set) { tlpOverview.Size = new Size(tlpOverview.Size.Width, tlpOverview.Size.Height + 37); int index = tlpOverview.RowCount++; RowStyle style = new RowStyle(SizeType.Absolute, 35); tlpOverview.RowStyles.Add(style); Label dgvLabel0 = CreateLabel(); dgvLabel0.Text = Stage.StageName.ToString(); tlpOverview.Controls.Add(dgvLabel0, 0, index); Label dgvLabel1 = CreateLabel(); dgvLabel1.Text = Set.SetNumber.ToString() + " / " + Stage.VO2MaxSetCollection.Count.ToString(); tlpOverview.Controls.Add(dgvLabel1, 1, index); Label dgvLabel2 = CreateLabel(); dgvLabel2.Text = Set.Direction; tlpOverview.Controls.Add(dgvLabel2, 2, index); Label dgvLabel3 = CreateLabel(); string formatString = @"mm\:ss"; dgvLabel3.Text = Set.TimeRemaining.ToString(formatString); tlpOverview.Controls.Add(dgvLabel3, 3, index); Label dgvLabel4 = CreateLabel(); dgvLabel4.Text = Set.Contraction; tlpOverview.Controls.Add(dgvLabel4, 4, index); Label dgvLabel5 = CreateLabel(); dgvLabel5.Text = Set.Legs; tlpOverview.Controls.Add(dgvLabel5, 5, index); Label dgvLabel6 = CreateLabel(); dgvLabel6.Text = Set.Position; tlpOverview.Controls.Add(dgvLabel6, 6, index); }
//Read Program - This method must be refactored into DataSample private void ReadXMLProgram() { CurrentVO2MaxProgram = new VO2MaxProgram(); string RootDiretory = AppDomain.CurrentDomain.BaseDirectory; XmlTextReader reader = null; switch (DataSample.ProgramSelector) { case Enumerators.ProgramSelect.VO2MaxProgram1: reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram1.xml"); lblTitle.Text = "Program: VO2 Max Program 1"; lblDescription.Text = "Program Time: 30 min"; CurrentPowerIndex = GlobalVariables.VO2MaxProgram1PB; break; case Enumerators.ProgramSelect.VO2MaxProgram2: reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram2.xml"); lblTitle.Text = "Program: VO2 Max Program 2"; lblDescription.Text = "Program Time: 30 min"; CurrentPowerIndex = GlobalVariables.VO2MaxProgram2PB; break; case Enumerators.ProgramSelect.VO2MaxProgram3: reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram3.xml"); lblTitle.Text = "Program: VO2 Max Program 3"; lblDescription.Text = "Program Time: 26 min"; CurrentPowerIndex = GlobalVariables.VO2MaxProgram3PB; break; case Enumerators.ProgramSelect.VO2MaxProgram4: reader = new XmlTextReader(RootDiretory + "\\Programs\\VO2MaxProgram4.xml"); lblTitle.Text = "Program: VO2 Max Program 4"; lblDescription.Text = "Program Time: 20 min"; CurrentPowerIndex = GlobalVariables.VO2MaxProgram4PB; break; case Enumerators.ProgramSelect.CPM: reader = new XmlTextReader(RootDiretory + "\\Programs\\CPMProgram.xml"); lblTitle.Text = "Program: Continuous Passive Motion (CPM)"; lblDescription.Text = "Program Time: 20 min"; CurrentPowerIndex = GlobalVariables.CPMProgramPB; break; case Enumerators.ProgramSelect.Proprioception: reader = new XmlTextReader(RootDiretory + "\\Programs\\ProprioceptionProgram.xml"); lblTitle.Text = "Program: Proprioception"; lblDescription.Text = "Program Time: 10 min"; CurrentPowerIndex = GlobalVariables.PropriocenptionProgramPB; break; case Enumerators.ProgramSelect.RehabBilateral: reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml"); lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)"; lblDescription.Text = "Program Time: 15 min"; CurrentPowerIndex = GlobalVariables.RehabProgramPB; break; case Enumerators.ProgramSelect.RehabLeftLeg: reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabLeftLeg.xml"); lblTitle.Text = "Program: Rehabilitation - Left Leg (11 Stages)"; lblDescription.Text = "Program Time: 15 min"; CurrentPowerIndex = GlobalVariables.RehabProgramLeftPB; break; case Enumerators.ProgramSelect.RehabRightLeg: reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabRightLeg.xml"); lblTitle.Text = "Program: Rehabilitation - Right Leg (11 Stages)"; lblDescription.Text = "Program Time: 15 min"; CurrentPowerIndex = GlobalVariables.RehabProgramRightPB; break; //case Enumerators.ProgramSelect.CustomProgram: // reader = new XmlTextReader(RootDiretory + "\\Programs\\ProgramRehabBilateral.xml"); // lblTitle.Text = "Program: Rehabilitation - Bilateral (9 Stages)"; // lblDescription.Text = "Program Time: 15 min"; // CurrentPowerIndex = GlobalVariables.RehabProgramPB; // break; default: break; } while (reader.Read()) { if (reader.ReadToFollowing("StageIndex")) { VO2MaxStage newVO2MaxStage = new VO2MaxStage(); reader.Read(); newVO2MaxStage.StageIndex = reader.ReadContentAsInt(); reader.ReadToFollowing("StageNumber"); reader.Read(); newVO2MaxStage.StageNumber = reader.ReadContentAsInt(); reader.ReadToFollowing("StageName"); reader.Read(); newVO2MaxStage.StageName = reader.ReadContentAsString(); reader.ReadToFollowing("StageDuration"); reader.Read(); newVO2MaxStage.StageTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0); reader.ReadToFollowing("Sets"); reader.Read(); while (reader.Read()) { if (reader.Name == "Set") { VO2MaxSet newVO2MaxSet = new VO2MaxSet(); reader.ReadToFollowing("SetIndex"); reader.Read(); newVO2MaxSet.SetIndex = reader.ReadContentAsInt(); reader.ReadToFollowing("Number"); reader.Read(); newVO2MaxSet.SetNumber = reader.ReadContentAsInt(); reader.ReadToFollowing("Duration"); reader.Read(); double SetTime = reader.ReadContentAsDouble(); if (SetTime < 1) { SetTime = SetTime * 60; newVO2MaxSet.TimeRemaining = new TimeSpan(0, 0, Convert.ToInt32(SetTime)); } else { newVO2MaxSet.TimeRemaining = new TimeSpan(0, Convert.ToInt32(SetTime), 0); } reader.ReadToFollowing("Direction"); reader.Read(); newVO2MaxSet.Direction = reader.ReadContentAsString(); reader.ReadToFollowing("DirectionFlag"); reader.Read(); int DirectionVariable = reader.ReadContentAsInt(); if (DirectionVariable == 1) newVO2MaxSet.SelectedDirection = Enumerators.Direction.Forward; else if (DirectionVariable == -1) newVO2MaxSet.SelectedDirection = Enumerators.Direction.Backward; reader.ReadToFollowing("Contraction"); reader.Read(); newVO2MaxSet.Contraction = reader.ReadContentAsString(); reader.ReadToFollowing("Legs"); reader.Read(); newVO2MaxSet.Legs = reader.ReadContentAsString(); reader.ReadToFollowing("Position"); reader.Read(); newVO2MaxSet.Position = reader.ReadContentAsString(); reader.ReadToFollowing("RestDuration"); reader.Read(); newVO2MaxSet.RestTimeRemaining = new TimeSpan(0, reader.ReadContentAsInt(), 0); reader.ReadToFollowing("Instructions"); reader.Read(); newVO2MaxSet.Instructions = reader.ReadContentAsString(); newVO2MaxStage.VO2MaxSetCollection.Add(newVO2MaxSet); reader.Read(); //Read White Space reader.Read(); //Read Set reader.Read(); //Read White Space } else { break; } } CurrentVO2MaxProgram.VO2MaxStageCollection.Add(newVO2MaxStage); } } CurrentVO2MaxProgram.ProgramTime = new TimeSpan(0, 0, 0); foreach (VO2MaxStage stage in CurrentVO2MaxProgram.VO2MaxStageCollection) { CurrentVO2MaxProgram.ProgramTime = CurrentVO2MaxProgram.ProgramTime + stage.StageTimeRemaining; } }