Exemple #1
0
        private void edit_exercise_click(object sender, RoutedEventArgs e)
        {
            Button     edit_button = (Button)sender;
            GearButton parent      = (GearButton)edit_button.Parent;

            EditExercise window = new EditExercise((exercise)edit_button.Tag, (List <exercise>)parent.Tag);

            window.ShowDialog();



            UpdateProgramView();
        }
Exemple #2
0
        public void UpdateProgramView()
        {
            block_scroll_view.Children.Clear();
            foreach (TrainingBlock block in main_program.GetTrainingBlocks())
            {
                TextBlock block_type = new TextBlock();
                block_type.FontSize = 20;
                block_type.Text     = block.GetBlockType();
                StackPanel text_and_block = new StackPanel();
                text_and_block.Children.Add(block_type);
                block_scroll_view.Children.Add(text_and_block);

                int week_count = 1;
                foreach (TrainingWeek week in block.GetTrainingWeeks())
                {
                    TextBlock week_number = new TextBlock();
                    week_number.Text     = "Week " + week_count;
                    week_number.FontSize = 16;
                    WrapPanel days_panel = new WrapPanel();
                    text_and_block.Children.Add(week_number);
                    text_and_block.Children.Add(days_panel);

                    foreach (TrainingDay day in week.GetTrainingDays())
                    {
                        StackPanel exercises_panel = new StackPanel(); exercises_panel.Margin = new Thickness(10.0);
                        TextBlock  WeekDay         = new TextBlock();
                        WeekDay.Text     = day.GetWeekDay();
                        WeekDay.FontSize = 14;
                        exercises_panel.Children.Add(WeekDay);
                        days_panel.Children.Add(exercises_panel);

                        foreach (exercise exercise in day.GetExercises())
                        {
                            WrapPanel  exercise_panel = new WrapPanel(); exercise_panel.Width = 300;
                            GearButton edit_button    = new GearButton();
                            edit_button.Tag        = day.GetExercises();
                            edit_button.btn.Tag    = exercise;
                            edit_button.btn.Width  = 15;
                            edit_button.btn.Height = 15;
                            edit_button.btn.Click += edit_exercise_click;

                            TextBlock exercise_text = new TextBlock();
                            exercise_text.Text = exercise.exerciseString();

                            exercise_panel.Children.Add(edit_button);
                            exercise_panel.Children.Add(exercise_text);

                            exercises_panel.Children.Add(exercise_panel);
                        }
                        Button add_exercise = new Button();
                        add_exercise.Tag                 = day.GetExercises();
                        add_exercise.Width               = 30;
                        add_exercise.Height              = 20;
                        add_exercise.Content             = "add";
                        add_exercise.HorizontalAlignment = HorizontalAlignment.Left;
                        add_exercise.Click              += add_exercise_click;
                        exercises_panel.Children.Add(add_exercise);
                    }
                    week_count++;
                }
                Button add_week_button = new Button();
                text_and_block.Children.Add(add_week_button);
                add_week_button.Tag = block; add_week_button.Content = "Add Week"; add_week_button.Width = 60; add_week_button.Height = 20; add_week_button.HorizontalAlignment = HorizontalAlignment.Left; add_week_button.Click += AddWeek;
            }
        }