Exemple #1
0
        public MainForm()
        {
            InitializeComponent();
            StartUpProjectForm startUpProjectForm = new StartUpProjectForm(this);

            startUpProjectForm.Show();
            m_exerciseRegister    = new ExerciseRegister();
            m_trainingDayRegister = new TrainingsdayRegister();
            m_trainingsStatistic  = new TrainingStatistics(this);
        }
Exemple #2
0
        private void parseLoadString(string loadString)
        {
            try
            {
                if (m_athlete.BodyPartRegister != null)
                {
                    m_athlete.BodyPartRegister = null;
                }
                if (m_athlete.WeightRegister != null)
                {
                    m_athlete.WeightRegister = null;
                }
                if (ExerciseRegister != null)
                {
                    ExerciseRegister = null;
                }
                if (TrainingDayRegister != null)
                {
                    TrainingDayRegister = null;
                }
                if (m_athlete != null)
                {
                    m_athlete = null;
                }
            }
            catch
            {
            }

            List <TrainingsDay> trainingsDaylist = new List <TrainingsDay>();

            string[] athleteString           = getInfoFromXMLFile(loadString, "Athlete");
            string[] bodyPartsRegisterString = getInfoFromXMLFile(loadString, "BodypartsRegister");
            string[] bodyFatRegisterString   = getInfoFromXMLFile(loadString, "BodyFatRegister");
            string[] exerciseRegisterString  = getInfoFromXMLFile(loadString, "ExerciseRegister");
            string[] trainingsDayListString  = getInfoFromXMLFile(loadString, "TrainingsdayList");

            string[] bodyPartsString           = getInfoFromXMLFile(bodyPartsRegisterString[0], "Bodypart");
            string[] bodyFatString             = getInfoFromXMLFile(bodyFatRegisterString[0], "Bodypart");
            string[] registeredExercisesString = getInfoFromXMLFile(exerciseRegisterString[0], "Exercise");
            string[] trainingsDayString        = getInfoFromXMLFile(trainingsDayListString[0], "Trainingsday");

            string[] exerciseOfTheDay;

            #region Restore the Athlete

            Gender gender;
            if (getInfoFromXMLFile(athleteString[0], "Gender")[0] == Gender.Male.ToString())
            {
                gender = Gender.Male;
            }
            else
            {
                gender = Gender.Female;
            }

            string weightString = getInfoFromXMLFile(athleteString[0], "WeightRegister")[0];

            this.m_athlete = new Athlete(
                getInfoFromXMLFile(athleteString[0], "Name")[0],
                Convert.ToInt32(getInfoFromXMLFile(athleteString[0], "Height")[0]),
                Convert.ToInt32(getInfoFromXMLFile(athleteString[0], "Age")[0]),
                this,
                gender);

            //Damit bleibt measurementString lokal
            if (weightString != " ")
            {
                string[] measurementString = getInfoFromXMLFile(weightString, "Measurement");

                for (int it = 0; it < measurementString.Length; it++)
                {
                    m_athlete.WeightRegister.addMeasurement(
                        getInfoFromXMLFile(measurementString[it], "Date")[0],
                        Math.Round(Convert.ToDouble(getInfoFromXMLFile(measurementString[it], "Weight")[0]), 1)
                        );
                }
            }

            #endregion Restore the Athlete

            #region Restore the Bodyparts

            for (int outer_it = 0; outer_it < bodyPartsString.Length; outer_it++)
            {
                string[] measurementString = getInfoFromXMLFile(bodyPartsString[outer_it], "Measurement");

                m_athlete.addBodyPart(
                    getInfoFromXMLFile(bodyPartsString[outer_it], "Name")[0],
                    getInfoFromXMLFile(bodyPartsString[outer_it], "Description")[0]);

                for (int inner_it = 0; inner_it < measurementString.Length; inner_it++)
                {
                    m_athlete.BodyPartRegister[outer_it].Date.Add(getInfoFromXMLFile(measurementString[inner_it], "Date")[0]);
                    m_athlete.BodyPartRegister[outer_it].Diameter.Add(Math.Round(Convert.ToDouble(getInfoFromXMLFile(measurementString[inner_it], "Diameter")[0]), 2));
                }
            }

            #endregion Restore the Bodyparts

            #region Restore the Body Fat Measurements

            for (int outer_it = 0; outer_it < bodyFatString.Length; outer_it++)
            {
                string[] measurementString = getInfoFromXMLFile(bodyFatString[outer_it], "Measurement");

                for (int inner_it = 0; inner_it < measurementString.Length; inner_it++)
                {
                    m_athlete.BodyFatRegister[outer_it].Date.Add(getInfoFromXMLFile(measurementString[inner_it], "Date")[0]);
                    m_athlete.BodyFatRegister[outer_it].Diameter.Add(Math.Round(Convert.ToDouble(getInfoFromXMLFile(measurementString[inner_it], "Diameter")[0]), 2));
                }
            }

            #endregion Restore the Body Fat Measurements

            #region Restore the Exercises

            for (int it = 0; it < registeredExercisesString.Length; it++)
            {
                m_exerciseRegister.RegisteredExercises.Add(new Exercise(
                                                               getInfoFromXMLFile(registeredExercisesString[it], "Name")[0],
                                                               (EtypeOfExercise)Enum.Parse(typeof(EtypeOfExercise), getInfoFromXMLFile(registeredExercisesString[it], "Type")[0]),
                                                               getInfoFromXMLFile(registeredExercisesString[it], "Description")[0]
                                                               ));
            }

            #endregion Restore the Exercises

            #region Restore the Trainingsdays

            for (int outer_it = 0; outer_it < trainingsDayString.Length; outer_it++)
            {
                m_trainingDayRegister.RegisteredTrainingsDays.Add(new TrainingsDay(this, getInfoFromXMLFile(trainingsDayString[outer_it], "Date")[0]));
                exerciseOfTheDay = getInfoFromXMLFile(trainingsDayString[outer_it], "Exercise");
                for (int inner_it = 0; inner_it < exerciseOfTheDay.Length; inner_it++)
                {
                    string[] type = getInfoFromXMLFile(exerciseOfTheDay[inner_it], "TypeOfExercise");
                    if (type[0] == "MachineExercise")
                    {
                        string[]      exerciseSetString = getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Set");
                        ExerciseSet[] exerciseSet       = new ExerciseSet[exerciseSetString.Length];
                        for (int it = 0; it < exerciseSetString.Length; it++)
                        {
                            exerciseSet[it] = new ExerciseSet(
                                Convert.ToDouble(getInfoFromXMLFile(exerciseSetString[it], "Weight")[0]),
                                Convert.ToInt32(getInfoFromXMLFile(exerciseSetString[it], "Repetitions")[0])
                                );
                        }

                        TrainingDayRegister.RegisteredTrainingsDays[outer_it].addMachineExcercise(
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "ExerciseName")[0],
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Comment")[0],
                            exerciseSet
                            );
                    }
                    else if (type[0] == "BodyWeightExercise")
                    {
                        string[] repetitionsString = getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Repetition");
                        int[]    repetitions       = new int[repetitionsString.Length];
                        for (int it = 0; it < repetitionsString.Length; it++)
                        {
                            repetitions[it] = Convert.ToInt32(repetitionsString[it]);
                        }

                        TrainingDayRegister.RegisteredTrainingsDays[outer_it].addBodyWeightExcercise(
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "ExerciseName")[0],
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Comment")[0],
                            repetitions
                            );
                    }
                    else if (type[0] == "CardioExercise")
                    {
                        Duration duration = new Duration(
                            Convert.ToInt32(getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Hour")[0]),
                            Convert.ToInt32(getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Minute")[0]),
                            Convert.ToInt32(getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Seconds")[0])
                            );

                        TrainingDayRegister.RegisteredTrainingsDays[outer_it].addCardioExcercise(
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "ExerciseName")[0],
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Comment")[0],
                            Convert.ToInt32(getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Distance")[0]),
                            duration
                            );
                    }
                    else if (type[0] == "SpecialExercise")
                    {
                        TrainingDayRegister.RegisteredTrainingsDays[outer_it].addSpecialExcercise(
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "ExerciseName")[0],
                            getInfoFromXMLFile(exerciseOfTheDay[inner_it], "Comment")[0]
                            );
                    }
                }
            }

            #endregion Restore the Trainingsdays
        }