// >> rte-insert-images-pick-image-implementation private async void OnPickImage(object sender, PickImageEventArgs eventArgs) { var mediaPlugin = CrossMedia.Current; if (mediaPlugin.IsPickPhotoSupported) { if (!await PermissionsHelper.RequestPhotosAccess()) { return; } if (!await PermissionsHelper.RequestStorrageAccess()) { return; } var mediaFile = await mediaPlugin.PickPhotoAsync(); if (mediaFile != null) { var imageSource = RichTextImageSource.FromFile(mediaFile.Path); eventArgs.Accept(imageSource); return; } } // << rte-insert-images-pick-image-implementation }
public CustomImagePickerViewModel() { var resourceService = DependencyService.Get <IResourceService>(); this.RecipientsItemSource = new List <string> { "BrandonPeterson", "VacationWander", "Joshua Price", "Reuben Holmes", "Eva Lawson", "Rory Baxter", "David Webb", "Howard Pittman", }; this.Source = RichTextSource.FromStream(() => resourceService.GetResourceStream("pick-image-demo.html")); //this.EmojiSource = this.EmojiSource = resourceService .GetResourceNamesFromFolder("Emojis") .OrderBy(resourceName => resourceName) .Select(resourceName => RichTextImageSource.FromStream(() => resourceService.GetResourceStream(resourceName), RichTextImageType.Png)) .ToList(); this.SendEmailCommand = new Command(SendEmail); }
// >> rte-custom-image-picker-add-images-to-picker-toolbar-item private void InitializeImages() { var resourceNames = this.currentAssembly.GetManifestResourceNames(); var imageSources = new List <RichTextImageSource>(); foreach (var resourceName in resourceNames) { if (resourceName.Contains("emoji")) { var imageSource = RichTextImageSource.FromStream(() => this.currentAssembly.GetManifestResourceStream(resourceName), RichTextImageType.Png); imageSources.Add(imageSource); } } this.imagePicker.ItemsSource = imageSources; }