Ejemplo n.º 1
0
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            MacroFileInfo goals = new MacroFileInfo(
                int.Parse(KCalInput.Text),
                int.Parse(ProteinInput.Text),
                int.Parse(CarbsInput.Text),
                int.Parse(FatsInput.Text)
                );

            float  start_weight   = float.Parse(String.Format("{0}.{1}", StartWeightWhole.Text, StartWeightDecimal.Text));
            float  target_weight  = float.Parse(String.Format("{0}.{1}", TargetWeightWhole.Text, TargetWeightDecimal.Text));
            float  current_weight = float.Parse(String.Format("{0}.{1}", CurrentWeightWhole.Text, CurrentWeightDecimal.Text));
            string weight_mode;

            if (InMaintenance.IsChecked.Value)
            {
                weight_mode = "MAINTENANCE";
            }
            else if (target_weight > start_weight)
            {
                weight_mode = "GAIN";
            }
            else
            {
                weight_mode = "LOSE";
            }

            WriteUserInfo(current_user.dir_path, false, goals, start_weight, current_weight, target_weight, weight_mode);
            current_user.UpdateUser(goals, start_weight, current_weight, target_weight, weight_mode);
        }
Ejemplo n.º 2
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            MacroFileInfo goals = new MacroFileInfo(
                int.Parse(KCalInput.Text),
                int.Parse(ProteinInput.Text),
                int.Parse(CarbsInput.Text),
                int.Parse(FatsInput.Text)
                );

            float  start_weight  = float.Parse(String.Format("{0}.{1}", StartWeightWhole.Text, StartWeightDecimal.Text));
            float  target_weight = float.Parse(String.Format("{0}.{1}", TargetWeightWhole.Text, TargetWeightDecimal.Text));
            string weight_mode;

            if (InMaintenance.IsChecked.Value)
            {
                weight_mode = "MAINTENANCE";
            }
            else if (target_weight > start_weight)
            {
                weight_mode = "GAIN";
            }
            else
            {
                weight_mode = "LOSE";
            }


            var user_dir = Directory.CreateDirectory(path + @"\" + NameInput.Text);

            Directory.CreateDirectory(user_dir.FullName + @"\days\");
            WriteUserInfo(user_dir.FullName, true, goals, start_weight, start_weight, target_weight, weight_mode);

            main_frame.Content = new UserMode(main_frame, new User(NameInput.Text, user_dir.FullName));
        }
Ejemplo n.º 3
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            MacroFileInfo old_macros;

            string[] _;
            (old_macros, _) = CommonLib.OpenDayFile(day_file_path);
            MacroFileInfo new_macros = new MacroFileInfo(
                old_macros.kcals + Int32.Parse(KCalInput.Text),
                old_macros.protein + Int32.Parse(ProteinInput.Text),
                old_macros.carbs + Int32.Parse(CarbsInput.Text),
                old_macros.fats + Int32.Parse(FatsInput.Text)
                );

            string[] completion_levels = new string[4] {
                GetCompletionLevel(new_macros.kcals, current_user.KCalGoal),
                GetCompletionLevel(new_macros.protein, current_user.ProteinGoal),
                GetCompletionLevel(new_macros.carbs, current_user.CarbsGoal),
                GetCompletionLevel(new_macros.fats, current_user.FatsGoal)
            };

            CommonLib.UpdateDayFile(day_file_path, new_macros, completion_levels);

            content_frame.Content = new UserHomePage(content_frame, current_user);
        }