我正在使用ELCImagepicker.dll创建具有多个图像选择的图库。一切都很好。
1-我想在用户选择时更改Tick的图标。这是一种非常古老的风格 2-更改最大选择的验证消息。我想使用"选择"而不是"发送"。
这是MediaService文件。 maxImage
设置最大图片验证
public class MediaService : IMediaService
{
public async Task OpenGallery(int maxImage)
{
var picker = ELCImagePickerViewController.Create(maxImage);
picker.MaximumImagesCount = maxImage;
var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (topController.PresentedViewController != null)
{
topController = topController.PresentedViewController;
}
topController.PresentViewController(picker, true, null);
List<string> images = new List<string>();
await picker.Completion.ContinueWith(t =>
{
picker.BeginInvokeOnMainThread(() =>
{
//dismiss the picker
picker.DismissViewController(true, null);
if (t.IsCanceled || t.Exception != null)
{
}
else
{
//List<string> images = new List<string>();
var items = t.Result as List<AssetResult>;
foreach (var item in items)
{
var path = Save(item.Image, item.Name);
images.Add(path);
//CleanPath(path);
}
}
});
});
MessagingCenter.Send<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelected", images);
}
string Save(UIImage image, string name)
{
var documentsDirectory = Environment.GetFolderPath
(Environment.SpecialFolder.Personal);
string jpgFilename = System.IO.Path.Combine(documentsDirectory, name); // hardcoded filename, overwritten each time
NSData imgData = image.AsJPEG();
NSError err = null;
if (imgData.Save(jpgFilename, false, out err))
{
return jpgFilename;
}
else
{
Console.WriteLine("NOT saved as " + jpgFilename + " because" + err.LocalizedDescription);
return null;
}
}
void IMediaService.ClearFiles(List<string> filePaths)
{
var documentsDirectory = Environment.GetFolderPath
(Environment.SpecialFolder.Personal);
if (Directory.Exists(documentsDirectory))
{
foreach (var p in filePaths)
{
File.Delete(p);
}
}
}
}