Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        private void customRoutineBtn_Click(object sender, EventArgs e)
        {
            mainTitle.Text            = "Custom Routine";
            saveRoutineButton.Enabled = false;
            saveRoutineButton.Visible = false;
            recordsGroupBox.Visible   = false;
            routinesGroupBox.Visible  = true;
            CancelEditingMode();

            var emptyRoutine = new Routines.GridRoutine();

            emptyRoutine.exercises = new List <Routines.GridExercise>();
            emptyRoutine.exercises.Add(new Routines.GridExercise());
            LoadRoutine(emptyRoutine);
        }
Exemplo n.º 3
0
        private void LoadRoutine(Routines.GridRoutine routine)
        {
            routineDescriptionText.Text     = routine.description;
            routineNameText.Text            = routine.name;
            routineDifficultyTrackbar.Value = routine.difficulty;
            ClearExercisesTable();

            foreach (var exercise in routine.exercises)
            {
                AddToExercisesTable(exercise);
            }

            // Load highlights from first row
            if (exercisesGrid.RowCount > 0)
            {
                ExercisesGridHandComboChanged(0, 0, false);
                ExercisesGridHandComboChanged(0, 1, true);
            }
        }