public override void ViewDidLoad () { base.ViewDidLoad (); // only show save button in toolbar when adding a new note if (SaveMode == NoteSaveMode.Insert) { var items = new UIBarButtonItem[] { toolbar.Items[0] }; toolbar.SetItems (items, false); } saveButton.Clicked += delegate { if (Note != null) { Note.Title = titleTextField.Text; Note.Body = bodyTextView.Text; if (SaveMode == NoteSaveMode.Insert) { NotesCoordinator.Coordinator.AddNote (Note); this.DismissModalViewControllerAnimated (true); } else { NotesCoordinator.Coordinator.UpdateNote (Note); } } else { var alert = new UIAlertView ("", "Please select a note", null, "OK"); alert.Show (); } }; addButton.Clicked += delegate { var addNoteController = new NoteDetailControllerIPad { Note = new Note (), SaveMode = NoteSaveMode.Insert, ModalPresentationStyle = UIModalPresentationStyle.FormSheet }; this.PresentModalViewController (addNoteController, true); }; setColorButton.Clicked += delegate { if(_colorSelectionController == null) _colorSelectionController = new ColorSelectionController (); if(_colorSelectionPopover == null) { _colorSelectionPopover = new UIPopoverController (_colorSelectionController); _colorSelectionController.Popover = _colorSelectionPopover; } _colorSelectionPopover.PresentFromBarButtonItem (setColorButton, UIPopoverArrowDirection.Any, true); }; NotesCoordinator.Coordinator.NoteSaved += delegate { Note = null; }; NotesCoordinator.Coordinator.NoteDeleted += delegate { Note = null; }; }
public override void ViewDidLoad() { base.ViewDidLoad(); // only show save button in toolbar when adding a new note if (SaveMode == NoteSaveMode.Insert) { var items = new UIBarButtonItem[] { toolbar.Items[0] }; toolbar.SetItems(items, false); } saveButton.Clicked += delegate { if (Note != null) { Note.Title = titleTextField.Text; Note.Body = bodyTextView.Text; if (SaveMode == NoteSaveMode.Insert) { NotesCoordinator.Coordinator.AddNote(Note); this.DismissModalViewControllerAnimated(true); } else { NotesCoordinator.Coordinator.UpdateNote(Note); } } else { var alert = new UIAlertView("", "Please select a note", null, "OK"); alert.Show(); } }; addButton.Clicked += delegate { var addNoteController = new NoteDetailControllerIPad { Note = new Note(), SaveMode = NoteSaveMode.Insert, ModalPresentationStyle = UIModalPresentationStyle.FormSheet }; this.PresentModalViewController(addNoteController, true); }; setColorButton.Clicked += delegate { if (_colorSelectionController == null) { _colorSelectionController = new ColorSelectionController(); } if (_colorSelectionPopover == null) { _colorSelectionPopover = new UIPopoverController(_colorSelectionController); _colorSelectionController.Popover = _colorSelectionPopover; } _colorSelectionPopover.PresentFromBarButtonItem(setColorButton, UIPopoverArrowDirection.Any, true); }; NotesCoordinator.Coordinator.NoteSaved += delegate { Note = null; }; NotesCoordinator.Coordinator.NoteDeleted += delegate { Note = null; }; }