public SetRowControl(DatabaseOperations db, int setSeqNum, Workload workload, int activityId, DateTime date) { InitializeComponent(); this.db = db; this.exerciseNameLbl.Text = "Set " + (setSeqNum + 1).ToString(); foreach (string unit in workload.format) { AddUnitToControl(new WorkloadInputMetadata(unit, activityId, setSeqNum, date), workload.GetUnitValue(unit), this.workloadFlp); } }
/* Displays the workout associated with this control. It will be presented as rows of * sets, with the exercise name at the top. * Note that no existing children controls are removed before adding the new ones. */ private void DisplayWorkout() { this.dateLbl.Text = this.date.Date.ToString("dd.MM.yy"); //get all sets from the database, and add them as SetRowControls. List<SetActivityExercise> rows = this.db.GetSetsActivitiesExercises(this.date); int currentSeqNum = -1; SetRowControl prevRowControl = null; foreach (SetActivityExercise row in rows) { //for every time a new activity is encountered, the exercise name is added. if (currentSeqNum != row.activity.seqNum) { ExerciseNameTitle nameRow = new ExerciseNameTitle(); nameRow.Tag = row.activity; nameRow.SetExerciseName(row.exercise.exerciseName); nameRow.SetRefreshCallback(RefreshBtn_Click, nameRow); this.setListFlp.Controls.Add(nameRow); currentSeqNum = row.activity.seqNum; prevRowControl = null; } Workload workload = new Workload(row.exercise.exerciseFormat, row.set.reps, row.set.weight, row.set.secs); SetRowControl rowControl = new SetRowControl(this.db, row.set.setSeqNum, workload, row.activity.activityId, this.date); this.setListFlp.Controls.Add(rowControl); if (prevRowControl != null) { prevRowControl.SetNextSetRowControl(rowControl); } prevRowControl = rowControl; } this.commentsRichTextBox.Text = this.db.GetCommentsAtDate(this.date); }
public TotalWorkloadAtDate(DateTime date, int numSets, Workload workload) { this.date = date; this.numSets = numSets; this.workload = workload; }
/* Validates that the format of the workload contains all units in the * performance type. Assumes that the units in performanceType are * separated by a '/'. */ private bool ValidateFormat(Workload w, string performanceType) { string[] requiredUnits = performanceType.ToLower().Split('/'); foreach (string unit in requiredUnits) { if (!w.HasUnit(unit)) { return false; } } return true; }