コード例 #1
0
        public async Task AddToCalendar(DateTime startTime, DateTime endTime, String subject, String details, Boolean isAllDay, UIViewController viewController)
        {
            var granted = await RequestAccessToCalendarAsync();

            if (granted)
            {
                EKEventEditViewController eventController = new EKEventEditViewController();

                // set the controller's event store - it needs to know where/how to save the event
                eventController.EventStore = AppCalendarSingleton.Current.EventStore;

                // wire up a delegate to handle events from the controller
                eventControllerDelegate          = new CreateEventEditViewDelegate(eventController);
                eventController.EditViewDelegate = eventControllerDelegate;

                EKEvent newEvent = EKEvent.FromStore(AppCalendarSingleton.Current.EventStore);
                newEvent.StartDate = (NSDate)DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
                newEvent.EndDate   = (NSDate)DateTime.SpecifyKind(endTime, DateTimeKind.Utc);
                newEvent.Title     = subject;
                newEvent.Notes     = details;
                newEvent.AllDay    = isAllDay;
                //newEvent.AddAlarm(ConvertReminder(reminder, startTime));
                //newEvent.Availability = ConvertAppointmentStatus(status);

                eventController.Event = newEvent;

                // show the event controller
                viewController.PresentViewController(eventController, true, null);

                CLLocationManager locationManager = new CLLocationManager();

                // if (CLLocationManager.Status == CLAuthorizationStatus.NotDetermined)
                locationManager.RequestWhenInUseAuthorization();
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the CreateEventEditViewDelegate class.
 /// </summary>
 /// <param name="eventController">Event controller.</param>
 /// <param name="CalendarView">Calendar view.</param>
 /// <param name="DataSource">Data source.</param>
 public CreateEventEditViewDelegate(EKEventEditViewController eventController, DSCalendarView CalendarView, DSCalendarEventKitDataSource DataSource)
 {
     // save our controller reference
     this.eventController = eventController;
     this.mCalendarView   = CalendarView;
     this.mDatasource     = DataSource;
 }
コード例 #3
0
        partial void addTime(UIKit.UIBarButtonItem sender)
        {
            // Show the EKEventEditViewController
            var controller = new EKEventEditViewController();

            controller.EventStore = model.EventStore;
            controller.Completed += (object obj, EKEventEditEventArgs e) =>
            {
                DismissViewController(true, null);

                if (e.Action != EKEventEditViewAction.Canceled)
                {
                    // Update our events, since we added a new event.
                    model.FetchPokerEvents();
                }
            };
            controller.GetDefaultCalendarForNewEvents += delegate(EKEventEditViewController obj)
            {
                return(model.SelectedCalendar);
            };

            var ekevent = EKEvent.FromStore(model.EventStore);

            ekevent.Title     = PNVModel.DefaultEventTitle;
            ekevent.TimeZone  = NSTimeZone.LocalTimeZone;
            ekevent.StartDate = NSDate.Now;
            ekevent.EndDate   = NSDate.Now.AddSeconds(60 * 60);
            controller.Event  = ekevent;

            PresentViewController(controller, true, null);
        }
コード例 #4
0
 private void DisposeCalEventViewController()
 {
     if (_editCalEventController != null)
     {
         _editCalEventController.DismissViewController(true, null);
         _editCalEventController.EditViewDelegate = null;
         _editCalEventController.Dispose();
         _editCalEventController = null;
     }
 }
コード例 #5
0
            // Display notofication after successfull adding to calendar
            public override void Completed(EKEventEditViewController controller, EKEventEditViewAction action)
            {
                eventController.DismissViewController(true, null);

                if (action == EKEventEditViewAction.Saved)
                {
                    AppNotifications.Display(new DisplayedPromptsModel()
                    {
                        Category = "", Task = "Task has been successfully scheduled"
                    });
                }
            }
コード例 #6
0
        private void InitializeCalEventViewController()
        {
            _editCalEventController            = new OrgEventEditViewController();
            _editCalEventController.EventStore = (EKEventStore)ViewModel.CurrentCalendarEvent.EventStore;
            _editCalEventController.Event      = (EKEvent)ViewModel.CurrentCalendarEvent.EventObj;

            var viewDelegate = new OrgEventCalEditViewDelegate(ViewModel);

            _editCalEventController.EditViewDelegate = viewDelegate;

            PresentViewController(_editCalEventController, true, null);
        }
コード例 #7
0
        public override void Completed(EKEventEditViewController controller, EKEventEditViewAction action)
        {
            switch (action)
            {
            case EKEventEditViewAction.Canceled:
                if (_viewModel.CancelEventCommand.CanExecute(null))
                {
                    _viewModel.CancelEventCommand.Execute(null);
                }
                break;

            case EKEventEditViewAction.Saved:
                if (_viewModel.SaveEventCommand.CanExecute(null))
                {
                    _viewModel.SaveEventCommand.Execute(null);
                }
                break;
            }
        }
コード例 #8
0
        // completed is called when a user eith
        public override void Completed(EKEventEditViewController controller, EKEventEditViewAction action)
        {
            _eventController.DismissViewController(true, null);
            switch (action)
            {
            case EKEventEditViewAction.Canceled:
                _success = false;
                break;

            case EKEventEditViewAction.Saved:
                _success = true;
                break;

            case EKEventEditViewAction.Deleted:
                _success = false;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(action), action, null);
            }
        }
コード例 #9
0
        public void AddEventToCalendar(CultureInfo ci, DateTime from, DateTime until, string name, string location)
        {
            try
            {
                EventStore.RequestAccess(EKEntityType.Event,
                                         (granted, e) =>
                {
                    if (granted)
                    {
                        UIApplication.SharedApplication.InvokeOnMainThread(() =>
                        {
                            var eventController = new EKEventEditViewController
                            {
                                EventStore = EventStore
                            };

                            var eventControllerDelegate      = new CreateEventEditViewDelegate(eventController);
                            eventController.EditViewDelegate = eventControllerDelegate;

                            var newEvent       = EKEvent.FromStore(EventStore);
                            newEvent.StartDate = DateTimeToNsDate(from);
                            newEvent.EndDate   = DateTimeToNsDate(until);
                            newEvent.AllDay    = true;
                            newEvent.Location  = location;
                            newEvent.Title     = name;
                            newEvent.Calendar  = EventStore.DefaultCalendarForNewEvents;

                            eventController.Event = newEvent;

                            UIApplication.SharedApplication.Windows[0].RootViewController
                            .PresentViewController(eventController, true, null);
                        });
                    }
                });
            }
            catch (Exception)
            {
                // shht
            }
        }
コード例 #10
0
ファイル: IPhonePIM.cs プロジェクト: lsp1357/appverse-mobile
        /// <summary>
        /// Launchs the create new event controller.
        /// </summary>
        protected void LaunchCreateNewEvent(CalendarEntry entry)
        {
            EKEventStore store = IPhoneServiceLocator.CurrentDelegate.EventStore;
            EKCalendar calendar = store.DefaultCalendarForNewEvents;

            EKEvent calendarEvent = EKEvent.FromStore(store);
            // add event to the default calendar for the new events
            calendarEvent.Calendar = calendar;

            try {
                // add event details
                calendarEvent.Title = entry.Title;
                if(entry.Notes == null) {
                    entry.Notes = "";
                }
                calendarEvent.Notes = entry.Notes;
                calendarEvent.Location = entry.Location;
                calendarEvent.AllDay = entry.IsAllDayEvent;
                calendarEvent.StartDate = IPhoneUtils.DateTimeToNSDate(entry.StartDate);
                calendarEvent.EndDate = IPhoneUtils.DateTimeToNSDate(entry.EndDate);

                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Creating Calendar Event: " + calendarEvent.Title);
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Default Calendar: " + calendar.Title);
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Event StartDate: " + calendarEvent.StartDate.ToString());
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Event EndDate: " + calendarEvent.EndDate.ToString());
                // TODO: locate how to translate this features
                // entry.Type (birthday, exchange, etc)
                //calendarEvent.  = entry.IsEditable

                // Attendees
                if(entry.Attendees != null && entry.Attendees.Length >0) {
                    int attendeesNum = entry.Attendees.Length;
                    // TODO : check another way to add participants
                    // calendarEvent.Attendees --> READ ONLY !!!
                }

                // Alarms
                if(entry.Alarms != null && entry.Alarms.Length >0) {
                    foreach(CalendarAlarm alarm in entry.Alarms) {
                        EKAlarm eventAlarm = new EKAlarm();
                        eventAlarm.AbsoluteDate = IPhoneUtils.DateTimeToNSDate(alarm.Trigger);
                        // TODO: how to manage "action", "sound" and "emailaddress"
                        calendarEvent.AddAlarm(eventAlarm);
                    }
                }

                if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0)) {
                    // Recurrence Rules
                    if(entry.IsRecurrentEvent && entry.Recurrence != null) {
                        EKRecurrenceFrequency recurrenceFrequency = EKRecurrenceFrequency.Daily;
                        if(entry.Recurrence.Type == RecurrenceType.Weekly) {
                            recurrenceFrequency = EKRecurrenceFrequency.Weekly;
                        } else if(entry.Recurrence.Type == RecurrenceType.Montly) {
                            recurrenceFrequency = EKRecurrenceFrequency.Monthly;
                        } else if(entry.Recurrence.Type == RecurrenceType.Yearly) {
                            recurrenceFrequency = EKRecurrenceFrequency.Yearly;
                        } else if(entry.Recurrence.Type == RecurrenceType.FourWeekly) {
                            recurrenceFrequency = EKRecurrenceFrequency.Weekly;
                            entry.Recurrence.Interval = 4; // force event to be repeated "every 4 weeks"
                        } else if(entry.Recurrence.Type == RecurrenceType.Fortnightly) {
                            recurrenceFrequency = EKRecurrenceFrequency.Weekly;
                            entry.Recurrence.Interval = 2; // force event to be repeated "every 2 weeks"
                        }
                        EKRecurrenceEnd recurrenceEnd = null;
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence Frequency: " + recurrenceFrequency);
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence Interval: " + entry.Recurrence.Interval);
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence EndDate (requested): " + entry.Recurrence.EndDate.ToString());
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence number: " + entry.RecurrenceNumber);
                        if(entry.Recurrence.EndDate.CompareTo(entry.EndDate)>0) {
                            recurrenceEnd = EKRecurrenceEnd.FromEndDate(IPhoneUtils.DateTimeToNSDate(entry.Recurrence.EndDate));
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence EndDate (applied): " + recurrenceEnd.EndDate.ToString());
                        } else if(entry.RecurrenceNumber > 0) {
                            recurrenceEnd = EKRecurrenceEnd.FromOccurrenceCount((int)entry.RecurrenceNumber);
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Recurrence OcurrenceCount: " + recurrenceEnd.OccurrenceCount);
                        } else {
                            recurrenceEnd = new EKRecurrenceEnd();
                        }
                        EKRecurrenceRule recurrenceRule = new EKRecurrenceRule(recurrenceFrequency,entry.Recurrence.Interval, recurrenceEnd);
                        if(entry.Recurrence.DayOfTheWeek > 0) {
                            EKRecurrenceDayOfWeek dayOfWeek = EKRecurrenceDayOfWeek.FromWeekDay(entry.Recurrence.DayOfTheWeek,0);
                            EKRecurrenceDayOfWeek[] arrayDayOfWeek = new EKRecurrenceDayOfWeek[1];
                            arrayDayOfWeek[0] = dayOfWeek;
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Setting DayOfTheWeek: " + dayOfWeek.DayOfTheWeek);
                            recurrenceRule = new EKRecurrenceRule(recurrenceFrequency,entry.Recurrence.Interval, arrayDayOfWeek, null, null, null, null, null, recurrenceEnd);
                        }

                        calendarEvent.AddRecurrenceRule(recurrenceRule);
                    }
                }
            } catch (Exception e) {
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "ERROR Creating Calendar Event [" + calendarEvent.Title + "]. Error message: " + e.Message);
            }

            EKEventEditViewController eventViewController = new EKEventEditViewController();
            eventViewController.Event = calendarEvent;
            eventViewController.EventStore = store;
            eventViewController.Completed += delegate(object sender, EKEventEditEventArgs e) {
                UIApplication.SharedApplication.InvokeOnMainThread (delegate {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "On EKEventEditViewController Completed: " + e.Action);
                    if(e.Action == EKEventEditViewAction.Saved) {
                        INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
                        if (notificationService != null) {
                            notificationService.StartNotifyAlert ("Calendar Alert", "Calendar Entry Saved", "OK");
                        }
                    }
                    IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().DismissModalViewController(true);
                });
            };

            IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController (eventViewController, true);
            IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
        }
コード例 #11
0
        public RotatingCalendarView(RectangleF rect, float tabBarHeight)
        {
            notificationObserver = NSNotificationCenter.DefaultCenter.AddObserver ("EKEventStoreChangedNotification", EventsChanged);
            this.Title = Util.MyTitle;
            CurrentDate = DateTime.Today;
            SingleDayView = new CalendarDayTimelineView (rect, tabBarHeight);
            WeekView = new TrueWeekView (CurrentDate);
            WeekView.UseCalendar = true;
            LandscapeLeftView = WeekView;
            LandscapeRightView = WeekView;
            PortraitView = SingleDayView;
            SingleDayView.OnEventClicked += theEvent =>
            {
                if (theEvent != null) {
                    if (OnEventClicked != null) {
                        OnEventClicked (theEvent);
                    }
                }
            };

            WeekView.OnEventClicked += theEvent =>
            {
                if (theEvent != null) {
                    if (OnEventClicked != null) {
                        OnEventClicked (theEvent);
                    }
                }
            };
            SingleDayView.dateChanged += theDate => { CurrentDate = theDate; };
            this.OnEventClicked += theEvent =>
            {

                //Util.MyEventStore.RemoveEvents(Util.getEvent(theEvent),EKSpan.ThisEvent,theError.Handle);
                addController = new EKEventEditViewController ();

                // set the addController's event store to the current event store.
                addController.EventStore = Util.MyEventStore;
                addController.Event = Util.getEvent (theEvent);

                addController.Completed += delegate(object sender, EKEventEditEventArgs e)
                {
                    this.DismissModalViewControllerAnimated (true);
                };

                try {
                    if (this.ModalViewController == null)
                        this.NavigationController.PresentModalViewController (addController, true);
                } catch (Exception ex) {
                    //rotatingView.NavigationController.PopViewControllerAnimated(false);
                }
            };
        }
コード例 #12
0
        public override void Completed(EKEventEditViewController controller, EKEventEditViewAction action)
        {
            switch (action)
            {
                case EKEventEditViewAction.Canceled:
                {
                    BackToParentController();
                    break;
                }

                case EKEventEditViewAction.Saved:
                {
                    BackToParentController();
                    NSError e;
                    EventSingleton.Current.EventStore.SaveEvent(_parentController.Event, EKSpan.ThisEvent, out e);
                    break;
                }
            }
        }
コード例 #13
0
        private void portriatNavBar()
        {
            //  _leftButton = new UIBarButtonItem("Calendars", UIBarButtonItemStyle.Bordered, HandlePreviousDayTouch);
            NavigationItem.LeftBarButtonItem = _orgLefButton;
            NavigationItem.Title = Util.MyTitle;
            _rightButton = new UIBarButtonItem (UIBarButtonSystemItem.Add, delegate {
                addController = new EKEventEditViewController();
                // set the addController's event store to the current event store.
                addController.EventStore = Util.MyEventStore;
                addController.Event = EKEvent.FromStore(Util.MyEventStore);
                if (Util.MyCalendar != null)
                    addController.Event.Calendar = Util.MyCalendar;
                addController.Event.StartDate = DateTime.Now;
                addController.Event.EndDate = DateTime.Now.AddHours(1);

                addController.Completed += delegate(object theSender, EKEventEditEventArgs eva) {
                    switch (eva.Action)
                    {
                    case EKEventEditViewAction.Canceled :
                        case EKEventEditViewAction.Deleted :
                        case EKEventEditViewAction.Saved:
                        this.NavigationController.DismissModalViewControllerAnimated(true);

                        break;
                    }
                };
                this.NavigationController.PresentModalViewController (addController, true);
            });

            NavigationItem.RightBarButtonItem = _rightButton;
        }
コード例 #14
0
 public CreateEventEditViewDelegate(EKEventEditViewController eventController)
 {
     // save our controller reference
     this._eventController = eventController;
 }
コード例 #15
0
        public AddViewController(UIViewController theView, BaseItem ParentTask,long assignedID,int groupID, DateTime duedate)
            : base(null,true)
        {
            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, delegate{
                this.DeactivateController(true);
            });

            taskElement = new ImageStringElement("Item",Images.boxImg,delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.Item,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? groupID: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);
            });

            calendarElement = new ImageStringElement("Calendar Event",Images.AppleCalendar,delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                addController = new EKEventEditViewController();
                // set the addController's event store to the current event store.
                addController.EventStore = Util.MyEventStore;
                addController.Event = EKEvent.FromStore(Util.MyEventStore);
                if(duedate.Year < 2000)
                    duedate = DateTime.Today;
                addController.Event.StartDate = duedate.AddHours(DateTime.Now.Hour);
                addController.Event.EndDate = duedate.AddHours(DateTime.Now.Hour + 1);

                addController.Completed += delegate(object theSender, EKEventEditEventArgs eva) {
                    switch (eva.Action)
                    {
                        case EKEventEditViewAction.Canceled :
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                        case EKEventEditViewAction.Deleted :
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                        case EKEventEditViewAction.Saved:
                            theView.NavigationController.DismissModalViewControllerAnimated(true);
                            break;
                    }
                };

                theView.NavigationController.PresentModalViewController(addController,true);
            });

            checkListElement = new ImageStringElement("List",Images.checkListImage, delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new CheckList(assignedID){
                Kind = TaskKind.List,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate
                };

                var taskVC = new DetailViewController(task,true);
                taskVC.TaskListSaved += savedTask => {
                        theView.NavigationController.PushViewController(new TaskViewController(savedTask.Description,true,savedTask),true);
                };

                theView.NavigationController.PushViewController(taskVC,true);
            });

            phoneCallElement = new ImageStringElement("Phone Call",Images.phoneImg, delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.PhoneCall,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            emailElement = new ImageStringElement("Send an Email",Images.emailImg,delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.Email,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            websiteElement = new ImageStringElement("Visit a Website",Images.globeImg,delegate{
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID){
                    Kind = TaskKind.VisitAWebsite,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID ,
                    ParentID = ParentTask == null ? 0: ParentTask.ID ,
                    GroupID = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate = duedate

                };
                theView.NavigationController.PushViewController(new DetailViewController(task,true),true);

            });

            Root = new RootElement("Add new item")
            {
                new Section()
                {
                    taskElement,
                    calendarElement,
                    checkListElement,
                },
                new Section()
                {
                    phoneCallElement,
                    emailElement,
                    websiteElement,
                }
            };

            ///
        }
コード例 #16
0
		partial void addTime (MonoTouch.UIKit.UIBarButtonItem sender)
		{
			// Show the EKEventEditViewController
			var controller = new EKEventEditViewController ();
			controller.EventStore = model.EventStore;
			controller.Completed += (object obj, EKEventEditEventArgs e) => 
			{
				DismissViewController (true, null);

				if (e.Action != EKEventEditViewAction.Canceled) {
					// Update our events, since we added a new event.
					model.FetchPokerEvents ();
				}
			};
			controller.GetDefaultCalendarForNewEvents += delegate (EKEventEditViewController obj)
			{
				return model.SelectedCalendar;
			};

			var ekevent = EKEvent.FromStore (model.EventStore);
			ekevent.Title = PNVModel.DefaultEventTitle;
			ekevent.TimeZone = NSTimeZone.LocalTimeZone;
			ekevent.StartDate = NSDate.Now;
			ekevent.EndDate = NSDate.Now.AddSeconds (60 * 60);
			controller.Event = ekevent;

			PresentViewController (controller, true, null);
		}
コード例 #17
0
        public AddViewController(UIViewController theView, BaseItem ParentTask, long assignedID, int groupID, DateTime duedate) : base(null, true)
        {
            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, delegate {
                this.DeactivateController(true);
            });

            taskElement = new ImageStringElement("Item", Images.boxImg, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID)
                {
                    Kind             = TaskKind.Item,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID,
                    ParentID         = ParentTask == null ? 0: ParentTask.ID,
                    GroupID          = ParentTask == null ? groupID: ParentTask.GroupID,
                    OwnerID          = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate          = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task, true), true);
            });

            calendarElement = new ImageStringElement("Calendar Event", Images.AppleCalendar, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                addController = new EKEventEditViewController();
                // set the addController's event store to the current event store.
                addController.EventStore = Util.MyEventStore;
                addController.Event      = EKEvent.FromStore(Util.MyEventStore);
                if (duedate.Year < 2000)
                {
                    duedate = DateTime.Today;
                }
                addController.Event.StartDate = duedate.AddHours(DateTime.Now.Hour);
                addController.Event.EndDate   = duedate.AddHours(DateTime.Now.Hour + 1);

                addController.Completed += delegate(object theSender, EKEventEditEventArgs eva) {
                    switch (eva.Action)
                    {
                    case EKEventEditViewAction.Canceled:
                        theView.NavigationController.DismissModalViewControllerAnimated(true);
                        break;

                    case EKEventEditViewAction.Deleted:
                        theView.NavigationController.DismissModalViewControllerAnimated(true);
                        break;

                    case EKEventEditViewAction.Saved:
                        theView.NavigationController.DismissModalViewControllerAnimated(true);
                        break;
                    }
                };

                theView.NavigationController.PresentModalViewController(addController, true);
            });

            checkListElement = new ImageStringElement("List", Images.checkListImage, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new CheckList(assignedID)
                {
                    Kind             = TaskKind.List,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID,
                    ParentID         = ParentTask == null ? 0: ParentTask.ID,
                    GroupID          = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID          = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate          = duedate
                };

                var taskVC            = new DetailViewController(task, true);
                taskVC.TaskListSaved += savedTask => {
                    theView.NavigationController.PushViewController(new TaskViewController(savedTask.Description, true, savedTask), true);
                };

                theView.NavigationController.PushViewController(taskVC, true);
            });

            phoneCallElement = new ImageStringElement("Phone Call", Images.phoneImg, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID)
                {
                    Kind             = TaskKind.PhoneCall,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID,
                    ParentID         = ParentTask == null ? 0: ParentTask.ID,
                    GroupID          = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID          = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate          = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task, true), true);
            });

            emailElement = new ImageStringElement("Send an Email", Images.emailImg, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID)
                {
                    Kind             = TaskKind.Email,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID,
                    ParentID         = ParentTask == null ? 0: ParentTask.ID,
                    GroupID          = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID          = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate          = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task, true), true);
            });

            websiteElement = new ImageStringElement("Visit a Website", Images.globeImg, delegate {
                this.NavigationController.PopViewControllerAnimated(false);
                var task = new BaseItem(assignedID)
                {
                    Kind             = TaskKind.VisitAWebsite,
                    ExternalParentID = ParentTask == null ? 0: ParentTask.ExternalID,
                    ParentID         = ParentTask == null ? 0: ParentTask.ID,
                    GroupID          = ParentTask == null ? 0: ParentTask.GroupID,
                    OwnerID          = ParentTask == null ? Settings.Sync.userID : ParentTask.OwnerID,
                    DueDate          = duedate
                };
                theView.NavigationController.PushViewController(new DetailViewController(task, true), true);
            });



            Root = new RootElement("Add new item")
            {
                new Section()
                {
                    taskElement,
                    calendarElement,
                    checkListElement,
                },
                new Section()
                {
                    phoneCallElement,
                    emailElement,
                    websiteElement,
                }
            };

            ///
        }