private void Button_Click_1(object sender, RoutedEventArgs e) { // loop over the images in the media library looking for downloaded.jpg. This image comes from the // download method in the SettingsScreen MediaLibrary lib = new MediaLibrary(); Picture attachmentPic = null; foreach (Picture curPic in lib.Pictures) { if (curPic.Name.Equals("downloaded.jpg")) { attachmentPic = curPic; break; } } if (attachmentPic == null) { MessageBox.Show("Please use the settings page to save a test picture before running this API"); return; } // create a new attachment with the resized picture file CBHelperAttachment attachment = new CBHelperAttachment(); attachment.FileName = attachmentPic.Name; WriteableBitmap pic = PictureDecoder.DecodeJpeg(attachmentPic.GetImage()); Stream picStream = new MemoryStream(); pic.SaveJpeg(picStream, 400, 400, 0, 100); picStream.Seek(0, SeekOrigin.Begin); byte[] buffer = new byte[picStream.Length]; picStream.Read(buffer, 0, (int)picStream.Length); attachment.FileData = (byte[])buffer; picStream.Close(); List<CBHelperAttachment> attList = new List<CBHelperAttachment>(); attList.Add(attachment); TestObject newObj = new TestObject(); newObj.FirstName = "Cloud"; newObj.LastName = "Base"; newObj.Title = ".io"; App.helper.InsertDocument("users", newObj, attList, delegate(CBResponseInfo resp) { this.OutputBox.Text = "OUTPUT: " + resp.OutputString; return true; }); }
private void Button_Click_3(object sender, RoutedEventArgs e) { TestObject newObj = new TestObject(); newObj.FirstName = "Cloud"; newObj.LastName = "Base"; newObj.Title = ".io"; if (App.helper != null) { App.helper.InsertDocument("users", newObj, delegate(CBResponseInfo resp) { this.OutputBox.Text = "OUTPUT: " + resp.OutputString; return true; }); } }