private void addExerciseButton_Click(object sender, EventArgs e) { var exercise = new Routines.GridExercise(); exercise.leftHandHold = leftHand_Combo.SelectedItem.ToString(); exercise.rightHandHold = rightHand_Combo.SelectedItem.ToString(); AddToExercisesTable(exercise); }
private void SaveRoutine() { routineNameErrorLabel.Visible = false; // Read from grid var newRoutine = new Routines.GridRoutine(); newRoutine.description = routineDescriptionText.Text; newRoutine.name = routineNameText.Text; newRoutine.difficulty = routineDifficultyTrackbar.Value; newRoutine.exercises = new List <Routines.GridExercise>(); foreach (var row in exercisesGrid.Rows) { var cells = (row as DataGridViewRow).Cells; if (cells[0].Value == null) { continue; } var newExercise = new Routines.GridExercise(); newExercise.leftHandHold = cells[0].Value.ToString(); newExercise.rightHandHold = cells[1].Value.ToString(); newExercise.duration = cells[2].Value.ToString(); newExercise.rest = cells[3].Value.ToString(); newExercise.description = cells[4].Value == null ? "" : cells[4].Value.ToString(); newRoutine.exercises.Add(newExercise); } if (trainingRowIndex != -1) { routinesData[trainingRowIndex] = newRoutine; } else { routinesData.Add(newRoutine); } Routines.SaveRoutines(routinesData); mainTitle.Text = "Hangboard Records"; recordsGroupBox.Visible = true; routinesGroupBox.Visible = false; trainingRowIndex = -1; var routines = new List <String>(); foreach (var routine in routinesData) { routines.Add(routine.name); } trainingCombo.DataSource = routines; }
private void AddToExercisesTable(Routines.GridExercise exercise) { exercisesGrid.Rows.Add(); var cells = exercisesGrid.Rows[exercisesGrid.Rows.Count - 1].Cells; cells[0].Value = exercise.leftHandHold; cells[1].Value = exercise.rightHandHold; cells[2].Value = exercise.duration; cells[3].Value = exercise.rest; cells[4].Value = exercise.description; exercisesGrid.ClearSelection(); createRoutineButton.Enabled = exercisesGrid.RowCount > 0 && routineNameText.Text.Length > 0; }