public bool DeleteSelectedExercises() { var exercisesToDelete = this.SelectedExercise; if (exercisesToDelete == null || exercisesToDelete.Status == PublishStatus.Published || !exercisesToDelete.IsMine()) { return(false); } try { if (FMMessageBox.AskYesNo(ApplicationStrings.QRemoveExercise, SelectedExercise.GetLocalizedName()) == System.Windows.Forms.DialogResult.Yes) { PleaseWait.Run(delegate { ServiceManager.DeleteExercise(exercisesToDelete); }, false, null); ObjectsReposidory.ClearExerciseCache(); OnFillReqest(); return(true); } return(false); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorRemoveExercise, ErrorWindow.EMailReport); return(false); } }
private void selectedExerciseChanged() { if (SelectedExercise != null) { usrExerciseEditor.Fill(SelectedExercise, ExercisesReposidory.Instance.Items.Values); bool showComments = !SelectedExercise.IsNew; tpComments.SetVisible(showComments); if (showComments && SelectedExercise != null) { if (xtraTabControl.SelectedItem == tpComments) { usrWorkoutCommentsList1.CannotVote = SelectedExercise.IsMine(); usrWorkoutCommentsList1.Fill(SelectedExercise); } else if (xtraTabControl.SelectedItem == tpRecords) { usrExerciseRecords.Fill(SelectedExercise); } } } else { usrExerciseEditor.ClearContent(); usrWorkoutCommentsList1.ClearContent(); usrExerciseRecords.ClearContent(); } updateButtons(false); }
void updateButtons(bool startOperation) { //exercisesTree1.Enabled = !startOperation; CanDelete = false; CanEdit = !startOperation && this.SelectedExercise != null && SelectedExercise.IsMine() && !SelectedExercise.IsNew; CanNew = !startOperation && (SelectedExercise != null || SelectedExerciseType.HasValue); CanAddToFavorites = !startOperation && SelectedExercise.CanAddToFavorites(); CanRemoveFromFavorites = !startOperation && SelectedExercise.CanRemoveFromFavorites(); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { Node node = GetHitNode(); FocusedNode = node; e.Cancel = node == null || (SelectedExerciseType != null && !AllowsAdd); mnuDelete.Visible = SelectedExercise.IsEditable(); mnuAddExercise.Visible = AllowsAdd && SelectedExercise == null; mnuEditExercise.Visible = SelectedExercise.IsEditable(); mnuOpenExercise.Visible = SelectedExercise != null && !SelectedExercise.IsEditable(); }
private void rbtRemoveFromFavorites_Click(object sender, RoutedEventArgs e) { if (!UIHelper.EnsurePremiumLicence()) { return; } UIHelper.RunWithExceptionHandling(delegate { if (SelectedExercise.RemoveFromFavorites()) { Fill(pageContext); } }); }
private void rbtnEdit_Click(object sender, RoutedEventArgs e) { if (!UIHelper.EnsurePremiumLicence()) { return; } var dlg = new EditDomainObjectWindow(); var ctrl = new usrExerciseEditor(); ctrl.Fill(SelectedExercise.StandardClone(), ExercisesReposidory.Instance.Items.Values); dlg.SetControl(ctrl); if (dlg.ShowDialog() == true) { ExercisesReposidory.Instance.Update((ExerciseDTO)ctrl.Object); Fill(pageContext); } }