public static bool EnsureRemoveEntryTypeFromToday(Type entryType) { if (ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(DateTime.Now.Date)) {//if today already has training day object then we should use it var day = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[DateTime.Now.Date].Copy(); var entriesWithTheSameType = day.TrainingDay.Objects.Where(x => x.Status != EntryObjectStatus.System && x.GetType() == entryType).ToList(); if (entriesWithTheSameType.Count > 0) { //inform user that he has the same type of entry in today and if he continue, then we add a new entry to today (without overwriting existing one) if (BAMessageBox.Ask(ApplicationStrings.EntryObjectPageBase_QCopyToTodayOverwrite) == MessageBoxResult.Cancel) { return(false); } //else //{ // //instead of overwriting, we basically add this new entry to today // //overwrite // //day.TrainingDay.Objects.Remove(existingEntry); //} } ApplicationState.Current.TrainingDay = day; } else { ApplicationState.Current.TrainingDay = new TrainingDayInfo(new TrainingDayDTO()); ApplicationState.Current.TrainingDay.TrainingDay.ProfileId = ApplicationState.Current.SessionData.Profile.GlobalId; if (ApplicationState.Current.CurrentViewCustomer != null) { ApplicationState.Current.TrainingDay.TrainingDay.CustomerId = ApplicationState.Current.CurrentViewCustomer.GlobalId; } ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate = DateTime.Now.Date; } return(true); }
protected override void btnDelete_Click(object sender, EventArgs e) { if (BAMessageBox.Ask(ApplicationStrings.SupplementsPage_QRemoveSupplement) == MessageBoxResult.OK) { deleteEntry(Entry); } }
private void btnCancel_Click(object sender, EventArgs e) { if (BAMessageBox.Ask(ApplicationStrings.InvitationViewPage_QRejectInvitation) == MessageBoxResult.OK) { inviteOperation(InviteFriendOperation.Reject); } }
private void btnRemoveFromFavorites_Click(object sender, RoutedEventArgs e) { if (BAMessageBox.Ask(string.Format(ApplicationStrings.ProfileInfoPage_QRemoveFromFavorites, viewModel.UserName)) == MessageBoxResult.Cancel) { return; } progressBar.ShowProgress(true, ApplicationStrings.ProfileInfoPage_ProgressSend); viewModel.RemoveFromFavorites(); }
private void btnInviteFriendship_Click(object sender, RoutedEventArgs e) { if (BAMessageBox.Ask(string.Format(ApplicationStrings.ProfileInfoPage_QInviteFriendship, viewModel.UserName)) == MessageBoxResult.Cancel) { return; } progressBar.ShowProgress(true, ApplicationStrings.ProfileInfoPage_ProgressSend); viewModel.InviteFriendship(); }
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { if (viewModel.IsInProgress && BAMessageBox.Ask(ApplicationStrings.SynchronizationPage_QOnBackWhenSyncing) == MessageBoxResult.Cancel) { e.Cancel = true; return; } base.OnBackKeyPress(e); }
void showImplementation(EntryObjectDTO newEntry, bool next) { if (newEntry == null) { if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.EntryObjectPageBase_ErrOfflineRetrieveEntries); return; } if (BAMessageBox.Ask(ApplicationStrings.EntryObjectPageBase_QRetrieveNextMonth) == MessageBoxResult.OK) { isNextPending = next; progressBar.ShowProgress(true, ApplicationStrings.TrainingDaySelectorControl_ProgressRetrieveEntries); IsHitTestVisible = false; DateTime monthDate; if (next) { var lastDay = ApplicationState.Current.CurrentBrowsingTrainingDays.GetLastLoadedEntry(); if (lastDay == null) { monthDate = DateTime.Now; } else { monthDate = lastDay.TrainingDate; } monthDate = monthDate.AddMonths(1).MonthDate(); } else { var firstDay = ApplicationState.Current.CurrentBrowsingTrainingDays.GetFirstLoadedEntry(); if (firstDay == null) { monthDate = DateTime.Now; } else { monthDate = firstDay.TrainingDate; } monthDate = monthDate.AddMonths(-1).MonthDate(); } ApplicationState.Current.TrainingDaysRetrieved += Current_TrainingDaysRetrieved; ApplicationState.Current.RetrieveMonth(monthDate, ApplicationState.Current.CurrentBrowsingTrainingDays); } return; } if (isModified() && BAMessageBox.Ask(ApplicationStrings.EntryObjectPageBase_BackKeyQuestion) == MessageBoxResult.Cancel) { return; } ApplicationState.Current.TrainingDay = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[newEntry.TrainingDay.TrainingDate].Copy(); ApplicationState.Current.CurrentEntryId = new LocalObjectKey(newEntry); show(true); }
protected override void btnDelete_Click(object sender, EventArgs e) { if (ApplicationState.Current.TrainingDay == null) { return; } if (BAMessageBox.Ask(ApplicationStrings.MeasurementsPage_QRemoveMeasurements) == MessageBoxResult.OK) { deleteEntry(Entry); } }
void mnuShowProgress_Click(object sender, EventArgs e) { if (!UpgradeAccountControl.EnsureAccountType(ApplicationStrings.Feature_Premium_Reports, this)) { return; } if (isModified() && BAMessageBox.Ask(ApplicationStrings.StrengthWorkoutPage_QShowProgressForModifiedEntry) == MessageBoxResult.Cancel) { return; } this.Navigate("/Pages/MeasurementsReportPage.xaml"); }
void mnuRefresh_Click(object sender, EventArgs e) { var m = new ServiceManager <GetTrainingDayCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetTrainingDayCompletedEventArgs> operationCompleted) { client1.GetTrainingDayCompleted -= operationCompleted; client1.GetTrainingDayCompleted += operationCompleted; WorkoutDayGetOperation data = new WorkoutDayGetOperation(); data.WorkoutDateTime = ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate; data.UserId = ApplicationState.Current.TrainingDay.TrainingDay.ProfileId; data.CustomerId = ApplicationState.Current.TrainingDay.TrainingDay.CustomerId; data.Operation = GetOperation.Current; client1.GetTrainingDayAsync(ApplicationState.Current.SessionData.Token, data, new RetrievingInfo()); }); m.OperationCompleted += (s, a) => { progressBar.ShowProgress(false); if (ApplicationState.Current.TrainingDay == null || IsClosing) { return; } if (a.Error != null) { BAMessageBox.ShowError(ApplicationStrings.EntryObjectPageBase_ErrDuringRefresh); } else { OfflineModeManager manager = new OfflineModeManager(ApplicationState.Current.MyDays, ApplicationState.Current.SessionData.Profile.GlobalId); manager.MergeNew(a.Result.Result, ApplicationState.Current, false, delegate { return(BAMessageBox.Ask(ApplicationStrings.EntryObjectPageBase_QResfreshMerge) == MessageBoxResult.OK); }); show(true); } }; progressBar.ShowProgress(true, ApplicationStrings.EntryObjectPageBase_ProgressRefresh); if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
protected override void btnDelete_Click(object sender, EventArgs e) { if (ApplicationState.Current.TrainingDay == null) { return; } if (ReadOnly) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotModifyEntriesOfAnotherUser); return; } if (BAMessageBox.Ask(ApplicationStrings.StrengthWorkoutPage_RemoveEntry) == MessageBoxResult.OK) { deleteEntry(Entry); } }
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { if (!IsPopupOpen() && isModified() && BAMessageBox.Ask(ApplicationStrings.EntryObjectPageBase_BackKeyQuestion) == MessageBoxResult.Cancel) { e.Cancel = true; return; } if (!IsPopupOpen()) { if (!BeforeClose()) { e.Cancel = true; return; } IsClosing = true; ApplicationState.Current.TrainingDay = null; } base.OnBackKeyPress(e); }
private void btnUseInToday_Click(object sender, RoutedEventArgs e) { buttonPressed = true; var button = (RoundButton)sender; InGroup <TrainingPlanEntryViewModel> group = (InGroup <TrainingPlanEntryViewModel>)button.Tag; TrainingPlanDay planDay = (TrainingPlanDay)group.Tag; var workoutPlan = planDay.TrainingPlan; if (!workoutPlan.IsFavorite && !workoutPlan.IsMine) { BAMessageBox.ShowInfo(ApplicationStrings.WorkoutPlanViewControl_ErrMustAddPlanToFavorites); return; } if (BAMessageBox.Ask(ApplicationStrings.WorkoutPlanViewControl_btnUseInToday_QUsePlanInCalendar) == MessageBoxResult.Cancel) { return; } fillStrengthTrainingEntryWithPlan(planDay); }
private void btnStart_Click(object sender, RoutedEventArgs e) { if (!TimerHasBeenStarted && !isGPSReady() && BAMessageBox.Ask(ApplicationStrings.GPSTrackerPage_InfoGpsNotReady) == MessageBoxResult.Cancel) { return; } //if (!TimerHasBeenStarted && viewModel.Entry.HasCoordinates && BAMessageBox.Ask("This entry already contains gps coordinates. Do you want to overwrite them??") == MessageBoxResult.Cancel) //{ // return; //} if (IsPause) { timer.Start(); } else { timer.Stop(); } startTimer(IsPause); TimerHasBeenStarted = true; }
void checkCrashState() { if (ApplicationState.Current == null) { return; } bool crash = ApplicationState.Current.Crash; ApplicationState.Current.Crash = false; if (ApplicationState.Current.TrainingDay != null && crash) { if (BAMessageBox.Ask(ApplicationStrings.TrainingDaySelectorControl_QCrashSaverRestoreEntry) == MessageBoxResult.OK) { LocalObjectKey id = ApplicationState.Current.CurrentEntryId; Object currentEntry = ApplicationState.Current.TrainingDay.TrainingDay.GetEntry(id); TrainingDaySelectorControl.GoToPage(currentEntry, this); return; } } ApplicationState.Current.ResetCurrents(); }
protected override bool ValidateBeforeSave() { var incorrectSets = SerieValidator.GetIncorrectSets(Entry); if (incorrectSets.Count > 0) { StringBuilder builder = new StringBuilder(); builder.AppendLine(ApplicationStrings.StrengthTraining_MsgIncorrectSetsValidation); foreach (var incorrectSet in incorrectSets.GroupBy(x => x.StrengthTrainingItem.Exercise)) { builder.Append(incorrectSet.Key.DisplayExercise + ": "); foreach (var serieDto in incorrectSet) { builder.Append(serieDto.GetDisplayText() + ", "); } builder.AppendLine(); } if (BAMessageBox.Ask(builder.ToString()) == MessageBoxResult.Cancel) { return(false); } } return(true); }
void changeAccountType(AccountType accountType) { if (ApplicationState.Current.ProfileInfo.Licence.AccountType > accountType) { int accountDiff = accountType - ApplicationState.Current.ProfileInfo.Licence.AccountType; int kara = Math.Abs(accountDiff) * ApplicationState.Current.ProfileInfo.Licence.Payments.Kara; if (BAMessageBox.Ask(string.Format(ApplicationStrings.AccountTypePage_QChangeAccountToLower, kara)) == MessageBoxResult.Cancel) { return; } } else { if (BAMessageBox.Ask(string.Format(ApplicationStrings.AccountTypePage_QChangeAccountToHigher)) == MessageBoxResult.Cancel) { return; } } progressBar.ShowProgress(true, ApplicationStrings.AccountTypePage_ChangingAccountType); updateButtons(false); var m = new ServiceManager <AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <AsyncCompletedEventArgs> operationCompleted) { var param = new ProfileOperationParam(); param.Operation = ProfileOperation.AccountType; param.ProfileId = ApplicationState.Current.SessionData.Profile.GlobalId; param.AccountType = accountType; client1.ProfileOperationAsync(ApplicationState.Current.SessionData.Token, param); client1.ProfileOperationCompleted -= operationCompleted; client1.ProfileOperationCompleted += operationCompleted; }); m.OperationCompleted += (s, a) => { FaultException <BAServiceException> serviceEx = a.Error as FaultException <BAServiceException>; if (serviceEx != null && serviceEx.Detail.ErrorCode == ErrorCode.ConsistencyException) { updateButtons(true); BAMessageBox.ShowError(ApplicationStrings.AccountTypePage_ErrNotEnoughPoints); return; } if (a.Error != null) { BugSenseHandler.Instance.SendExceptionAsync(a.Error); updateButtons(true); progressBar.ShowProgress(false); BAMessageBox.ShowError(ApplicationStrings.AccountTypePage_ErrCannotChangeAccountType); return; } refreshProfileInfo(); }; if (!m.Run()) { updateButtons(true); progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }