public async void CameraButton_Clicked(Image image, Grid grid, int colum, int row)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsTakePhotoSupported && !CrossMedia.Current.IsPickPhotoSupported)
            {
                await DisplayAlert("Alerta!", "Captura e seleção de foto não suportada", "ok");
            }
            else
            {
                StoreCameraMediaOptions store = new StoreCameraMediaOptions
                {
                    Directory          = "Images",
                    Name               = DateTime.Now + "_.jpg",
                    CompressionQuality = 30
                };

                var file = await CrossMedia.Current.TakePhotoAsync(store);

                if (file == null)
                {
                    return;
                }
                //await DisplayAlert("File Path", file.Path, "Ok");
                image.Source = ImageSource.FromStream(() => { return(file.GetStream()); });
                grid.Children.Add(image, colum, row);

                var stream = file.GetStream();
                var bytes  = new byte[stream.Length];
                await stream.ReadAsync(bytes, 0, (int)stream.Length);

                string base64 = System.Convert.ToBase64String(bytes);
                Puma.ModelosBanco.FotosItem foto = new Puma.ModelosBanco.FotosItem();
                foto.Idrelatorio   = this.itemSubItem.RelatoriosId;
                foto.Idsetor       = this.itemSubItem.Idsetor;
                foto.Idsubitem     = this.itemSubItem.Idsubitem;
                foto.Iditemsubitem = this.itemSubItem.Id;
                if (grid == GridFotosBomba)
                {
                    foto.Name = "GridFotosBomba";
                }
                if (grid == GridFotosBfe)
                {
                    foto.Name = "GridFotosBfe";
                }
                if (grid == GridFotosTub)
                {
                    foto.Name = "GridFotosTub";
                }
                if (grid == GridFotosReg)
                {
                    foto.Name = "GridFotosReg";
                }

                foto.Base64 = base64;
                this.FotosItem.Add(foto);
            }
        }
示例#2
0
 public void RemoverUltimaFotoReg(object sender, EventArgs e)
 {
     manipulacao.RemovePicture(GridFotosReg);
     if (this.FotosItem.Count > 0)
     {
         Puma.ModelosBanco.FotosItem foto = this.FotosItem[this.FotosItem.Count - 1];
         this.FotosItem.RemoveAt(this.FotosItem.Count - 1);
         this.DeleteFotosItem.Add(foto);
         this.ChangeForSave();
     }
 }