void ObjectsReposidory_ExercisesLoaded(object sender, EventArgs e) { ApplicationState.Current.Cache.Exercises.Loaded -= new EventHandler(ObjectsReposidory_ExercisesLoaded); if (ApplicationState.Current.Cache.Exercises == null || !ApplicationState.Current.Cache.Exercises.IsLoaded) { onExercisesLoaded(); BAMessageBox.ShowError(ApplicationStrings.ExerciseTypeViewModel_ErrRetrieveExercises); return; } if (GroupedExercises == null) { GroupedExercises = new ObservableCollection <GroupingLayer <string, ExerciseViewModel> >(); } else { GroupedExercises.Clear(); } var res = ApplicationState.Current.Cache.Exercises.Items.Values.Where(x => ExerciseType == null || x.ExerciseType == ExerciseType.Value).OrderBy(x => EnumLocalizer.Default.Translate(x.ExerciseType)).ThenBy(x => Settings.ExercisesSortBy == ExerciseSortBy.Name ? x.Name : x.Shortcut).Select(x => new ExerciseViewModel(x) { IsAddMode = SelectionMode }).GroupBy( x => EnumLocalizer.Default.Translate(x.Exercise.ExerciseType)).Select(n => new GroupingLayer <string, ExerciseViewModel>(n)); foreach (var exercise in res) { GroupedExercises.Add(exercise); } onExercisesLoaded(); }
void btnDeleteMessages_Click(object sender, EventArgs e) { if (!NetworkInterface.GetIsNetworkAvailable() || ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); return; } var messagesToDelete = lstMessages.SelectedItems.Cast <Message>().Select(x => x.MessageViewModel.Message).ToList(); foreach (var message in messagesToDelete) { ApplicationState.Current.Cache.Messages.Remove(message.GlobalId); } ThreadPool.QueueUserWorkItem((a1) => { foreach (var message in messagesToDelete) { ServicePool.Add(new DeleteMessageServiceCommand(message.GlobalId)); } }); fill(); lstMessages.IsSelectionEnabled = false; }
public void PrepareTrainingDay() { if (ApplicationState.Current.CurrentBrowsingTrainingDays.IsMine) { ApplicationState.Current.TimerStartTime = null; if (!ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(currentDate)) { var day = new TrainingDayDTO(); day.TrainingDate = currentDate; day.ProfileId = ApplicationState.Current.SessionData.Profile.GlobalId; if (ApplicationState.Current.CurrentViewCustomer != null) { day.CustomerId = ApplicationState.Current.CurrentViewCustomer.GlobalId; } ApplicationState.Current.TrainingDay = new TrainingDayInfo(day); return; } } if (ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(currentDate)) { ApplicationState.Current.TrainingDay = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[currentDate].Copy(); } else { BAMessageBox.ShowError("Nie powinien tutaj wejsc. PrepareTrainingDay"); } return; }
private void usrProgressIndicatorButtons_OkClick(object sender, Controls.CancellationSourceEventArgs e) { bool isValid = true; Dispatcher.Invoke(new Action(delegate { if (!validateInternal()) { isValid = false; BAMessageBox.ShowError(Strings.Message_EditDomainObjectWindow_WrongFields); return; } })); if (!isValid) { return; } var res = userControl.Save(); UIHelper.BeginInvoke(new Action(delegate { if (res != null) { userControl.Object = res; DialogResult = true; Close(); } }), Dispatcher); }
// Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { e.Handled = true; ApplicationState.Current.SaveState(true); if (System.Diagnostics.Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger System.Diagnostics.Debugger.Break(); } else { //EmailComposeTask emailComposeTask = new EmailComposeTask(); //emailComposeTask.Subject = "Unhandled exception occured"; //emailComposeTask.Body = e.ExceptionObject.StackTrace; //emailComposeTask.To = "*****@*****.**"; //emailComposeTask.Show(); #if DEBUG MessageBox.Show(e.ExceptionObject.Message); MessageBox.Show(e.ExceptionObject.StackTrace); #else BAMessageBox.ShowError(ApplicationStrings.ErrUnhandledErrorOccured); #endif } }
private void btnCreate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(viewModel.Password) || viewModel.Password != viewModel.ConfirmPassword) { BAMessageBox.ShowError(ApplicationStrings.CreateProfilePage_ErrWrongPasswords); return; } viewModel.Country = Country; if (Settings.InitialAsk) { createProfile(); return; } var ctrl = new FeatureConfirmationControl(); ctrl.ShowPopup(messagePrompt => { messagePrompt.IsCancelVisible = false; messagePrompt.Completed += (a, s) => { Settings.InitialAsk = true; createProfile(); }; }); }
public void Send() { if (message.Sender == null) { message.Sender = ApplicationState.Current.SessionData.Profile; } if (string.IsNullOrEmpty(message.Topic)) { onOperationCompleted(true); BAMessageBox.ShowError(ApplicationStrings.MessageViewModel_ErrorTopicEmpty); return; } if (message.Sender.GlobalId != ApplicationState.Current.SessionData.Profile.GlobalId) { onOperationCompleted(true); BAMessageBox.ShowError("Err with sender"); return; } var m = new ServiceManager <AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <AsyncCompletedEventArgs> operationCompleted) { client1.SendMessageCompleted -= operationCompleted; client1.SendMessageCompleted += operationCompleted; client1.SendMessageAsync(ApplicationState.Current.SessionData.Token, message); }); m.OperationCompleted += (s, a) => { FaultException <ValidationFault> faultEx = a.Error as FaultException <ValidationFault>; if (faultEx != null) { onOperationCompleted(true); BAMessageBox.ShowError(faultEx.Detail.Details[0].Key + ":" + faultEx.Detail.Details[0].Message); return; } if (a.Error != null) { BugSenseHandler.Instance.SendExceptionAsync(a.Error); onOperationCompleted(true); BAMessageBox.ShowError(ApplicationStrings.MessageViewModel_ErrorSendMessage); return; } onOperationCompleted(false); }; if (!m.Run()) { onOperationCompleted(true); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (txtComment.Text == string.Empty) { return; } this.Focus(); progressBar.ShowProgress(true, ApplicationStrings.BlogPage_ProgressSavingComment); var m = new ServiceManager <TrainingDayCommentOperationCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <TrainingDayCommentOperationCompletedEventArgs> operationCompleted) { TrainingDayCommentOperationParam operation = new TrainingDayCommentOperationParam(); operation.OperationType = TrainingDayOperationType.Add; var dto = new TrainingDayCommentDTO(); dto.Comment = txtComment.Text; dto.Profile = ApplicationState.Current.SessionData.Profile; operation.Comment = dto; operation.TrainingDayId = viewModel.Day.GlobalId; client1.TrainingDayCommentOperationAsync(ApplicationState.Current.SessionData.Token, operation); client1.TrainingDayCommentOperationCompleted -= operationCompleted; client1.TrainingDayCommentOperationCompleted += operationCompleted; }); m.OperationCompleted += (s1, a1) => { FaultException <BAServiceException> serviceEx = a1.Error as FaultException <BAServiceException>; if (serviceEx != null && serviceEx.Detail.ErrorCode == ErrorCode.InvalidOperationException) { BAMessageBox.ShowError(ApplicationStrings.ErrCommentsAreDisabled); return; } else if (a1.Error != null) { progressBar.ShowProgress(false); BAMessageBox.ShowError(ApplicationStrings.BlogPage_ErrSavingComment); return; } else { txtComment.Text = string.Empty; progressBar.ShowProgress(true, ApplicationStrings.BlogPage_ProgressRetrieveComments); viewModel.LoadComments(); } }; if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } return; } }
public bool ValidateControl() { if (GpsTrackerEntry.Exercise == null) { BAMessageBox.ShowError(GPSStrings.usrGPSTrackerEntry_ErrActivityNull); return(false); } return(true); }
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); }
private void btnAddItem_Click(object sender, EventArgs e) { Cursor = Cursors.Wait; try { var menuItem = (MenuItem)sender; var pairEntry = (ImageSourceListItem <Type>)menuItem.DataContext; EntryObjectInstanceAttribute entryAttribute = new EntryObjectInstanceAttribute(); var attributes = pairEntry.Value.GetCustomAttributes(typeof(EntryObjectInstanceAttribute), true); if (attributes.Length > 0) { entryAttribute = (EntryObjectInstanceAttribute)attributes[0]; } //if this type can be only once added then we need to check if we can add it if (entryAttribute.Instance == EntryObjectInstance.Single) { if (day.ContainsSpecifiedEntry(pairEntry.Value)) { BAMessageBox.ShowError(Strings.ErrorEntryObjectTypeAlreadyExists); return; } } var entry = day.AddEntry(pairEntry.Value); if (day.TrainingDate.IsFuture()) {//for entries in future set planned status entry.Status = EntryObjectStatus.Planned; } if (EntryObjectBuilder != null) { EntryObjectBuilder.EntryObjectCreated(entry); } try { createNewEntryControl(entry, true, null); SetModifiedFlag(); Cursor = Cursors.Arrow; } catch (TrainingIntegrationException ex) { day.RemoveEntry(entry); ExceptionHandler.Default.Process(ex, Strings.ErrorTrainingIntegrity, ErrorWindow.MessageBox); } catch (Exception ex) { day.RemoveEntry(entry); ExceptionHandler.Default.Process(ex, Strings.ErrorUnhandledException, ErrorWindow.EMailReport); } } finally { Cursor = Cursors.Arrow; } }
public void friendshipOperation(InviteFriendOperation operation) { var m = new ServiceManager <InviteFriendOperationCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <InviteFriendOperationCompletedEventArgs> operationCompleted) { InviteFriendOperationData data = new InviteFriendOperationData(); data.Operation = operation; data.User = user; client1.InviteFriendOperationCompleted -= operationCompleted; client1.InviteFriendOperationCompleted += operationCompleted; client1.InviteFriendOperationAsync(ApplicationState.Current.SessionData.Token, data); }); m.OperationCompleted += (s, a) => { FaultException <BAServiceException> faultEx = a.Error as FaultException <BAServiceException>; if (a.Error != null && (faultEx == null || faultEx.Detail.ErrorCode != ErrorCode.ObjectNotFound)) { BugSenseHandler.Instance.SendExceptionAsync(a.Error); onOperationCompleted(); BAMessageBox.ShowError(ApplicationStrings.UserViewModel_ErrOperation); } else { if (operation == InviteFriendOperation.Reject) { ApplicationState.Current.ProfileInfo.Friends.Remove(user); NotifyPropertyChanged("IsFriend"); NotifyPropertyChanged("IsCalendarAccessible"); NotifyPropertyChanged("HasAccessToMeasurements"); } else { ApplicationState.Current.ProfileInfo.Invitations.Add(new FriendInvitationDTO() { CreatedDateTime = DateTime.UtcNow, InvitationType = InvitationType.Invite, Invited = user }); } NotifyPropertyChanged("CanBeFriend"); onOperationCompleted(); } }; if (!m.Run()) { onOperationCompleted(); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
private void mnuRemoveSuperSet_Click(object sender, RoutedEventArgs e) { if (ReadOnly) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotModifyEntriesOfAnotherUser); return; } var item = (StrengthTrainingItemViewModel)(sender as FrameworkElement).DataContext; _viewModel.RemoveSuperSet(item); }
static void Default_ShowMessageBoxWindow(object sender, ErrorEventArgs e) { if (e.Exception is ValidationException) { BAMessageBox.ShowValidationError(((ValidationException)e.Exception).Results); } else { BAMessageBox.ShowError(e.DisplayMessage, e.ErrorId); } }
void generateReport() { if (result != null) { fillReportData(result); return; } progressBar.Visibility = Visibility.Visible; chart.Visibility = Visibility.Collapsed; txtMessage.Text = ApplicationStrings.MeasurementsReportPage_MsgGeneratingReport; var m = new ServiceManager <ReportMeasurementsTimeCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <ReportMeasurementsTimeCompletedEventArgs> operationCompleted) { ReportMeasurementsTimeParams data = new ReportMeasurementsTimeParams(); data.UserId = ApplicationState.Current.TrainingDay.TrainingDay.ProfileId; data.CustomerId = ApplicationState.Current.TrainingDay.TrainingDay.CustomerId; data.StartDate = DateTime.UtcNow.AddYears(-1); client1.ReportMeasurementsTimeCompleted -= operationCompleted; client1.ReportMeasurementsTimeCompleted += operationCompleted; client1.ReportMeasurementsTimeAsync(ApplicationState.Current.SessionData.Token, data); }); m.OperationCompleted += (s, a) => { progressBar.Visibility = Visibility.Collapsed; FaultException <BAServiceException> faultEx = a.Error as FaultException <BAServiceException>; if (a.Error != null) { txtMessage.Text = ApplicationStrings.MeasurementsReportPage_ErrGeneratingReport; BAMessageBox.ShowError(ApplicationStrings.MeasurementsReportPage_ErrGeneratingReport); } else { chart.Visibility = Visibility.Visible; txtMessage.Text = ""; fillReportData(a.Result); } }; if (!m.Run()) { progressBar.Visibility = Visibility.Collapsed; if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
void retrievePlansPage(int pageIndex) { progressBar.ShowProgress(true, ApplicationStrings.WorkoutPlans_ProgressRetrievingPlans); PartialRetrievingInfo pageInfo = new PartialRetrievingInfo(); pageInfo.PageIndex = pageIndex; var m = new ServiceManager <GetWorkoutPlansCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetWorkoutPlansCompletedEventArgs> operationCompleted) { lblNoSearchResult.Visibility = System.Windows.Visibility.Collapsed; client1.GetWorkoutPlansAsync(ApplicationState.Current.SessionData.Token, allCriteria, pageInfo); client1.GetWorkoutPlansCompleted -= operationCompleted; client1.GetWorkoutPlansCompleted += operationCompleted; }); m.OperationCompleted += (s, a) => { if (a.Error != null) { progressBar.ShowProgress(false); FaultException <ValidationFault> faultEx = a.Error as FaultException <ValidationFault>; if (faultEx != null) { BAMessageBox.ShowError(faultEx.Detail.Details[0].Key + ":" + faultEx.Detail.Details[0].Message); return; } BAMessageBox.ShowError(ApplicationStrings.ErrCannotRetrievePlans); return; } allItemsCount = a.Result.Result.AllItemsCount; foreach (var planDto in a.Result.Result.Items) { allPlans.Add(new WorkoutPlanViewModel(planDto)); } if (allItemsCount == 0) { lblNoSearchResult.Visibility = System.Windows.Visibility.Visible; } progressBar.ShowProgress(false); updateApplicationBarButtons(); }; if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
private void OnMyPlacesOnLoaded(object s, EventArgs a) { ApplicationState.Current.Cache.MyPlaces.Loaded -= OnMyPlacesOnLoaded; if (ApplicationState.Current.Cache.MyPlaces.IsLoaded) { fillMyPlaces(); } else { BAMessageBox.ShowError(ApplicationStrings.ErrCannotRetrieveMyPlaces); } progressBar.ShowProgress(false); }
private void Featured_Loaded(object s, EventArgs a) { ApplicationState.Current.Cache.Featured.Loaded -= Featured_Loaded; if (ApplicationState.Current.Cache.Featured.IsLoaded) { fillFeatured(); } else { BAMessageBox.ShowError(ApplicationStrings.FeaturedPage_ErrCannotRetrieveFeaturedItems); } progressBar.ShowProgress(false); }
protected void Delete_Click() { if (!ApplicationState.Current.TrainingDay.TrainingDay.IsMine) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotModifyEntriesOfAnotherUser); return; } SelectedSetView.Delete(); if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }
public void AddMember(CustomerDTO customer) { if (Members.Any(x => x.Customer.GlobalId == customer.GlobalId)) { BAMessageBox.ShowError("Error_CustomerGroupDetailsViewModel_AddMember_AlreadyInGroup".TranslateInstructor()); return; } var viewModel = new GroupMemberItem(customer); Members.Add(viewModel); ValidateMembers(); ValidateCustomers(); }
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); } } }
private void btnAddToFavorites_Click(object sender, EventArgs e) { if (!UpgradeAccountControl.EnsureAccountType(ApplicationStrings.Feature_Premium_CreatingWorkoutPlans, this)) { return; } progressBar.ShowProgress(true); var m = new ServiceManager <WorkoutPlanOperationCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <WorkoutPlanOperationCompletedEventArgs> operationCompleted) { var param = new WorkoutPlanOperationParam(); param.WorkoutPlanId = SelectedPlan.GlobalId; param.Operation = SupplementsCycleDefinitionOperation.AddToFavorites; client1.WorkoutPlanOperationAsync(ApplicationState.Current.SessionData.Token, param); client1.WorkoutPlanOperationCompleted -= operationCompleted; client1.WorkoutPlanOperationCompleted += operationCompleted; }); m.OperationCompleted += (s1, a1) => { progressBar.ShowProgress(false); FaultException <BAServiceException> serviceEx = a1.Error as FaultException <BAServiceException>; if (serviceEx != null && serviceEx.Detail.ErrorCode == ErrorCode.LicenceException) { BAMessageBox.ShowInfo(ApplicationStrings.ErrLicence); return; } if (a1.Error != null) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotAddPlanToFavorites); return; } else { ApplicationState.Current.Cache.TrainingPlans.Items.Add(SelectedPlan.GlobalId, SelectedPlan); } updateApplicationBar(); }; if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
private void btnAddCategory_Click(object sender, RoutedEventArgs e) { ChampionshipCategoryEditor dlg = new ChampionshipCategoryEditor(); if (dlg.ShowDialog() == true) { if (categories.Where(x => x.Category.IsTheSame(dlg.Category)).Count() > 0) { BAMessageBox.ShowError(InstructorStrings.usrChampionshipScheduleEntryEditor_ErrCategoryAlreadySelected); return; } categories.Add(new ChampionshipCategoryViewModel(dlg.Category)); } }
private void voteOnWorkoutPlan(VoteObject objType) { var m = new ServiceManager <VoteCompletedEventArgs>( delegate(BodyArchitectAccessServiceClient client1, EventHandler <VoteCompletedEventArgs> operationCompleted) { VoteParams param = new VoteParams(); param.GlobalId = Item.GlobalId; param.UserRating = Item.UserRating; param.UserShortComment = Item.UserShortComment; param.ObjectType = objType; client1.VoteCompleted -= operationCompleted; client1.VoteCompleted += operationCompleted; //client1.VoteAsync(ApplicationState.Current.SessionData.Token, (WorkoutPlanDTO)Item); client1.VoteAsync(ApplicationState.Current.SessionData.Token, param); }); m.OperationCompleted += (s, a) => { progressBar.ShowProgress(false); if (a.Error != null) { BAMessageBox.ShowError(ApplicationStrings.VotingPage_ErrSendRating); } else { saved = true; Item.Rating = a.Result.Result.Rating; if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } }; if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
public void LoadComments() { result = null; if (day == null || day.GlobalId == Guid.Empty) { _comments.Clear(); setCommentsStatus(); onBlogCommentsLoaded(); return; } CommentsStatus = ApplicationStrings.BlogViewModel_LoadComments_Loading; var m = new ServiceManager <GetTrainingDayCommentsCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetTrainingDayCommentsCompletedEventArgs> operationCompleted) { client1.GetTrainingDayCommentsAsync(ApplicationState.Current.SessionData.Token, day, new PartialRetrievingInfo()); client1.GetTrainingDayCommentsCompleted -= operationCompleted; client1.GetTrainingDayCommentsCompleted += operationCompleted; }); m.OperationCompleted += (s, a) => { if (a.Error != null) { onBlogCommentsLoaded(); BAMessageBox.ShowError(ApplicationStrings.BlogViewModel_LoadComments_ErrorMsg); return; } else { _comments.Clear(); fillComments(a); setCommentsStatus(); } onBlogCommentsLoaded(); }; if (!m.Run()) { onBlogCommentsLoaded(); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
public void ChangeStatus() { //progressStatus.ShowProgress(true, ApplicationStrings.ChangeStatusControl_ChangingStatusProgress); var m = new ServiceManager <AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <AsyncCompletedEventArgs> operationCompleted) { var param = new ProfileOperationParam(); param.Operation = ProfileOperation.SetStatus; param.ProfileId = ApplicationState.Current.SessionData.Profile.GlobalId; param.Status = new ProfileStatusDTO() { Status = Comment }; client1.ProfileOperationAsync(ApplicationState.Current.SessionData.Token, param); client1.ProfileOperationCompleted -= operationCompleted; client1.ProfileOperationCompleted += operationCompleted; }); m.OperationCompleted += (s1, a1) => { if (a1.Error != null) { //progressStatus.ShowProgress(false); BAMessageBox.ShowError(ApplicationStrings.ChangeStatusControl_ErrChangeStatus); return; } else { //progressStatus.ShowProgress(false); if (OperationCompleted != null) { OperationCompleted(this, EventArgs.Empty); } } }; if (!m.Run()) { progressStatus.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } return; } }
protected virtual void DeleteSet_Click(object sender, RoutedEventArgs e) { if (!EditMode) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotModifyEntriesOfAnotherUser); return; } var item = (SetViewModel)(sender as FrameworkElement).DataContext; item.Delete(); //SelectedItemView.Delete(item); //DataContext = null; //DataContext = SelectedItemView; fill(); }
private void mnuDelete_Click(object sender, RoutedEventArgs e) { if (ReadOnly) { BAMessageBox.ShowError(ApplicationStrings.ErrCannotModifyEntriesOfAnotherUser); return; } var item = (StrengthTrainingItemViewModel)(sender as FrameworkElement).DataContext; _viewModel.Delete(item); lsItems.SelectedIndex = -1; //DataContext = null; DataContext = _viewModel; lblNoExercises.Visibility = Entry.Entries.Count == 0? System.Windows.Visibility.Visible: System.Windows.Visibility.Collapsed; }
public void Load(IRatingable exercise) { entry = exercise; var m = new ServiceManager <GetCommentsCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <GetCommentsCompletedEventArgs> operationCompleted) { client1.GetCommentsCompleted -= operationCompleted; client1.GetCommentsCompleted += operationCompleted; client1.GetCommentsAsync(ApplicationState.Current.SessionData.Token, entry.GlobalId, new PartialRetrievingInfo()); }); m.OperationCompleted += (s, a) => { refreshRequired = false; if (a.Error != null) { onCommentsLoaded(); BAMessageBox.ShowError(ApplicationStrings.VotesControl_ErrRetrieveRatings); return; } else { Comments.Clear(); result = a.Result.Result; foreach (var item in a.Result.Result.Items) { Comments.Add(new VoteViewModel(item)); } updateNoRatingsLabel(); loaded = true; //setCommentsStatus(); } onCommentsLoaded(); }; if (!m.Run()) { onCommentsLoaded(); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
private void goToOffline(bool automatic) { showProgress(true, true); progressBar.ShowProgress(true, ApplicationStrings.Login_ProgressOfflineModeStart); ThreadPool.QueueUserWorkItem(delegate { try { ApplicationState.GoToOfflineMode(); Deployment.Current.Dispatcher.BeginInvoke(delegate { progressBar.ShowProgress(false); onLoggingChanged(); if (!Settings.InfoOfflineMode) { Settings.InfoOfflineMode = true; BAMessageBox.ShowInfo(ApplicationStrings.MessageOfflineModeDescription); } }); } catch (InvalidOperationException ex) { Deployment.Current.Dispatcher.BeginInvoke(() => showProgress(false, true)); if (automatic) { BAMessageBox.ShowError(ApplicationStrings.ErrDuringLogin); } else { BAMessageBox.ShowWarning(ApplicationStrings.Login_ErrGoOffline_MustLoginFirst, true); } } catch { Deployment.Current.Dispatcher.BeginInvoke(() => showProgress(false, true)); if (automatic) { BAMessageBox.ShowError(ApplicationStrings.ErrDuringLogin); } else { BAMessageBox.ShowError(ApplicationStrings.Login_ErrGoOfflineMode); } } }); }