示例#1
0
        private void SetImage(int flag, Plugin.Media.Abstractions.MediaFile profileData)
        {
            try
            {
                switch (flag)
                {
                case 1:
                    img1.Source = ImageSource.FromStream(() =>
                    {
                        var stream = profileData.GetStream();

                        //file.Dispose();
                        return(stream);
                    });
                    _file1            = profileData;
                    imageFillCounter1 = 1;
                    break;

                case 2:
                    img2.Source = ImageSource.FromStream(() =>
                    {
                        var stream = profileData.GetStream();

                        //file.Dispose();
                        return(stream);
                    });
                    _file2            = profileData;
                    imageFillCounter2 = 2;
                    break;

                case 3:
                    img3.Source = ImageSource.FromStream(() =>
                    {
                        var stream = profileData.GetStream();

                        //file.Dispose();
                        return(stream);
                    });
                    _file3            = profileData;
                    imageFillCounter3 = 3;
                    break;

                case 4:
                    img4.Source = ImageSource.FromStream(() =>
                    {
                        var stream = profileData.GetStream();

                        //file.Dispose();
                        return(stream);
                    });
                    _file4            = profileData;
                    imageFillCounter4 = 4;
                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
        public async Task OpenPhotoTaker()
        {
            ActivateSpinner();

            var rnd       = new Random();
            var rndEnding = rnd.Next(100, 9999);

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await _userDialoags.AlertAsync("It appears that no camera is available", "No Camera", "OK");

                return;
            }
            var myfile = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Small,        //resizes the photo to 50% of the original
                CompressionQuality = 92,                                               // Int from 0 to 100 to determine image compression level
                DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Front,     // determine which camera to default to
                Directory          = "CC Directors",
                Name        = $"myprofilepic{rndEnding}",
                SaveToAlbum = true,                                                     // this saves the photo to the camera roll
                //if we need the public album path --> var aPpath = file.AlbumPath;
                //if we need a private path --> var path = file.Path;
                AllowCropping = false,
            });

            file = myfile;
            if (file == null)
            {
                DeactivateSpinner();
                return;
            }

            Debug.WriteLine("File Location: " + file.Path + "     <--- here");


            // imageChanged = true;
            setImage = ImageSource.FromStream(() =>
            {
                var stream      = file.GetStream();
                var path        = file.Path;
                var pathprivate = file.AlbumPath;
                Debug.WriteLine(path.ToString());
                Debug.WriteLine(pathprivate.ToString());
                profileimage = file.GetStream();


                //file.Dispose();
                return(stream);
            });

            await DetermineEmotion();



            DeactivateSpinner();
        }
示例#3
0
        public async Task OpenPhotoSelecter()
        {
            ActivateSpinner();

            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await _userDialoags.AlertAsync("Permission was not granted to access camera roll or picking photos is not available on this device.", "Cannot Pick Photo", "OK");

                return;
            }
            var myfile = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
            {
                PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Small,
                CompressionQuality = 92,
            });

            file = myfile;
            if (file == null)
            {
                DeactivateSpinner();
                return;
            }
            string filePath = file.Path;
            string fileType = filePath.Substring(filePath.Length - 4);

            Debug.WriteLine($"****    {fileType}   *****");
            if (fileType == ".jpg" || fileType == ".png" || fileType == ".JPG" || fileType == ".PNG")
            {
                //imageChanged = true;
                setImage = ImageSource.FromStream(() =>
                {
                    var stream      = file.GetStream();
                    var path        = file.Path;
                    var pathprivate = file.AlbumPath;
                    Debug.WriteLine(path);
                    Debug.WriteLine(pathprivate);
                    profileimage = file.GetStream();
                    //file.Dispose();
                    return(stream);
                });
            }
            else
            {
                await _userDialoags.AlertAsync("Unsupported file type.", "Error", "OK");
            }

            await DetermineEmotion();

            DeactivateSpinner();
        }
        public async void TakePhoto_Tapped()
        {
            currcount = 1;
            ClassifierResult_Label.Text = string.Empty;

            Plugin.Media.Abstractions.MediaFile file = null;

            await CrossMedia.Current.Initialize();

            try
            {
                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    await DisplayAlert("No camera found", ":( No camera available.", "Ok");

                    return;
                }

                file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory = "Sample",
                    Name      = "Xamarin.jpg"
                });

                if (file == null)
                {
                    return;
                }

                SelectedImageSource = ImageSource.FromStream(() =>
                {
                    try
                    {
                        var stream = file.GetStream();
                        return(stream);
                    }
                    catch
                    {
                        return(null);
                    }
                });

                ClassifierResult = await Classifier.GetImageTags(file.GetStream());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
示例#5
0
        private async Task GetPhotoLibrary()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    DependencyService.Get <IMessage>().ShortAlert("Gallery Permissions not available.");
                    await Navigation.PopModalAsync();
                }

                Plugin.Media.Abstractions.MediaFile file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    SaveMetaData = true,
                });

                if (file == null)
                {
                    await Navigation.PopModalAsync();
                }
                else
                {
                    Stream stream = file.GetStream();
                    bufferMemory = Logic.GetByteArrayFromString(stream);
                    ProcessPhotoInStream(stream);
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                await Navigation.PopModalAsync();
            }
        }
        private async Task <bool> TakeFoto(string ID)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable ||
                !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ": No camera available", "OK");

                return(false);
            }

            camara = await CrossMedia.Current.TakePhotoAsync(
                new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory   = "Sample",
                RotateImage = true,


                Name = ID + ".jpg"
            });

            if (camara == null)
            {
                return(true);
            }
            await DisplayAlert("File Location", camara.Path, "OK");

            imagen.Source = camara.Path;
            imagen.RotateTo(90);
            camara.GetStream();

            return(false);
        }
        private async void Enviar_Reporte(object sender, EventArgs e)
        {
            if (isFull)
            {
                reporte.foto = Guid.NewGuid().ToString();
                string id = reporte.foto;
                reporte.codigo     = device.codigo;
                reporte.marca      = device.marca;
                reporte.serie      = device.serie;
                reporte.modelo     = device.modelo;
                reporte.producto   = device.nombre;
                reporte.comentario = editor.Text;
                reporte.ID         = id;
                PathFoto           = id;
                bool res = await PostReport(reporte);

                //enviar foto
                if (camara != null)
                {
                    UploadFile(camara.GetStream());
                }

                editor.Text = "";
                if (res)
                {
                    await DisplayAlert("Mensaje", "Reporte subido correctamente", "OK");

                    await Navigation.PopAsync();
                }
            }
            else
            {
                await DisplayAlert("Mensaje", "No se encontro producto para enviar", "OK");
            }
        }
        /// <summary>
        /// Allows the user to pick an image to display for a question
        /// </summary>
        /// <param name="sender"></param>
        /// <returns></returns>
        private async Task PickImageAsync(object sender)
        {
            await CrossMedia.Current.Initialize();

            Plugin.Media.Abstractions.MediaFile file = await CrossMedia.Current.PickPhotoAsync();

            if (file != null) // if the user actually picked an image
            {
                MemoryStream memoryStream = new MemoryStream();
                file.GetStream().CopyTo(memoryStream);

                if (memoryStream.Length < 3000000)
                {
                    ImageButton currentImage;

                    currentImage = ((ImageButton)((StackLayout)((View)sender).Parent).Children[6]);

                    currentImage.Source = file.Path;

                    // Enables the image
                    currentImage.IsVisible = true;
                    if (sender is Button)
                    {
                        ((Button)sender).IsVisible = false;
                    }
                }
                else
                {
                    await this.DisplayAlert("Couldn't use Picture", "Pictures must be under 3 MB", "Back");
                }
                file.Dispose();
            }
        }
示例#9
0
        private async void Foto_nuevop_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable ||
                !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ": No camera available", "OK");

                return;
            }

            f = await CrossMedia.Current.TakePhotoAsync(
                new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory = "Sample",

                Name = nameEntry.Text + ".jpg"
            });

            if (f == null)
            {
                return;
            }
            await DisplayAlert("File Location", f.Path, "OK");

            imagen.Source = f.Path;
            f.GetStream();
        }
示例#10
0
        // photo taken or loaded
        async Task SetNewPhoto(Plugin.Media.Abstractions.MediaFile photo)
        {
            if (photo != null)
            {
                PreviewImage = ImageSource.FromStream(() => { return(photo.GetStream()); });
                OnPropertyChanged("PreviewImage");
                IsPhotoSet = true;
                OnPropertyChanged("IsPhotoSet");

                // update photo properties
                PhotoFilePath = photo.Path;
                PhotoTime     = DateTime.Now;
                var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10));
                PhotoLocation = await Geolocation.GetLocationAsync(request);

                // set current PhotoItem object
                PhotoItemObject = new PhotoItem(PhotoFilePath, PhotoLocation, PhotoTime);
                PhotoItemObject.PhotoPosition = new Position(PhotoLocation.Latitude, PhotoLocation.Longitude);

                // reset category picker
                for (int i = 0; i < AllCategories.Count; i++)
                {
                    AllCategories[i].IsChecked = false;
                }
            }
        }
        async void Button_Clicked_1(System.Object sender, System.EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable ||
                !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ": No camera available", "OK");

                return;
            }

            f = await CrossMedia.Current.TakePhotoAsync(
                new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory   = "Sample",
                RotateImage = false,

                Name = "prueba" + ".jpg"
            });

            if (f == null)
            {
                return;
            }
            await DisplayAlert("File Location", f.Path, "OK");

            image1.Source = f.Path;
            image1.RotateTo(90);
            f.GetStream();
        }
示例#12
0
        //
        // Use this to send multipart form with image
        //
        public async void ReportIssueForm(object sender, EventArgs e)
        {
            var           jsonData  = JsonConvert.SerializeObject(new { userDesc = Description.Text });
            StringContent descData  = new StringContent(Description.Text);
            StreamContent imageData = new StreamContent(imageFile.GetStream());

            MultipartFormDataContent form = new MultipartFormDataContent();

            form.Add(descData, "userDesc");
            form.Add(imageData, "image", "upload.jpg");

            var response = await client.PostAsync("/api/reportIncident/" + globalEq.equipID, form);

            var result = await response.Content.ReadAsStringAsync();

            if (result == "E-mail sent!")
            {
                var ok = DisplayAlert("Success", "The issue has been reported.", "OK");
            }
            else
            {
                var notOk = DisplayAlert("Uh-Oh", "There was an error reporting the issue.", "OK");
            }
            Page x = await Navigation.PopModalAsync();

            //TODO: Figure out how to reload ContentPage after pop
        }
示例#13
0
        private async void GetPicture()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                    return;
                }
                profileData = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });


                if (profileData == null)
                {
                    return;
                }

                imgProfile.Source = ImageSource.FromStream(() =>
                {
                    var stream = profileData.GetStream();

                    //file.Dispose();
                    return(stream);
                });
            }
            catch (Exception ex)
            {
            }
        }
示例#14
0
        private async void GetPicture()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                    return;
                }
                picture_Data = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });


                if (picture_Data == null)
                {
                    return;
                }


                var filename = Path.GetFileName(picture_Data.Path);

                pictureStream             = ReadFully(picture_Data.GetStream());
                lblUPloadbookpicture.Text = filename;
            }
            catch (Exception ex)
            {
            }
        }
示例#15
0
        public string SaveFotoFromAlbum(string caminhoFoto, Plugin.Media.Abstractions.MediaFile file)
        {
            string nomeArquivo;

            if (string.IsNullOrEmpty(caminhoFoto))
            {
                nomeArquivo = String.Format("{0:ddMMyyy_HHmm}", DateTime.Now) + ".jpg";
            }
            else
            {
                File.Delete(DependencyService.Get <IFotoLoadMediaPlugin>().GetPathToPhoto(caminhoFoto));
                nomeArquivo = (caminhoFoto.LastIndexOf("/") > 0) ? caminhoFoto.Substring(caminhoFoto.LastIndexOf("/") + 1) : caminhoFoto;
            }

            var caminhoFotos = DependencyService.Get <IFotoLoadMediaPlugin>().GetDevicePathToPhoto();

            if (!Directory.Exists(caminhoFotos))
            {
                Directory.CreateDirectory(caminhoFotos);
            }

            string caminhoCompleto = Path.Combine(caminhoFotos, nomeArquivo);

            using (FileStream fileStream = new FileStream(caminhoCompleto, FileMode.Create))
            {
                file.GetStream().CopyTo(fileStream);
            }
            return(DependencyService.Get <IFotoLoadMediaPlugin>().SetPathToPhoto(caminhoCompleto));
        }
示例#16
0
        public DocumentConfirm(Plugin.Media.Abstractions.MediaFile _photo, int _type)
        {
            InitializeComponent();

            image = _photo.GetStream();
            photo = _photo;
            type  = _type;
        }
示例#17
0
 private byte[] ConvertStreamToByteArray(Plugin.Media.Abstractions.MediaFile img)
 {
     using (var memoryStream = new MemoryStream())
     {
         img.GetStream().CopyTo(memoryStream);
         img.Dispose();
         return(memoryStream.ToArray());
     }
 }
示例#18
0
        private async void ImageChoose()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                Plugin.Media.Abstractions.MediaFile file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions()
                {
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Medium,
                    CompressionQuality = 80
                });

                if (file == null)
                {
                    return;
                }
                Acr.UserDialogs.UserDialogs.Instance.ShowLoading(AppResource.alertLoading);

                imgProduct.Source = ImageSource.FromStream(() =>
                {
                    Stream img = file.GetStream();
                    return(img);
                });

                Stream stream = file.GetStream();
                byte[] imageData;

                using (MemoryStream ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    imageData = ms.ToArray();
                }

                _imageStream = new MemoryStream(imageData);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                Acr.UserDialogs.UserDialogs.Instance.HideLoading();
            }
        }
示例#19
0
        MemoryStream ConvertToMemoryStream(Plugin.Media.Abstractions.MediaFile stream)
        {
            using (var ms = new MemoryStream())
            {
                var imagestream = stream.GetStream();
                imagestream.CopyTo(ms);

                return(ms);
            }
        }
        public async void PickPhoto_Tapped()
        {
            currcount = 0;
            ClassifierResult_Label.Text = string.Empty;

            Plugin.Media.Abstractions.MediaFile file = null;

            await CrossMedia.Current.Initialize();

            try
            {
                file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });

                if (file == null)
                {
                    return;
                }

                SelectedImageSource = ImageSource.FromStream(() =>
                {
                    try
                    {
                        var stream = file.GetStream();
                        return(stream);
                    }
                    catch
                    {
                        return(null);
                    }
                });

                ClassifierResult = await Classifier.GetImageTags(file.GetStream());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
示例#21
0
        private async Task UpdateProfile()
        {
            List <string> list   = null;
            string        ret    = string.Empty;
            string        base64 = string.Empty;
            ProfileModel  _model = new ProfileModel();
            ProfileModel  model  = null;

            StaticMethods.ShowLoader();
            Task.Factory.StartNew(
                // tasks allow you to use the lambda syntax to pass wor
                () =>
            {
                _model.first_name   = txtFirstName.Text;
                _model.last_name    = txtLastName.Text;
                _model.email        = txtEmail.Text;
                _model.mobile_no    = txtMobileNo.Text;
                _model.description  = txtDescription.Text;
                _model.dob          = txtDob.Text;
                _model.country_name = txtCountry.Text;
                if (profileData != null)
                {
                    var bytearray      = StreamToByte(profileData.GetStream());
                    base64             = Convert.ToBase64String(bytearray);
                    _model.profile_pic = base64;
                }

                model = WebService.UpdateProfile(_model);
            }).ContinueWith(
                t =>
            {
                if (model != null)
                {
                    CrossSecureStorage.Current.SetValue("userId", StaticDataModel.UserId.ToString());
                    CrossSecureStorage.Current.SetValue("profilePic", model.profile_pic.ToString());
                    CrossSecureStorage.Current.SetValue("firstName", model.first_name.ToString());
                    CrossSecureStorage.Current.SetValue("lastName", model.last_name.ToString());
                    CrossSecureStorage.Current.SetValue("userEmail", model.email.ToString());

                    StaticMethods.ShowToast("Profile updated Successfully");

                    profileImage.Source  = Constants.PRO_PIC_IMG_URL + model.profile_pic;
                    App.Current.MainPage = new MainPage();
                }
                else
                {
                    StaticMethods.ShowToast("Something went wrong, please try again later!");
                    _context.ChangeMenu.Execute(_context.ChangeMenu);
                }
                StaticMethods.DismissLoader();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                );
        }
示例#22
0
        private async void CameraButton_Clicked(object sender, EventArgs e)
        {
            Plugin.Media.Abstractions.StoreCameraMediaOptions options = new Plugin.Media.Abstractions.StoreCameraMediaOptions();
            options.SaveToAlbum = true;

            photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(options);

            if (photo != null)
            {
                PhotoImage.Source = ImageSource.FromStream(() => { return(photo.GetStream()); });
            }
        }
示例#23
0
        private async void FromCamera()
        {
            try
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                    return;
                }
                profileData = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });


                if (profileData == null)
                {
                    return;
                }

                imgProfile.Source = ImageSource.FromStream(() =>
                {
                    var stream = profileData.GetStream();

                    //file.Dispose();
                    return(stream);
                });

                var bytearray = StaticMethods.StreamToByte(profileData.GetStream());
                var base64    = Convert.ToBase64String(bytearray);
                var extsn     = Path.GetExtension(profileData.Path);
                var str       = extsn.Split('.');
                extsn = str[1];
                UpdateProfilePic(base64, extsn);
            }
            catch (Exception ex)
            {
            }
        }
示例#24
0
 private byte[] ImageToBytes()
 {
     if (file == null)
     {
         return(null);
     }
     using (var memoryStream = new MemoryStream())
     {
         file.GetStream().CopyTo(memoryStream);
         file.Dispose();
         return(memoryStream.ToArray());
     }
 }
 async Task UseVision(Plugin.Media.Abstractions.MediaFile file)
 {
     try
     {
         var apiRoot = "https://westcentralus.api.cognitive.microsoft.com/vision/v1.0";
         var client  = new VisionServiceClient(key, apiRoot);
         using (var photoStream = file.GetStream())
         {
             text = await client.RecognizeTextAsync(photoStream);
         }
     }
     catch (ClientException e)
     {
         Debug.WriteLine("Error  == " + e.ToString());
     }
 }
示例#26
0
        private async void PickPhoto_Clicked(object sender, EventArgs e)
        {
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await DisplayAlert("No upload", "Picking a photo is not supported.", "Ok");

                return;
            }
            theImage = await CrossMedia.Current.PickPhotoAsync();

            if (theImage == null)
            {
                return;
            }
            MyImage.Source = ImageSource.FromStream(() => theImage.GetStream());
        }
        public async void AddPhoto()
        {
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert("No upload", "Picking a photo is not supported", "Ok");

                return;
            }
            file = await CrossMedia.Current.PickPhotoAsync();

            if (file == null)
            {
                return;
            }
            ImageS = ImageSource.FromStream(() => file.GetStream()).ToString();
        }
        private async void AgregaEmp(object sender, EventArgs e)
        {
            if (nombrEntry.Text != "" && correoEntry.Text != "" && contraEntry.Text != "")
            {
                if (contra2.Text == contraEntry.Text)
                {
                    Usuario user = new Usuario
                    {
                        ID                = identi,
                        nombre            = nombrEntry.Text,
                        contrasena        = contraEntry.Text,
                        apellido_paterno  = apepEntry.Text,
                        apellido_materno  = apemEntry.Text,
                        tipoUsuario       = tipousuario,
                        telefono          = telEntry.Text,
                        correo            = correoEntry.Text,
                        fechaContratacion = DateTime.Now.ToString("dd/MM/yyyy")
                    };
                    try
                    {
                        await App.MobileService.GetTable <Usuario>().InsertAsync(user);

                        if (!(f == null))
                        {
                            UploadFile(f.GetStream());
                        }
                        await DisplayAlert("Agregado", "Usuario agregado correctamente", "Aceptar");

                        await Navigation.PopAsync();
                    }
                    catch (MobileServiceInvalidOperationException ms)
                    {
                        var response = await ms.Response.Content.ReadAsStringAsync();
                        await DisplayAlert("error", response, "Aceptar");
                    }
                }
                else
                {
                    DisplayAlert("Error", "Contraseña no coincide", "Aceptar");
                }
            }
            else
            {
                DisplayAlert("Error", "Faltan campos por Llenar", "Aceptar");
            }
        }
示例#29
0
        private async void AddImage_Clicked(object sender, EventArgs e)
        {
            if (this.BugImage.IsEnabled)
            {
                switch (await this.DisplayActionSheet("Image Options", "Cancel", "Remove", "Change"))
                {
                case "Cancel":
                    return;

                case "Remove":
                    this.BugImage.IsEnabled      = false;
                    this.BugImageFrame.IsEnabled = false;
                    this.BugImageFrame.IsVisible = false;
                    this.ImagePath = null;
                    return;

                case "Change":
                default:
                    break;
                }
            }

            await CrossMedia.Current.Initialize();

            Plugin.Media.Abstractions.MediaFile file = await CrossMedia.Current.PickPhotoAsync();

            if (file != null) // if the user actually picked an image
            {
                MemoryStream memoryStream = new MemoryStream();
                file.GetStream().CopyTo(memoryStream);

                if (memoryStream.Length < 3000000)
                {
                    this.BugImage.IsEnabled      = true;
                    this.BugImageFrame.IsEnabled = true;
                    this.BugImageFrame.IsVisible = true;
                    this.BugImage.Source         = FileImageSource.FromFile(file.Path);
                    this.ImagePath = file.Path;
                }
                else
                {
                    await this.DisplayAlert("Couldn't use Picture", "Pictures must be under 3 MB", "Back");
                }
                file.Dispose();
            }
        }
示例#30
0
        private async void ImageButton_ClickedAsync(object sender, EventArgs e)
        {
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await DisplayAlert("no upload", "picking a photo is not supported", "Ok");

                return;
            }

            file = await CrossMedia.Current.PickPhotoAsync();

            if (file == null)
            {
                return;
            }

            Image.Source = ImageSource.FromStream(() => file.GetStream());
        }