Пример #1
0
        void editTrainingPlan(BodyArchitect.Service.Model.TrainingPlans.TrainingPlan plan)
        {
            ControlHelper.RunWithExceptionHandling(delegate
            {
                WorkoutPlanDTO planDto       = (WorkoutPlanDTO)plan.Tag;
                TrainingPlanEditorWindow wnd = new TrainingPlanEditorWindow();
                wnd.Fill(plan);
                if (wnd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    ParentWindow.RunAsynchronousOperation(delegate
                    {
                        TrainingPlanChecker checker = new TrainingPlanChecker();
                        checker.Process(wnd.TrainingPlan);
                        planDto.SetTrainingPlan(wnd.TrainingPlan);

                        XmlSerializationTrainingPlanFormatter formatter = new XmlSerializationTrainingPlanFormatter();
                        planDto.PlanContent = formatter.ToXml(wnd.TrainingPlan).ToString();

                        planDto.Profile = UserContext.CurrentProfile;
                        ServiceManager.SaveTrainingPlan(planDto);
                        ObjectsReposidory.ClearWorkoutPlansCache();
                        ParentWindow.SynchronizationContext.Send(delegate
                        {
                            Fill();
                        }, null);
                    });
                }
            });
        }
Пример #2
0
 private void viewTrainingPlan()
 {
     ControlHelper.RunWithExceptionHandling(delegate
     {
         TrainingPlan.Open();
     });
 }
Пример #3
0
 private void tbRemoveFromFavorites_Click(object sender, EventArgs e)
 {
     ControlHelper.RunWithExceptionHandling(delegate
     {
         if (TrainingPlan.RemoveFromFavorites())
         {
             Fill();
         }
     });
 }
 private void btnShowTrainingPlan_Click(object sender, EventArgs e)
 {
     if (SelectedPlan == null)
     {
         return;
     }
     ControlHelper.RunWithExceptionHandling(delegate
     {
         SelectedPlan.Open();
         setTrainingPlans(fillWorkoutPlans(false));
     });
 }
Пример #5
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (TrainingPlan == null)
     {
         return;
     }
     ControlHelper.RunWithExceptionHandling(delegate
     {
         var plan = TrainingPlan.ToTrainingPlan();
         plan.Tag = TrainingPlan;
         editTrainingPlan(plan);
     });
 }
Пример #6
0
        //static PleaseWaitWindow _pleaseWaitDlg;

        /// <summary>
        /// Runs the specified long operation (in delegate) in separate thread and display please wait modal window.
        /// </summary>
        /// <param name="method">The method to run in background.</param>
        /// <param name="canBeCanceled">if set to <c>true</c> operation can be canceled (PleaseWait window display Cancel button).</param>
        public static bool Run(MyRunMethod method, bool canBeCanceled = false, int?progressMax = null, bool useDefaultExceptionHandling = true)
        {
            bool res = true;

            if (useDefaultExceptionHandling)
            {
                ControlHelper.RunWithExceptionHandling(delegate
                {
                    res = pleaseWaitImplementation(canBeCanceled, progressMax, method);
                });
            }
            else
            {
                res = pleaseWaitImplementation(canBeCanceled, progressMax, method);
            }
            return(res);
        }