예제 #1
0
        private async Task SendPicture(NSData imageData)
        {
            await Task.Delay(100);

            if (imageData.Length > 0)
            {
                byte[] myByteArray = new byte[imageData.Length];
                System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteArray, 0, Convert.ToInt32(imageData.Length));

                ViewModel.SendPicture(myByteArray, (string res) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        Toaster.Make(View, Translator.GetText("send_picture_success"));
                        _spinner.Hide();
                    });
                });
            }
        }
예제 #2
0
        public async void OnFinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
        {
            if (e.Info[UIImagePickerController.MediaType].ToString() == "public.image")
            {
                UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage;

                if (originalImage != null)
                {
                    InvokeOnMainThread(() =>
                    {
                        imgPicker.DismissModalViewController(true);
                        _spinner.Display();
                        Toaster.Make(View, Translator.GetText("upload_picture"));
                    });

                    NSData imageData = originalImage.AsJPEG(0.5f);

                    await SendPicture(imageData);
                }
            }
        }