forked from stormlion227/ImageCropper.Forms
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathImageCropperImplementation.cs
More file actions
54 lines (47 loc) · 1.85 KB
/
ImageCropperImplementation.cs
File metadata and controls
54 lines (47 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Com.Theartofdev.Edmodo.Cropper;
using System.Diagnostics;
using System;
using System.Collections.Generic;
namespace Stormlion.ImageCropper.Droid
{
public class ImageCropperImplementation : IImageCropperWrapper
{
public void ShowFromFile(ImageCropper imageCropper, List<ImageProperties> imagesCroppingList)
{
try
{
CropImage.ActivityBuilder activityBuilder;
foreach (var imageFile in imagesCroppingList)
{
activityBuilder = CropImage.Activity(Android.Net.Uri.FromFile(new Java.IO.File(imageFile.ImagePath)));
if (imageCropper.CropShape == ImageCropper.CropShapeType.Oval)
{
activityBuilder.SetCropShape(CropImageView.CropShape.Oval);
}
else
{
activityBuilder.SetCropShape(CropImageView.CropShape.Rectangle);
}
if (imageCropper.AspectRatioX > 0 && imageCropper.AspectRatioY > 0)
{
activityBuilder.SetFixAspectRatio(true);
activityBuilder.SetAspectRatio(imageCropper.AspectRatioX, imageCropper.AspectRatioY);
}
else
{
activityBuilder.SetFixAspectRatio(false);
}
if (!string.IsNullOrWhiteSpace(imageCropper.PageTitle))
{
activityBuilder.SetActivityTitle(imageCropper.PageTitle);
}
activityBuilder.Start(Xamarin.Essentials.Platform.CurrentActivity);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
}
}