You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using ImageCropper.Forms for cropping the image selected from the camera and gallery. I have 3 options for changing a profile picture; Take Photo, Upload from Gallery and Select Avatar. So for showing the Media options I am using a DisplayActionSheet like below:
var actionSheet = await DisplayActionSheet(null,"Cancel", null, "Take Photo", "Upload from Gallery", "Select Avatar");
if (actionSheet == "Take Photo")
{
OpenCamera();
}
else if(actionSheet == "Upload from Gallery")
{
Opengallery();
}
else if(actionSheet == "Select Avatar")
{
OpenAvatar();
}
OpenCamera() and Opengallery() are added below. That code is also asking the Take Photo and Photo Library options again as a popup. I don't need that pop up, is there any way to remove the second popup asked by ImageCropper.Forms and load the camera or gallery directly?
My Code:
async void OpenCamera()
{
try
{
await CrossMedia.Current.Initialize();
//I need to open camera only here, no need of a pop up again.
new ImageCropper()
{
PageTitle = "Test Title",
AspectRatioX = 1,
AspectRatioY = 1,
CropShape = ImageCropper.CropShapeType.Rectangle,
SelectSourceTitle = "Select source",
TakePhotoTitle = "Take Photo",
PhotoLibraryTitle = "Photo Library",
Success = (imageFile) =>
{
Device.BeginInvokeOnMainThread(() =>
{
profilephoto.Source = ImageSource.FromFile(imageFile);
});
}
}.Show(this);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("CameraException:>" + ex);
}
}
async void Opengallery()
{
try
{
await CrossMedia.Current.Initialize();
//I need to open gallery only here, no need of a pop up again.
new ImageCropper()
{
PageTitle = "Test Title",
AspectRatioX = 1,
AspectRatioY = 1,
CropShape = ImageCropper.CropShapeType.Rectangle,
SelectSourceTitle = "Select source",
TakePhotoTitle = "Take Photo",
PhotoLibraryTitle = "Photo Library",
Success = (imageFile) =>
{
Device.BeginInvokeOnMainThread(() =>
{
profilephoto.Source = ImageSource.FromFile(imageFile);
//var stream = ImageSource.FromFile(imageFile);
//imagefile = imageFile;
});
}
}.Show(this);
}
}
I am using ImageCropper.Forms for cropping the image selected from the camera and gallery. I have 3 options for changing a profile picture; Take Photo, Upload from Gallery and Select Avatar. So for showing the Media options I am using a
DisplayActionSheet
like below:OpenCamera() and Opengallery() are added below. That code is also asking the
Take Photo
andPhoto Library
options again as a popup. I don't need that pop up, is there any way to remove the second popup asked byImageCropper.Forms
and load the camera or gallery directly?My Code:
Screenshot: https://i.stack.imgur.com/qYBuu.jpg
Is there any way to separate camera and gallery code like MediaPlugin?
The text was updated successfully, but these errors were encountered: