public void nudgeItemValue(HomepwnerItemCell cell, double stepperValue)
        {
            NSIndexPath indexPath = TableView.IndexPathForCell(cell);
            BNRItem     i         = BNRItemStore.allItems[indexPath.Row];

            i.valueInDollars = (int)stepperValue;
            BNRItemStore.updateDBItem(i);
            TableView.ReloadData();
        }
        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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 public void nudgeItemValue(HomepwnerItemCell cell, double stepperValue)
 {
     NSIndexPath indexPath = TableView.IndexPathForCell(cell);
     BNRItem i = BNRItemStore.allItems[indexPath.Row];
     i.valueInDollars = (int)stepperValue;
     BNRItemStore.updateDBItem(i);
     TableView.ReloadData();
 }
        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);
        }