コード例 #1
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            nameField.Text          = item.itemName;
            serialNumberField.Text  = item.serialNumber;
            valueField.Text         = item.valueInDollars.ToString();
            valueField.KeyboardType = UIKeyboardType.NumberPad;
            dateField.Text          = item.dateCreated.ToShortDateString();

            string imageKey = item.imageKey;

            if (imageKey != null)
            {
                // Get image for image key from image store
                UIImage imageToDisplay = BNRImageStore.imageForKey(imageKey);

                // Use that image to put on the screen in imageView
                imageView.Image = imageToDisplay;
            }
            else
            {
                // Clear the imageView
                imageView.Image = null;
            }
            assetTypeBtn.SetTitle(
                NSBundle.MainBundle.LocalizedString(((item.assetType == "" || item.assetType == null) ? "None" : item.assetType), "Asset Type"),
                UIControlState.Normal);
        }
コード例 #2
0
 partial void deletePicture(Foundation.NSObject sender)
 {
     if (item.imageKey != null)
     {
         string key = item.imageKey;
         BNRImageStore.deleteImageForKey(key);
         imageView.Image = null;
         item.imageKey   = null;
     }
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        public void showImageAtIndexPath(NSObject sender, HomepwnerItemCell cell)
        {
            NSIndexPath indexPath = TableView.IndexPathForCell(cell);

            Console.WriteLine("Going to show the image for {0}", indexPath);

            // Get the item for the index path
            BNRItem i = BNRItemStore.allItems[indexPath.Row];

            string imageKey = i.imageKey;

            // If there is no image, we don't need to do anything
            if (imageKey == null || imageKey == "")
            {
                return;
            }

            UIImage img = BNRImageStore.imageForKey(imageKey);

            // Create a new ImageViewController and set its image
            ImageViewController ivc = new ImageViewController();

            ivc.Image       = img;
            ivc.PopoverSize = new CGSize(600, 600);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                // Make a rectangle that the frame of the button relative to our table view
                UIButton btn  = sender as UIButton;
                CGRect   rect = View.ConvertRectFromView(btn.Bounds, btn);

                // Present a 600 x 600 popover from the rect
                imagePopover = new UIPopoverController(ivc);
                imagePopover.PopoverContentSize = ivc.PopoverSize;

                imagePopover.DidDismiss += (object pSender, EventArgs e) => {
                    imagePopover.Dismiss(true);
                    imagePopover = null;
                };

                imagePopover.PresentFromRect(rect, View, UIPopoverArrowDirection.Any, true);
            }
            else
            {
                this.NavigationController.PushViewController(ivc, true);
            }
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            Console.WriteLine("********* {0}", indexPath.ToString());

            // Check for a reusable cell first, use that if it exists - before using nib
//			UITableViewCell cell = tableView.DequeueReusableCell("UITableViewCell");
//
//			if (cell == null)
//				// Create an instance of UITableViewCell, with default appearance
//				cell = new UITableViewCell(UITableViewCellStyle.Subtitle,"UITableViewCell");

            // Set the text on the cell with the description of the item
            // that is the nth index of items, where n = row this cell
            // will appear in on the tableView
            BNRItem p = BNRItemStore.allItems[indexPath.Row];

//			cell.TextLabel.Text = String.Format("Item: {0}, ${1}", p.itemName, p.valueInDollars);
//			cell.DetailTextLabel.Text = String.Format("SN: {0}, Added: {1}", p.serialNumber, p.dateCreated);
//			cell.BackgroundColor = UIColor.FromRGBA(1.0f, 1.0f, 1.0f, 0.5f);

            HomepwnerItemCell cell = tableView.DequeueReusableCell("HomepwnerItemCell") as HomepwnerItemCell;

            if (cell.nudgeValueCallback == null)
            {
                cell.nudgeValueCallback = nudgeItemValue;
                cell.showImageCallback  = showImageAtIndexPath;
            }

            // Configure the cell
            cell.nameLabel.Text         = p.itemName;
            cell.serialNumberLabel.Text = p.serialNumber;
            string currencySymbol = NSLocale.CurrentLocale.CurrencySymbol;

            cell.valueLabel.Text = String.Format("{0}{1}", currencySymbol, p.valueInDollars);
            if (p.valueInDollars < 0)
            {
                cell.valueLabel.TextColor = UIColor.Red;
            }
            else
            {
                cell.valueLabel.TextColor = UIColor.Black;
            }
            cell.stepper.MaximumValue = p.valueInDollars + 500;
            cell.stepper.MinimumValue = p.valueInDollars - 500;
            cell.stepper.Value        = p.valueInDollars;

            string thumbKey = p.imageKey + ".thumbnail";             // Changed from archiving method of saving for SQL method

            // If there is no image, we don;t need to do anything // For archiving method of saving
            UIImage img = BNRImageStore.imageForKey(thumbKey);             // Changed from archiving method of saving for SQL method

//			if (img == null) // For archiving method of saving
//				return; // For archiving method of saving

            cell.thumbnailView.Image = img;

//			cell.thumbnailView.Image = p.Thumbnail(); // Archiving method of saving

            cell.testIndexPathCallback = (ip) => {
                Console.WriteLine("Callback: {0}", ip.ToString());
            };
            cell.DoCallback(indexPath);

            return(cell);
        }
コード例 #7
0
 public void ClearImageCache(NSNotification note)
 {
     Console.WriteLine("Low Memory warning: {0}", note.ToString());
     BNRImageStore.clearCache();
 }