protected override void OnActivate() { var library = new MediaLibrary(); var photoFromLibrary = library.GetPictureFromToken(FileId); var image = photoFromLibrary.GetImage(); var buffer = LerTudo(image); dadosDaMulta.ExibirImagem(image, true); fileInfo = new HttpUpload.FileInfo { FileName = photoFromLibrary.Name, ContentType = "image/jpeg", Buffer = buffer, ParamName = "multa[foto]" }; dadosDaMulta.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsValid") { NotifyOfPropertyChange("CanShare"); } }; base.OnActivate(); }
public async Task <bool> MultarAsync(CriarMultaNova criarMultaNova, HttpUpload.FileInfo fileInfo) { var httpUpload = new HttpUpload(ObterUrl(urlMaisNovos)); var response = await httpUpload.Upload(fileInfo, criarMultaNova.ObterValores()); return(response.StatusCode == HttpStatusCode.Created); }
public async Task EscolherFoto() { var picker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.PicturesLibrary, ViewMode = PickerViewMode.Thumbnail }; picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".gif"); var storageFile = await picker.PickSingleFileAsync(); if (storageFile == null) { return; } var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read); var streamCloned = stream.CloneStream(); await dadosDaMulta.ExibirImagem(stream, true); fileInfo = new HttpUpload.FileInfo { FileName = storageFile.Name, ContentType = storageFile.ContentType, Buffer = await streamCloned.GetByteFromFileAsync(), ParamName = "multa[foto]" }; }
private async Task ObterImagem() { IRandomAccessStream streamCloned = null; if (ShareOperation.Data.Contains(StandardDataFormats.Bitmap)) { var sharedBitmapRandomAccessStreamReference = await ShareOperation.Data.GetBitmapAsync(); var stream = await sharedBitmapRandomAccessStreamReference.OpenReadAsync(); streamCloned = stream.CloneStream(); fileInfo = new HttpUpload.FileInfo { FileName = ObterNomeAleatorioDeArquivo(stream.ContentType), ContentType = stream.ContentType, Buffer = await stream.GetByteFromFileAsync(), ParamName = "multa[foto]" }; } else if (ShareOperation.Data.Contains(StandardDataFormats.StorageItems)) { var storageItems = await ShareOperation.Data.GetStorageItemsAsync(); var storageFile = (StorageFile)storageItems.FirstOrDefault(); if (storageFile == null) { return; } var stream = await storageFile.OpenReadAsync(); streamCloned = stream.CloneStream(); fileInfo = new HttpUpload.FileInfo { FileName = storageFile.Name, ContentType = stream.ContentType, Buffer = await stream.GetByteFromFileAsync(), ParamName = "multa[foto]" }; } await dadosDaMulta.ExibirImagem(streamCloned); }
public async Task Fotografar() { var dialog = new CameraCaptureUI(); var storageFile = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo); if (storageFile == null) { return; } var stream = await storageFile.OpenReadAsync(); var streamCloned = stream.CloneStream(); await dadosDaMulta.ExibirImagem(streamCloned, true); fileInfo = new HttpUpload.FileInfo { FileName = ObterNomeAleatorioDeArquivo(stream.ContentType), ContentType = stream.ContentType, Buffer = await stream.GetByteFromFileAsync(), ParamName = "multa[foto]" }; }