/// <summary> /// Ask the edit form to display itself to enter new record values /// </summary> /// <param name="sender"> /// A <see cref="NSButton"/> /// </param> partial void add (NSButton sender) { // setup the edit sheet controller if one hasn't been setup already if (myEditController == null) myEditController = new EditController(); // ask our edit sheet for information on the record we want to add NSMutableDictionary newValues = myEditController.edit(null, this); if (!myEditController.Cancelled) { // add the new entry myContentArray.AddObject(newValues); } }
// // Inspect our selected objects (user double-clicked them). // // Note: this method will not get called until you make all columns in the table // as "non-editable". So long as they are editable, double clicking a row will // cause the current cell to be editied. // partial void inspect (NSArray sender) { NSArray selectedObjects = sender; Console.WriteLine("inspect"); int index; uint numItems = (uint)selectedObjects.Count; for (index = 0; index < numItems; index++) { NSDictionary objectDict = selectedObjects.GetItem<NSDictionary> (0); if (objectDict != null) { Console.WriteLine(string.Format("inspector item: [ {0} {1}, {2} ]", (NSString)objectDict[FIRST_NAME].ToString(), (NSString)objectDict[LAST_NAME].ToString(), (NSString)objectDict[PHONE].ToString())); } // setup the edit sheet controller if one hasn't been setup already if (myEditController == null) myEditController = new EditController(); // remember which selection index we are changing nint savedSelectionIndex = (nint)myContentArray.SelectionIndex; NSDictionary editItem = selectedObjects.GetItem<NSDictionary> (0); // get the current selected object and start the edit sheet NSMutableDictionary newValues = myEditController.edit(editItem, this); if (!myEditController.Cancelled) { // remove the current selection and replace it with the newly edited one var currentObjects = myContentArray.SelectedObjects; myContentArray.Remove(currentObjects); // make sure to add the new entry at the same selection location as before myContentArray.Insert(newValues,savedSelectionIndex); } } }