public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            base.FinishedLaunching (app, options);
            
            _splitController = new UISplitViewController ();         
            _notesController = new NotesTableControllerIPad ();
            _noteDetailController = new NoteDetailControllerIPad ();
            
            _splitDelegate = new NoteDetailControllerIPad.SplitDelegate (_noteDetailController);
            _splitController.Delegate = _splitDelegate;

            _splitController.ViewControllers = new UIViewController[] { _notesController, _noteDetailController };
            
            window.AddSubview (_splitController.View);
            
            window.MakeKeyAndVisible ();
            
            return true;
        }
예제 #2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            base.FinishedLaunching(app, options);

            _splitController      = new UISplitViewController();
            _notesController      = new NotesTableControllerIPad();
            _noteDetailController = new NoteDetailControllerIPad();

            _splitDelegate            = new NoteDetailControllerIPad.SplitDelegate(_noteDetailController);
            _splitController.Delegate = _splitDelegate;

            _splitController.ViewControllers = new UIViewController[] { _notesController, _noteDetailController };

            window.AddSubview(_splitController.View);

            window.MakeKeyAndVisible();

            return(true);
        }
 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 SplitDelegate (NoteDetailControllerIPad controller)
 {
     _controller = controller;
 }
        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 SplitDelegate(NoteDetailControllerIPad controller)
 {
     _controller = controller;
 }