public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (indexPath.Section == 0) { foreach (UITableViewCell c in tableView.VisibleCells) { c.Accessory = UITableViewCellAccessory.None; } UITableViewCell cell = tableView.CellAt(indexPath); if (cell != null) { cell.Accessory = UITableViewCellAccessory.Checkmark; } var at = BNRItemStore.allAssetTypes[indexPath.Row]; item.assetType = at.assetType; BNRItemStore.updateDBItem(item); // if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { // Bronze, asset type picker popover for iPad // controller.updateAssetType(); // Bronze // popoverController.Dismiss(true); // Bronze // popoverController = null; // Bronze // } else { // Bronze this.NavigationController.PopViewController(true); // } // Bronze } }
public DetailViewController(bool isNew) : base("DetailViewController", null) { if (isNew) { UIBarButtonItem doneItem = new UIBarButtonItem(UIBarButtonSystemItem.Done); this.NavigationItem.RightBarButtonItem = doneItem; doneItem.Clicked += (sender, e) => { this.PresentingViewController.DismissViewController(true, null); var vcs = this.PresentingViewController.ChildViewControllers; var ivc = vcs[0] as ItemsViewController; ivc.TableView.ReloadData(); Console.WriteLine("allItems: {0}, tableViewRows: {1}", BNRItemStore.allItems.Count, ivc.TableView.NumberOfRowsInSection(0)); }; UIBarButtonItem cancelItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel); this.NavigationItem.LeftBarButtonItem = cancelItem; cancelItem.Clicked += (sender, e) => { // If the user cancelled, then remove the BNRItem from the store BNRItemStore.RemoveItem(Item); this.PresentingViewController.DismissViewController(true, null); var vcs = this.PresentingViewController.ChildViewControllers; var ivc = vcs[0] as ItemsViewController; ivc.TableView.ReloadData(); Console.WriteLine("allItems: {0}, tableViewRows: {1}", BNRItemStore.allItems.Count, ivc.TableView.NumberOfRowsInSection(0)); }; } }
public void addNewItem(object sender, EventArgs e) { UIAlertView alert = new UIAlertView( NSBundle.MainBundle.LocalizedString("Create an Asset Type", "Create Asset Type"), NSBundle.MainBundle.LocalizedString("Please enter a new asset type", "Please Enter"), null, NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"), new string[] { NSBundle.MainBundle.LocalizedString("Done", "Done") }); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; UITextField alerttextField = alert.GetTextField(0); alerttextField.KeyboardType = UIKeyboardType.Default; alerttextField.Placeholder = NSBundle.MainBundle.LocalizedString("Enter a new asset type", "Enter New"); alert.Show(); // Use for silver challenge alert.Clicked += (object avSender, UIButtonEventArgs ave) => { if (ave.ButtonIndex == 1) { Console.WriteLine("Entered: {0}", alert.GetTextField(0).Text); BNRItemStore.addAssetType(alert.GetTextField(0).Text); TableView.ReloadData(); NSIndexPath ip = NSIndexPath.FromRowSection(BNRItemStore.allAssetTypes.Count - 1, 0); this.RowSelected(TableView, ip); } else { this.NavigationController.PopViewController(true); } }; }
void addNewItem(object sender, EventArgs e) { Console.WriteLine("BtnAdd pressed"); BNRItem newItem = BNRItemStore.CreateItem(); // int lastRow = BNRItemStore.allItems.IndexOf(newItem); // // NSIndexPath ip = NSIndexPath.FromRowSection(lastRow, 0); // // NSIndexPath[] indexPaths = new NSIndexPath[] {ip}; // TableView.InsertRows(indexPaths, UITableViewRowAnimation.Automatic); DetailViewController detailViewController = new DetailViewController(true); detailViewController.EdgesForExtendedLayout = UIRectEdge.None; detailViewController.Item = newItem; UINavigationController navController = new UINavigationController(detailViewController); navController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; navController.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; this.PresentViewController(navController, true, null); Console.WriteLine("allItems: {0}, tableViewRows: {1}", BNRItemStore.allItems.Count, TableView.NumberOfRowsInSection(0)); }
public override void MoveRow(UITableView tableView, NSIndexPath fromIndexPath, NSIndexPath toIndexPath) { BNRItemStore.moveItem(fromIndexPath.Row, toIndexPath.Row); foreach (BNRItem i in BNRItemStore.allItems) { Console.WriteLine("ordering value for item {0} = {1}", BNRItemStore.allItems.IndexOf(i), i.orderingValue); } }
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 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 override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); // Clear first responder this.View.EndEditing(true); // "Save" changes to item item.itemName = nameField.Text; item.serialNumber = serialNumberField.Text; item.valueInDollars = Convert.ToInt32(valueField.Text); BNRItemStore.updateDBItem(item); }
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { //base.CommitEditingStyle(tableView, editingStyle, indexPath); if (editingStyle == UITableViewCellEditingStyle.Delete) { UITableViewCell cell = tableView.CellAt(indexPath); if (cell != null) { cell.BackgroundColor = UIColor.White; } BNRItem itemToRemove = BNRItemStore.allItems[indexPath.Row]; BNRItemStore.RemoveItem(itemToRemove); NSIndexPath[] indexPaths = new NSIndexPath[] { indexPath }; TableView.DeleteRows(indexPaths, UITableViewRowAnimation.Automatic); Console.WriteLine("allItems: {0}, tableViewRows: {1}", BNRItemStore.allItems.Count, tableView.NumberOfRowsInSection(0)); } }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. UIImage image = UIImage.FromBundle("tvBgImage.png"); TableView.BackgroundView = new UIImageView(image); BNRItemStore.loadItemsFromDatabase(); NSNotificationCenter nc = NSNotificationCenter.DefaultCenter; nc.AddObserver(this, new Selector("clearImageCache:"), UIApplication.DidReceiveMemoryWarningNotification, null); // HomepwnerItemCell UINib nib = UINib.FromName("HomepwnerItemCell", null); // Register this NIB which contains the cell TableView.RegisterNibForCellReuse(nib, "HomepwnerItemCell"); //TableView.SeparatorInset = new UIEdgeInsets(0, 0, 0, 0); }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); // Clear first responder this.View.EndEditing(true); if (dateField.IsFirstResponder) { dateField.ResignFirstResponder(); } // "Save" changes to item item.itemName = nameField.Text; item.serialNumber = serialNumberField.Text; item.valueInDollars = Convert.ToInt32(valueField.Text); BNRItemStore.updateDBItem(item); if (this.PresentingViewController != null) { var vcs = this.PresentingViewController.ChildViewControllers; var ivc = vcs[0] as ItemsViewController; ivc.TableView.ReloadData(); } }