Пример #1
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);
        }