partial void deletePicture(Foundation.NSObject sender) { if (item.imageKey != null) { string key = item.imageKey; BNRImageStore.deleteImageForKey(key); imageView.Image = null; item.imageKey = null; } }
public void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info) { string oldKey = item.imageKey; // Did the item already have an image? if (oldKey != null) { // Delete the old image BNRImageStore.deleteImageForKey(oldKey); BNRImageStore.deleteImageForKey(oldKey + ".thumbnail"); } // Get the picked picture from the event args UIImage image = info.ObjectForKey(UIImagePickerController.OriginalImage) as UIImage; // item.getThumbnailFromImage(image); // For Archive method of saving // Get thumbnail // For SQL saving UIImage thumbnailImage = item.getThumbnailFromImage(image); // For SQL saving // Create a GUID string - it iknows how to create unique identifier strings string key = Guid.NewGuid().ToString(); item.imageKey = key; BNRItemStore.updateDBItem(item); string thumbKey = key + ".thumbnail"; // For SQL saving // Store image and thumbnail in the BNRIMmageStore with this key BNRImageStore.setImage(image, item.imageKey); BNRImageStore.setImage(thumbnailImage, thumbKey); // Put that image onto the screen in our image view imageView.Image = image; // Take the image picker off the screen - // You must call this dismiss method //this.DismissViewController(true, null); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { // if on the phone, the image picker os presented modally. Dismiss it. this.DismissViewController(true, null); } else if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) && UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { this.DismissViewController(true, null); } else { // If on the iPad, the image picker is in the popover. Dismiss the popover. imagePickerPopover.Dismiss(true); imagePickerPopover = null; } }
public static void RemoveItem(BNRItem p) { string key = p.imageKey; if (key != null) { BNRImageStore.deleteImageForKey(key); BNRImageStore.deleteImageForKey(key + ".thumbnail"); } allItems.Remove(p); string dbPath = GetDBPath(); SQLiteConnection db; db = new SQLiteConnection(dbPath); db.Delete(p); db.Close(); }