Example #1
0
        // completed is called when a user eith
        public override void Completed(EventKitUI.EKEventEditViewController controller, EKEventEditViewAction action)
        {
            eventController.DismissViewController(true, null);

            switch (action)
            {
            case EKEventEditViewAction.Canceled:
                break;

            case EKEventEditViewAction.Deleted:
                break;

            case EKEventEditViewAction.Saved:
                NSError error;
                eventStore.SaveEvent(controller.Event, EKSpan.ThisEvent, out error);
                break;
            }
        }
        public void CreateCalendarEntry(LocalCalendarEvent localCalendarEvent)
        {
            eventStore.RequestAccess(EKEntityType.Event,
                                     (bool granted, NSError e) => {
                if (granted)
                {
                    UIApplication.SharedApplication.InvokeOnMainThread(() => {
                        EventKitUI.EKEventEditViewController eventController = new EventKitUI.EKEventEditViewController();

                        eventController.EventStore = eventStore;

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

                        EKEvent newEvent = EKEvent.FromStore(eventStore);

                        newEvent.StartDate = (NSDate)(DateTime.SpecifyKind(localCalendarEvent.StartDate, DateTimeKind.Local));
                        if (localCalendarEvent.EndDate.HasValue)
                        {
                            newEvent.EndDate = (NSDate)(DateTime.SpecifyKind(localCalendarEvent.EndDate.Value, DateTimeKind.Local));
                        }

                        newEvent.Title    = localCalendarEvent.Subject;
                        newEvent.Notes    = localCalendarEvent.Description;
                        newEvent.Location = localCalendarEvent.Location;

                        if (localCalendarEvent.ReminderDate.HasValue)
                        {
                            newEvent.AddAlarm(EKAlarm.FromDate((NSDate)(DateTime.SpecifyKind(localCalendarEvent.ReminderDate.Value, DateTimeKind.Local))));
                        }

                        eventController.Event = newEvent;

                        // show the event controller
                        UIApplication.SharedApplication.Windows[0].RootViewController.PresentViewController(eventController, true, null);
                    });
                }
                else
                {
                    new UIAlertView("Access Denied", "User Denied Access to Calendar Data", null, "ok", null).Show();
                }
            });
        }
		public bool Remind(DateTime startDate, DateTime endtDate, string title, string message, int reminder)
        {

			 Device.BeginInvokeOnMainThread(() =>
			{
				TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
				try
				{
						EKEvent newEvent = EKEvent.FromStore ( this.EventStore );
						// make the event start 20 minutes from now and last 30 minutes
						newEvent.StartDate = DateTimeToNSDate( startDate.ToUniversalTime() );
						newEvent.EndDate = DateTimeToNSDate( endtDate.ToUniversalTime() );
						newEvent.Title = title;
						newEvent.Notes = message;
						newEvent.Calendar = this.EventStore.DefaultCalendarForNewEvents;

						EventKitUI.EKEventEditViewController eventController = new EventKitUI.EKEventEditViewController();
						eventController.EventStore = eventStore;
						eventControllerDelegate = new CreateEventEditViewDelegate (eventController);
						eventController.EditViewDelegate = eventControllerDelegate;
						eventController.Event = newEvent;

						var firstController = UIApplication.SharedApplication.KeyWindow.RootViewController.ChildViewControllers.First().ChildViewControllers.Last().ChildViewControllers.First();
		
						firstController.PresentViewController (eventController, true, null);
				}
				catch (Exception ex)
				{
					tcs.SetException(ex);
				}
			});

			return true;


        }
		public CreateEventEditViewDelegate (EventKitUI.EKEventEditViewController eventController)
		{
			// save our controller reference
			this.eventController = eventController;
		}
 public CreateEventEditViewDelegate(EventKitUI.EKEventEditViewController eventController)
 {
     // save our controller reference
     this.eventController = eventController;
 }
Example #6
0
 public CreateEventEditViewDelegate(EventKitUI.EKEventEditViewController eventController, EKEventStore eventStore)
 {
     this.eventController = eventController;
     this.eventStore      = eventStore;
 }