void tk_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(e.ChosenPhoto); s.SetMainTexture(bitmap); }
internal async void AttachImage(Microsoft.Phone.Tasks.PhotoResult e) { this.IsRunning = true; try { List <ImgurUploader.DataUploadItem> items = new List <ImgurUploader.DataUploadItem>(); items.Add(new ImgurUploader.DataUploadItem(e)); var request = ImgurUploader.ImgurUploadRequest.CreateUploadRequest(items, ImgurUploader.ImgurLinkType.Normal); var response = await request.UploadAsync(); var result = response.CreateResult(); if (result.ToClipboard()) { Notification.Show("Image link copied to clipboard.", "Success!"); } else { Notification.ShowError("Image upload failed.", "Error"); } } catch (Exception ex) { AwfulDebugger.AddLog(this, AwfulDebugger.Level.Critical, ex); Notification.ShowError("Image upload failed.", "Error"); } this.IsRunning = false; }
void t_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (store.FileExists("mybg.jpg")) { store.DeleteFile("mybg.jpg"); } using (var stream = new IsolatedStorageFileStream("mybg.jpg", FileMode.OpenOrCreate, store)) { e.ChosenPhoto.CopyTo(stream); } } } else { this.Dispatcher.BeginInvoke(() => { MessageBox.Show("Oops, looks like your phone is syncing. Disconnect it and try again."); }); } }
void t_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) { System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(480, 800); BitmapImage bimg = new BitmapImage(); bimg.SetSource(e.ChosenPhoto); Image img = new Image(); img.Width = 480; img.Height = 800; img.Source = bimg; img.Stretch = Stretch.UniformToFill; wb.Render(img, null); wb.Invalidate(); using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var st = new IsolatedStorageFileStream("slideshow_" + (DateTime.Now.Day.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + DateTime.Now.Hour.ToString()) + ".jpg", FileMode.Create, FileAccess.Write, store)) { System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, st, 480, 800, 0, 100); } } updateList(); } else { MessageBox.Show("It looks like your phone is syncing; couldn't open the chooser."); } }
void t_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) { var req = HttpWebRequest.Create(new Uri("http://windowsphonehacker.com/splashes/bmp.php", UriKind.Absolute)); req.Method = "POST"; var boundary = "-----------------------------28520690214962"; var newLine = Environment.NewLine; var fileHeaderFormat = boundary + newLine + "Content-Disposition: form-data; name=\"fileu\"; filename=\"bg.jpg\"" + newLine + "Content-Type: image/jpeg" + newLine + newLine; req.ContentType = "application/octet-stream"; req.BeginGetRequestStream(callback => { Stream poststream = req.EndGetRequestStream(callback); var reqWriter = new StreamWriter(poststream); byte[] buf = new byte[e.ChosenPhoto.Length]; e.ChosenPhoto.Position = 0; e.ChosenPhoto.Read(buf, 0, (Int32)e.ChosenPhoto.Length); string data = Convert.ToBase64String(buf); //reqWriter.Write(fileHeaderFormat); reqWriter.Write(data); reqWriter.Close(); //poststream.Close(); req.BeginGetResponse(rep => { WebResponse reply = req.EndGetResponse(rep); Stream str = reply.GetResponseStream(); //StreamReader reader = new StreamReader(str); //System.Diagnostics.Debug.WriteLine(reader.ReadToEnd()); this.Dispatcher.BeginInvoke(() => { string id = "custom__" + DateTime.Now.Millisecond.ToString(); using (var store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()) { using (var stream = store.OpenFile(id, System.IO.FileMode.Create)) { str.CopyTo(stream); } } setBackground(id); MessageBox.Show("Successfully set background."); }); }, null); }, null); } }
private void photoChooser_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) { // Load the file into the image control BitmapImage image = new BitmapImage(); image.SetSource(e.ChosenPhoto); _imageControl.Source = image; e.ChosenPhoto.Seek(0, SeekOrigin.Begin); // Now upload the file to the server immediately UploadFile(e.ChosenPhoto); } }
void phcht_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e) { try { if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK && e.ChosenPhoto != null) { albumArt.Source = null; albumArt.Source = Microsoft.Phone.PictureDecoder.DecodeJpeg(e.ChosenPhoto); e.ChosenPhoto.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Code to execute when photo is selected from media library or a photo is taken using camera to add attachment to ListItem /// </summary> public override void OnPhotoSelectionCompleted(object sender, Microsoft.Phone.Tasks.PhotoResult e) { base.OnPhotoSelectionCompleted(sender, e); }