private async void imagePicker_SelectedIndexChanged(object sender, EventArgs e) { overlay.IsVisible = true; Picker picker = sender as Picker; string userId = Application.Current.Properties["Id"].ToString().Replace("\"", ""); if (picker.SelectedIndex == -1) { return; } ImageOption imageOption = new ImageOption(); MediaFile imagePath = null; if (picker.SelectedIndex == 0) { imagePath = await imageOption.TakePhoto(); } else if (picker.SelectedIndex == 1) { imagePath = await imageOption.UploadPhoto(); } string imageLink = await fireStorage.StoreImages(imagePath.GetStream(), userId + DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_fff")); await api.updateProfilePicture(userId, imageLink); await api.syncUserData(userId); retrieveUserProp(); imagePicker.IsVisible = false; imagePicker.SelectedIndex = -1; overlay.IsVisible = false; }
private async void ImagePicker_SelectedIndexChanged(object sender, EventArgs e) { try { Picker picker = sender as Picker; if (picker.SelectedIndex == -1) { return; } ImageOption imageOption = new ImageOption(); MediaFile imagePath = null; int counter = 0; if (picker.SelectedIndex == 0) { imagePath = await imageOption.TakePhoto(); } else if (picker.SelectedIndex == 1) { imagePath = await imageOption.UploadPhoto(); } var looper = imageGrid.Children.Where(x => x is Frame); if (!string.IsNullOrEmpty(imagePath.Path.ToString())) { foreach (Frame btn in looper) { ImageButton sample = btn.Content as ImageButton; //await DisplayAlert("Error!", sample.Source.ToString(), "Okay"); counter++; if (sample.Source.ToString().Contains("dashed_border.png")) { sample.Source = imagePath.Path.ToString(); sample.Aspect = Aspect.AspectFill; var sample2 = await fireStorage.StoreImages(imagePath.GetStream(), (Application.Current.Properties["Id"].ToString().Replace("\"", "") + "_" + counter.ToString()) + DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_fff")); imageUrl = sample2; await saveToGallery(); savetoSqlite(); break; } } } imagePicker.SelectedIndex = -1; } catch (Exception ex) { await DisplayAlert("Edit Profile", ex.ToString(), "Okay"); } }
private async void imagePicker_SelectedIndexChanged(object sender, EventArgs e) { Picker picker = sender as Picker; string userId = Application.Current.Properties["Id"].ToString().Replace("\"", ""); if (picker.SelectedIndex == -1) { return; } ImageOption imageOption = new ImageOption(); MediaFile imagePath = null; if (picker.SelectedIndex == 0) { imagePath = await imageOpt.TakePhoto(); } else if (picker.SelectedIndex == 1) { imagePath = await imageOpt.UploadPhoto(); } string imageLink = await fireStorage.StoreImages(imagePath.GetStream(), Session_Id + userId + Receiver_Id + DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_fff")); await sendMessage(imageLink); }
private async void ImagePicker_SelectedIndexChanged(object sender, EventArgs e) { try { Picker picker = sender as Picker; if (picker.SelectedIndex == -1) { return; } ImageOption imageOption = new ImageOption(); MediaFile imagePath = null; int counter = 0; if (picker.SelectedIndex == 0) { imagePath = await imageOption.TakePhoto(); } else if (picker.SelectedIndex == 1) { imagePath = await imageOption.UploadPhoto(); } var looper = imageGrid.Children.Where(x => x is AbsoluteLayout); if (!string.IsNullOrEmpty(imagePath.Path.ToString())) { int ctr1 = 0; foreach (AbsoluteLayout abl in looper) { var loopers = abl.Children.Where(x => x is Frame).FirstOrDefault() as Frame; var btnloopers = abl.Children.Where(x => x is ImageButton).FirstOrDefault() as ImageButton; CachedImage sample = loopers.Content as CachedImage; if (sample.Source.ToString().Contains("dashed_border.png")) { //sample.Source = imagePath.Path.ToString(); //sample.Aspect = Aspect.AspectFill; var sample2 = await fireStorage.StoreImages(imagePath.GetStream(), (Application.Current.Properties["Id"].ToString().Replace("\"", "") + "_" + counter.ToString()) + DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_fff")); imageUrl = sample2; var isSaved = await saveToGallery(); if (isSaved) { var isRetrieved = await api.retrieveGallery(); if (isRetrieved) { loadFromSqlite(true); } } //savetoSqlite(); //if (ctr1 != 0) // btnloopers.IsVisible = true; break; } ctr1++; } } imagePicker.SelectedIndex = -1; } catch (Exception ex) { await DisplayAlert("Connection Error", ex.ToString(), "Okay"); } }