private async Task PrintAsync() { try { if (_trainingDays == null) { await _userDialog.AlertAsync(Translation.Get(TRS.IMPOSSIBLE_ACTION), Translation.Get(TRS.PRINT), Translation.Get(TRS.OK)); } else { bool withImages = await _userDialog.ConfirmAsync(Translation.Get(TRS.PRINT_WITH_IMAGES) + " ?", Translation.Get(TRS.PRINT), Translation.Get(TRS.YES), Translation.Get(TRS.NO)); var trainingDayReport = new TrainingDayReport() { UserId = this.UserId, Year = this.Year, WeekOfYear = this.WeekOfYear, DayOfWeek = this.DayOfWeek, DisplayImages = withImages, TrainingDayId = null }; var memoryStream = await ReportWebService.TrainingDayReportAsync(trainingDayReport); if (memoryStream != null) { var pdfName = Guid.NewGuid().ToString() + ".pdf"; var fileManager = Resolver.Resolve <IFileManager>(); string pdfPath = Path.Combine(AppTools.TempDirectory, pdfName); bool writeSuccess = await fileManager.WriteBinaryFileAsync(pdfPath, memoryStream); if (writeSuccess) { if (Device.OS == TargetPlatform.Android) { Resolver.Resolve <IAndroidAPI> ().OpenPdf(pdfPath); } else if (Device.OS == TargetPlatform.iOS) { await WebViewViewModel.ShowAsync(pdfPath, this); } } } } } catch (Exception except) { ILogger.Instance.Error("Unable to print trainingDay", except); } }
private async void GenerateCell_Tapped(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(PasswordCell.Entry.Text) && !await _userDialogs.ConfirmAsync(AppResources.PasswordOverrideAlert, null, AppResources.Yes, AppResources.No)) { return; } var page = new ToolsPasswordGeneratorPage((password) => { PasswordCell.Entry.Text = password; _userDialogs.Toast(AppResources.PasswordGenerated); }); await Navigation.PushForDeviceAsync(page); }
private async void DeleteCell_Tapped(object sender, EventArgs e) { if (!_connectivity.IsConnected) { AlertNoConnection(); return; } // TODO: Validate the delete operation. ex. Cannot delete a folder that has logins in it? if (!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) { return; } _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); var deleteTask = await _folderService.DeleteAsync(_folderId); _userDialogs.HideLoading(); if (deleteTask.Succeeded) { _userDialogs.Toast(AppResources.FolderDeleted); await Navigation.PopForDeviceAsync(); } else if (deleteTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(deleteTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }
private async Task <bool> ConnectDeviceAsync(DeviceListItemViewModel device, bool showPrompt = true) { if (showPrompt && !await _userDialogs.ConfirmAsync($"Connect to device '{device.Name}'?")) { return(false); } try { CancellationTokenSource tokenSource = new CancellationTokenSource(); ConnectParameters connectParameters = new ConnectParameters(); await Adapter.ConnectToDeviceAsync(device.Device, connectParameters, tokenSource.Token); _userDialogs.ShowSuccess($"Initializing Reader, Please Wait.", 8000); PreviousGuid = device.Device.Id; return(true); } catch (Exception ex) { _userDialogs.Alert(ex.Message, "Connection error"); Mvx.Trace(ex.Message); return(false); } finally { //_userDialogs.HideLoading(); device.Update(); } }
public LogViewModel(SampleSqliteConnection conn, IUserDialogs dialogs) { this.Load = ReactiveCommand.CreateFromTask(async() => { var events = await conn.GeofenceEvents.OrderBy(x => x.Date).ToListAsync(); this.Events = events .Select(x => new CommandItem { Text = x.Text, Detail = x.Detail }) .ToList(); this.HasEvents = events.Any(); }); this.Clear = ReactiveCommand.CreateFromTask(async() => { var confirm = await dialogs.ConfirmAsync( "Do you wish to clear the geofence logs?", "Confirm", "Yes", "No" ); if (confirm) { await conn.DeleteAllAsync <GeofenceEvent>(); this.Load.Execute(Unit.Default); } }); this.BindBusyCommand(this.Load); }
private async Task ExecuteSubmitCommandAsync() { if (_settings.IsOnline) { var IsConfirm = await _userDialogs.ConfirmAsync("Are you sure you want to register official complaint to authority?", null, "Yes", "No"); if (IsConfirm == true) { IsBusy = true; var responce = await _complaintService.SendMail(ExternalId); if (responce == true) { await PageDialogService.DisplayAlertAsync(null, "Your complaint has been registered successfully. Thank you.", "OK"); IsBusy = false; await NavigationService.NavigateAsync(new System.Uri($"/{AppPages.SSCMaster.SSCMasterPage}/{AppPages.NavigationPage}/{AppPages.DashBoard.HomePage}/{AppPages.DashBoard.ComplaintStatusPage}", System.UriKind.RelativeOrAbsolute)); } else { IsBusy = false; await PageDialogService.DisplayAlertAsync(null, "Sorry, there seems some technical error in registering your complaint. Please try again later.", "OK"); } } } else { IsEmpty = true; EmptyStateTitle = AppAlertMessage.NoInternetConnections; IsBusy = false; } }
private async Task <bool> ConnectDeviceAsync(DeviceListItemViewModel device, bool showPrompt = true) { if (device.IsConnected) { return(true); } if (showPrompt && !await _userDialogs.ConfirmAsync($"Connect to device '{device.Name}'?")) { return(false); } try { _userDialogs.ShowLoading("Connecting ..."); await Adapter.ConnectToDeviceAync(device.Device); _userDialogs.InfoToast($"Connected to {device.Device.Name}."); PreviousGuid = device.Device.Id; return(true); } catch (Exception ex) { _userDialogs.Alert(ex.Message, "Connection error"); Mvx.Trace(ex.Message); return(false); } finally { _userDialogs.HideLoading(); device.Update(); } }
private async Task RemoveAgentExecuted(TeamAgentModel agent) { LoggingService.Trace("Executing TeamDetailsViewModel.RemoveAgentCommand"); IsAddingAgent = false; if (IsBusy) { return; } if (await _userDialogs.ConfirmAsync($"Remove '{agent.Name}' from the team ?", string.Empty, "Yes", "Cancel")) { var result = await _wasabeeApiV1Service.Teams_RemoveAgentFromTeam(Team.Id, agent.Id); if (result) { RefreshCommand.Execute(); } else { _userDialogs.Toast("Error removing agent"); } } }
public IObservable <bool> RequestConfirmation(string Message) { return(Observable.FromAsync <bool>((_) => _userDialogs.ConfirmAsync(new ConfirmConfig() { Title = Message })).Where((confirmed) => confirmed)); }
private async Task SaveRoleCommandExecuteAsync() { try { if (_settings.IsLogin) { var VerifiedResponce = await _userDialogs.ConfirmAsync("Are you sure you want to change user role ", null, "Yes", "No", null); if (VerifiedResponce == true) { IsBusy = true; var result = await _accountService.UpdateUserRole(SelectedResult.Id, SelectedAppRole.ExtId); if (result) { IsBusy = false; await PageDialogService.DisplayAlertAsync(null, "User role change successfully.", "Ok"); await NavigationService.NavigateAsync(new System.Uri($"/{AppPages.SSCMaster.SSCMasterPage}/{AppPages.NavigationPage}/{AppPages.DashBoard.SetUserRolePage}", System.UriKind.Absolute)); } IsBusy = false; } } } catch (Exception ex) { await PageDialogService.DisplayAlertAsync(null, AppAlertMessage.TechnicalError, "OK"); IsBusy = false; } }
// Private methods private async Task DestroyPerson() { var destroy = await _userDialogs.ConfirmAsync(new ConfirmConfig { Title = "Destroy Person", Message = "Sir, are you sure you want to destroy this person?", OkText = "YES", CancelText = "No" }); if (!destroy) { return; } var request = new DestructionAction { OnDestroyed = () => _navigationService.Close( this, new DestructionResult <Person> { Entity = Person, Destroyed = true }) }; Interaction.Raise(request); }
public static Task <bool> ShowPermissionDeniedQuestion(this IUserDialogs userDialogs) { return(userDialogs.ConfirmAsync( AppResources.PermissionDeniedMessage, AppResources.PermissionDeniedTitle, AppResources.OpenAppSettings)); }
private async Task ExecuteSubmitCommandAsync() { try { var IsSaveLocation = await _userDialogs.ConfirmAsync("Are you sure you want to save this location as the location of Slaughter House", "Slaughter House Location", "Yes", "No"); if (IsSaveLocation == true) { ComplaintModelObj = await _complaintService.GetNonComplaintModel(); if (ComplaintModelObj != null) { ComplaintModelObj.GpsLocations = Convert.ToString($"{MyPosition.Latitude}, {MyPosition.Longitude}"); await _complaintService.SaveComplaint(ComplaintModelObj); await NavigationService.GoBackAsync(); } } } catch (Exception ex) { await PageDialogService.DisplayAlertAsync(null, AppAlertMessage.TechnicalError, "OK"); IsBusy = false; } }
private async void GenerateCell_Tapped(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(PasswordCell.Entry.Text) && !await _userDialogs.ConfirmAsync("Are you sure you want to overwrite the current password?", null, AppResources.Yes, AppResources.No)) { return; } var page = new ToolsPasswordGeneratorPage((password) => { PasswordCell.Entry.Text = password; _userDialogs.Toast("Password generated."); }); await Navigation.PushForDeviceAsync(page); }
private async Task VerifiedComplaints() { try { if (_settings.IsOnline) { var VerifiedResponce = await _userDialogs.ConfirmAsync("Are you sure you want to verify this complaint? ", null, "Yes", "No", null); if (VerifiedResponce) { IsBusy = true; ComplaintModelObj = await _complaintService.GetNonComplaintModel(); ComplaintModelObj.ComplainStatus = (int)ComplaintStatusEnum.Verified; ComplaintModelObj.IsRejecet = false; ComplaintModelObj.CommentForRejection = " "; ComplaintModelObj.IsRegister = false; var responce = await _complaintService.SaveOnServer(ComplaintModelObj); if (responce == true) { IsBusy = false; ComplaintModelObj.Operation = (int)Operations.Update; ComplaintModelObj.IsEmailSend = false; await _complaintService.SaveComplaint(ComplaintModelObj); await NavigationService.NavigateAsync(new System.Uri($"/{AppPages.SSCMaster.SSCMasterPage}/{AppPages.NavigationPage}/{AppPages.DashBoard.HomePage}/{AppPages.DashBoard.ComplaintStatusPage}", System.UriKind.RelativeOrAbsolute)); } IsBusy = false; } else { IsBusy = false; } } else { IsBusy = false; _userDialogs.Toast("There is no INTERNET connection", new TimeSpan(20)); } } catch (Exception ex) { IsBusy = false; } }
public async Task <bool> ShowMessage(string title, string message, string buttonConfirmText, string buttonCancelText, Action <bool> afterHideCallback = null) { var result = await _userDialogs.ConfirmAsync(message, title, buttonConfirmText, buttonCancelText); afterHideCallback?.Invoke(result); return(result); }
public async Task LogoutAsync() { if (!await _userDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel)) { return; } MessagingCenter.Send(Application.Current, "Logout", (string)null); }
private async void OnDeleteCommandAsync(CustomPin pin) { bool result = await _userDialogs.ConfirmAsync(Resources["SureQuestion"]); if (result) { await DeletePinAsync(pin); } }
private async Task LogoutAsync() { if (!await _userDialogs.ConfirmAsync("Are you sure you want to log out?", null, AppResources.Yes, AppResources.Cancel)) { return; } MessagingCenter.Send(Application.Current, "Logout", (string)null); }
public RegistrationTypeSelectionPageViewModel( INavigationService navigationService, IAnalyticService analyticService, IFirebaseAuthService authService, IUserDialogs dialogs) : base(navigationService) { Title = "Registration Type"; analyticService.TrackScreen("registration-type"); Tradesman = ReactiveCommand.CreateFromTask(async() => { await dialogs.AlertAsync("Coming Soon!").ConfigureAwait(false); analyticService.TrackTapEvent("register-as-tradesman"); //await navigationService.NavigateAsync(nameof(TradesmentRegistrationPage)).ConfigureAwait(false); }); Contractor = ReactiveCommand.CreateFromTask(async() => { analyticService.TrackTapEvent("register-as-contractor"); await navigationService.NavigateAsync( nameof(ContractorRegistrationPage), new NavigationParameters { { "user_id", _userId } }).ConfigureAwait(false); }); GoBack = ReactiveCommand.CreateFromTask <Unit, Unit>(async _ => { var result = await dialogs.ConfirmAsync( new ConfirmConfig { Title = "Cancel Account Creation?", Message = "Are you sure you want to cancel account creation? This will discard any information you have entered so far", OkText = "Yes", CancelText = "No" }); if (result) { analyticService.TrackTapEvent("cancel-account-creation"); // make sure we log out so the user has to log in again await authService.Logout(); await NavigationService.NavigateToLoginPageAsync().ConfigureAwait(false); } return(Unit.Default); }); NavigatingTo .Where(args => args.ContainsKey("user_id")) .Select(args => args["user_id"].ToString()) .BindTo(this, x => x._userId); }
private async void OnDeleteTappedCommandAsync(Profile profile) { var answer = await _userDialogs.ConfirmAsync(new ConfirmConfig() .SetMessage($"{LocalizedResources["DeleteQuestion"]} {profile.Nickname}?") .UseYesNo()); if (answer) { _profileService.DeleteProfile(profile.Id); UpdateList(); } }
private async void OnRemoveCommand(object obj) { bool ans = await _userDialogs.ConfirmAsync("Remove the selected item?"); if (!ans) { return; } await _appSettingsManager.RemoveDeviceAsync(_deviceModel); await _navigationService.GoBackAsync(); }
public async Task <bool> ConfirmAction(string message, string title = "Afya Mobile", string yesbtnText = "Yes", string nobtnText = "No") { var destroy = await _userDialogs.ConfirmAsync(new ConfirmConfig { Title = title, Message = message, OkText = yesbtnText, CancelText = nobtnText }); return(destroy); }
public async Task SelectPhoto() { bool isUserAccept = await _userDialogs.ConfirmAsync(Constants.PleaseSelectPhoto, Constants.SelectPhoto, Constants.FromMemory, Constants.FromCamera); if (isUserAccept) { GetFromMemory(); return; } GetFromCamera(); }
private async Task ExecuteAddNewtItem() { var result = await _dialogs.PromptAsync( message : "Name of ToDo Item", title : "Add New Item"); var newItemTitle = result.Value; bool makeActive = true; if (this.TodoLists.Any(x => x.IsActive)) { makeActive = await _dialogs.ConfirmAsync( $"Do you want to make list '{result.Value}' your active list?", "Active List", okText : "Yes", cancelText : "No"); } _dialogs.ShowLoading(string.Empty); var created = await _repo.AddList(new Models.TodoList { Title = newItemTitle }); // if user wants to make it active, activate this one, // calling the repo method will deactivate all other lists if (makeActive) { await _repo.ActivateList(created.Id); } TodoLists.Add(created); _dialogs.HideLoading(); // navigate to the new list SelectItem.Execute(created); }
private async Task DeleteTeamExecuted(Team team) { LoggingService.Trace("Executing TeamsListViewModel.DeleteTeamCommand"); if (IsBusy) { return; } IsBusy = true; if (team.IsOwner is false) { return; } if (await _userDialogs.ConfirmAsync($"You're going to delete the team '{team.Name}'. Are you sure ?", "Danger zone", "Yes", "Cancel")) { if (await _userDialogs.ConfirmAsync("Are you REALLY sure ?", string.Empty, "Yes!", "Cancel")) { if (await _userDialogs.ConfirmAsync("Please confirm one last time before deletion", string.Empty, "Delete", "Cancel")) { var result = await _wasabeeApiV1Service.Teams_DeleteTeam(team.Id); _userDialogs.Toast(result ? $"Successfully deleted team '{team.Id}'" : "An error occured, team not deleted"); if (result) { await _teamsDatabase.DeleteTeam(team.Id); TeamsCollection.Remove(team); await RaisePropertyChanged(() => TeamsCollection); } } } } IsBusy = false; }
private async Task LogOut() { var confirmed = await _dialogs.ConfirmAsync( AppResources.LogoutMessage, AppResources.LogoutTitle, cancelText : AppResources.No); if (confirmed) { AppSettings.Instance.SignOut(); await _navigation.Navigate <SignInViewModel>(); } }
public LogsViewModel(IUserDialogs dialogs, SampleSqliteConnection conn) { this.conn = conn; this.Purge = ReactiveCommand.CreateFromTask(async() => { var result = await dialogs.ConfirmAsync("Are you sure you wish to purge all logs?"); if (result) { await this.conn.BeaconEvents.DeleteAsync(); await this.LoadData(); } }); }
private async void ExecuteDelete() { var config = new ConfirmConfig(); config.Title = "確認"; config.Message = "削除してよろしいでしょうか。"; var result = await _dialog.ConfirmAsync(config, null); if (result) { _service.DeleteTask(ID); Close(this); } }
private async void AttachmentSelected(object sender, SelectedItemChangedEventArgs e) { var attachment = e.SelectedItem as VaultAttachmentsPageModel.Attachment; if (attachment == null) { return; } ((ListView)sender).SelectedItem = null; if (!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) { return; } _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); var saveTask = await _loginService.DeleteAttachmentAsync(_login, attachment.Id); _userDialogs.HideLoading(); if (saveTask.Succeeded) { _userDialogs.Toast(AppResources.AttachmentDeleted); _googleAnalyticsService.TrackAppEvent("DeletedAttachment"); await LoadAttachmentsAsync(); } else if (saveTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }
public HistoryViewModel(SampleDbConnection conn, IGeofenceManager geofences, IUserDialogs dialogs, IMessaging messaging) { this.conn = conn; this.geofences = geofences; this.Reload = new Command(this.Load); this.Clear = ReactiveCommand.CreateAsyncTask(async x => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("Are you sure you want to delete all of your history?")); if (result) { this.conn.DeleteAll<GeofenceEvent>(); this.Load(); } }); this.SendDatabase = new Command(() => { var backupLocation = conn.CreateDatabaseBackup(conn.Platform); var mail = new EmailMessageBuilder() .Subject("Geofence Database") //.WithAttachment(conn.DatabasePath, "application/octet-stream") .WithAttachment(backupLocation, "application/octet-stream") .Body("--") .Build(); messaging.EmailMessenger.SendEmail(mail); }); }
public SettingsViewModel(IPermissions permissions, IGeofenceManager geofences, IUserDialogs dialogs, IViewModelManager viewModelMgr) { this.permissions = permissions; this.geofences = geofences; this.dialogs = dialogs; this.Menu = new Command(() => dialogs.ActionSheet(new ActionSheetConfig() .SetCancel() .Add("Add Geofence", async () => await viewModelMgr.PushNav<AddGeofenceViewModel>() ) .Add("Use Default Geofences", async () => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("This will stop monitoring all existing geofences and set the defaults. Are you sure you want to do this?")); if (result) { geofences.StopAllMonitoring(); await Task.Delay(500); geofences.StartMonitoring(new GeofenceRegion { Identifier = "FC HQ", Center = new Position(43.6411314, -79.3808415), // 88 Queen's Quay - Home Radius = Distance.FromKilometers(1) }); geofences.StartMonitoring(new GeofenceRegion { Identifier = "Close to HQ", Center = new Position(43.6411314, -79.3808415), // 88 Queen's Quay Radius = Distance.FromKilometers(3) }); geofences.StartMonitoring(new GeofenceRegion { Identifier = "Ajax GO Station", Center = new Position(43.8477697, -79.0435461), Radius = Distance.FromMeters(500) }); await Task.Delay(500); // ios needs a second to breathe when registering like this this.RaisePropertyChanged("CurrentRegions"); } }) .Add("Stop All Geofences", async () => { var result = await dialogs.ConfirmAsync(new ConfirmConfig() .UseYesNo() .SetMessage("Are you sure wish to stop monitoring all geofences?")); if (result) { this.geofences.StopAllMonitoring(); this.RaisePropertyChanged("CurrentRegions"); } }) )); this.Remove = new Command<GeofenceRegion>(x => { this.geofences.StopMonitoring(x); this.RaisePropertyChanged("CurrentRegions"); }); }