public static Workout FromTemplate(WorkoutTemplate workoutTemplate) { Workout workout = new Workout() { Title = workoutTemplate.Title, WorkoutTemplatePath = workoutTemplate.WorkoutTemplatePath, MinLength = workoutTemplate.MinLength, MaxLength = workoutTemplate.MaxLength, Template = workoutTemplate }; foreach (WorkoutTemplatePart part in workoutTemplate.WorkoutTemplateParts) { workout.WorkoutParts.Add(new WorkoutPart() { Title = part.Title, Template = part, MinLength = part.MinLength, MaxLength = part.MaxLength }); } return workout; }
private void newButton_Click(object sender, EventArgs e) { using (NewWorkoutForm form = new NewWorkoutForm()) { if (form.ShowDialog() == DialogResult.OK) { template = form.Template; workout = Workout.Workout.FromTemplate(template); RefreshWorkout(); } } }