public async Task <byte[]> GetProfileImage() { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DialogService.DisplayAlert(Strings.Ok, null, Strings.No_Camera, Strings.Camera_Not_Available); return(null); } MediaFile file = null; var action = await DialogService.DisplayActionSheet("Image Options", "Cancel", null, "Selected Picture", "Take Picture"); if (action == "Selected Picture") { file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { CompressionQuality = 50, PhotoSize = PhotoSize.Medium }); } else if (action == "Take Picture") { // DialogService.ShowToast("Not Available"); file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { CompressionQuality = 100, PhotoSize = PhotoSize.Full }); } if (file == null) { return(null); } byte[] resizedImage = await CrossImageResizer.Current.ResizeImageWithAspectRatioAsync(file.GetStream(), 1000, 1000); bProfileImage = resizedImage; return(resizedImage); //var stream = file.GetStream(); //byte[] buffer = new byte[stream.Length]; //using (MemoryStream ms = new MemoryStream()) //{ // stream.CopyTo(ms); // buffer = ms.ToArray(); // file.Dispose(); // bProfileImage = buffer; // return buffer; //} }
private async void Phone_Tapped(object sender, EventArgs e) { var res = await DialogService.DisplayActionSheet("Contact Us", "Close", null, pNumber1, pNumber2); if (res == pNumber1) { DialogService.QCall(pNumber1); } else if (res == pNumber2) { DialogService.QCall(pNumber2); } }
public async void DisplaysActionSheetWithResponse() { var page = new Mock <IPage>(); page.Setup(x => x.DisplayActionSheet("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook")) .ReturnsAsync("Yes"); var dialogService = new DialogService(page.Object); var answer = await dialogService.DisplayActionSheet("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook"); page.Verify(x => x.DisplayActionSheet("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook")); Assert.That(answer, Is.EqualTo("Yes")); }
private async void CheckOutAction() { if (IsBusy) { return; } IsBusy = true; DialogService.ShowLoading("Proccesing"); try { //double AddonTotal = 0; //for(var i=0; i < MyCartList.Count; i++) //{ // if (MyCartList[i].Addon == "true") // { // AddonTotal = AddonTotal + (Convert.ToDouble(MyCartList[i].Price) * Convert.ToInt16(MyCartList[i].Quantity)); // } // else //MAYBE // { // if ((Convert.ToDouble(MyCartList[i].Price) * Convert.ToInt16(MyCartList[i].Quantity)) > 24.00) // break; // } // if ((i + 1) == MyCartList.Count) // { // DialogService.HideLoading(); // if (Convert.ToDouble(GrandPrice) > 44.00) break; // if (AddonTotal < 44.00) // { // await DialogService.DisplayAlert(null, Strings.Ok, "Info", "You only have Addons in your Cart, Please add an item over 25 XCD or make addon items addup over 45 XCD"); // return; // } // } //} if (!(Convert.ToDouble(GrandPrice) > 24.00)) { DialogService.HideLoading(); await DialogService.DisplayAlert(null, Strings.Ok, "Info", "Cart Total Most be $25.00 Or Over"); return; } var address = await AddressService.Instance.FetchAddresses(AccountService.Instance.Current_Account.Email, 1, 0); DialogService.HideLoading(); bool useCard = false; //temp string payment_response = await DialogService.DisplayActionSheet("Payment Methods", "Close", null, Strings.Cash_On_Delivery, Strings.Credit_Debit_Card); if (payment_response == Strings.Credit_Debit_Card) { useCard = true; //DialogService.ShowToast("Not Available At The Moment"); ///return; } else if (payment_response == Strings.Cash_On_Delivery) { useCard = false; } else { return; } if (address == null) { await _pageService.PushAsync(new ConfirmOrder(null, MyCartList, null, useCard)); return; } await _pageService.PushAsync(new ConfirmOrder(address[0], MyCartList, null, useCard)); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; } }