Esempio 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;
        }
Esempio n. 2
0
        private void InitialiseDataSources()
        {
            foreach (var hold in Records.leftHoldNames)
            {
                leftHand_Combo.Items.Add(hold);
            }

            foreach (var hold in Records.rightHoldNames)
            {
                rightHand_Combo.Items.Add(hold);
            }

            (recordsGrid.Columns["gridLeftHandHold"] as DataGridViewComboBoxColumn).DataSource        = Records.leftHoldNames;
            (recordsGrid.Columns["gridRightHandHold"] as DataGridViewComboBoxColumn).DataSource       = Records.rightHoldNames;
            (exercisesGrid.Columns["routinesLeftHandHold"] as DataGridViewComboBoxColumn).DataSource  = Records.leftHoldNames;
            (exercisesGrid.Columns["routinesRightHandHold"] as DataGridViewComboBoxColumn).DataSource = Records.rightHoldNames;

            recordsData  = Records.LoadRecords();
            filteredData = recordsData;
            RefreshRecordsTable();

            routinesData = Routines.LoadRoutines();

            var routines = new List <String>();

            foreach (var routine in routinesData)
            {
                routines.Add(routine.name);
            }

            trainingCombo.DataSource = routines;

            if (routines.Count == 0)
            {
                startTrainingBtn.Enabled = false;
            }
        }