Example #1
0
        protected void LaunchCreateNewEvent(string name, DateTime startTime, DateTime endTime)
        {
            // create a new EKEventEditViewController. This controller is built in an allows
            // the user to create a new, or edit an existing event.

            EventKitUI.EKEventEditViewController eventController =
                new EventKitUI.EKEventEditViewController ();

            // set the controller's event store - it needs to know where/how to save the event
            eventController.EventStore = ((AppDelegate)UIApplication.SharedApplication.Delegate).EventStore;

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

            eventController.Event.Title = name;
            eventController.Event.StartDate = DateTimeToNSDate (startTime);
            eventController.Event.EndDate = DateTimeToNSDate (endTime);

            // show the event controller

            UIViewController topVc = UIApplication.SharedApplication.KeyWindow.RootViewController;

            topVc.PresentViewController (eventController, true, null);

            /*
            EKEventStore store = ((AppDelegate)UIApplication.SharedApplication.Delegate).EventStore;

            EKEvent newEvent = EKEvent.FromStore (store);

            newEvent.Title = name;
            newEvent.StartDate = DateTimeToNSDate (startTime);
            newEvent.EndDate = DateTimeToNSDate (endTime);

            newEvent.Calendar = store.DefaultCalendarForNewEvents;

            NSError err;
            bool isSuceess = store.SaveEvent(newEvent, EKSpan.ThisEvent, out err);

            if (isSuceess) {

                new UIAlertView ("Add suceess", "Suceess add event to your reminder", null, "ok", null).Show ();

            } else {

                new UIAlertView ("Add fail", "Fail add event to your reminder", null, "ok", null).Show ();
                Debug.WriteLine (err.ToString ());
            }
            */
        }
Example #2
0
        /// <summary>
        /// Launchs the create new event controller.
        /// </summary>
        protected void LaunchModifyEvent()
        {
            // first we need to create an event it so we have one that we know exists
             // in a real world scenario, we'd likely either a) be modifying an event that
             // we found via a query, or 2) we'd do like this, in which we'd automatically
             // populate the event data, like for say a dr. appt. reminder, or something
             EKEvent newEvent = EKEvent.FromStore ( App.Current.EventStore );
             // set the alarm for 10 minutes from now
             newEvent.AddAlarm ( EKAlarm.FromDate ( DateTime.Now.AddMinutes ( 10 ) ) );
             // make the event start 20 minutes from now and last 30 minutes
             newEvent.StartDate = DateTime.Now.AddMinutes ( 20 );
             newEvent.EndDate = DateTime.Now.AddMinutes ( 50 );
             newEvent.Title = "Get outside and do some exercise!";
             newEvent.Notes = "This is your motivational event to go and do 30 minutes of exercise. Super important. Do this.";

             // create a new EKEventEditViewController. This controller is built in an allows
             // the user to create a new, or edit an existing event.
             MonoTouch.EventKitUI.EKEventEditViewController eventController =
            new MonoTouch.EventKitUI.EKEventEditViewController ();

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

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

             // show the event controller
             PresentViewController ( eventController, true, null );
        }
Example #3
0
        protected void LaunchCreateNewEvent()
        {
            // create a new EKEventEditViewController. This controller is built in an allows
             // the user to create a new, or edit an existing event.
             MonoTouch.EventKitUI.EKEventEditViewController eventController =
            new MonoTouch.EventKitUI.EKEventEditViewController ();

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

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

             // show the event controller
             PresentViewController ( eventController, true, null );
        }
		protected void LaunchCreateNewEvent ()
		{
			// create a new EKEventEditViewController. This controller is built in an allows
			// the user to create a new, or edit an existing event.
			AppDelegate.EventStore.RequestAccess (EKEntityType.Event, (bool granted, NSError e) => {

				EventKitUI.EKEventEditViewController eventController =
					new EventKitUI.EKEventEditViewController ();
				InvokeOnMainThread (() => { 
					//					EKEvent newEvent = EKEvent.FromStore (AppDelegate.EventStore);
					//					newEvent.Title = "Get outside and do some exercise!";
					//					newEvent.Notes = "This is your motivational event to go and do 30 minutes of exercise. Super important. Do this.";
					//					newEvent.Location = "Seattle,WA";
					// set the controller's event store - it needs to know where/how to save the event
					eventController.EventStore = AppDelegate.EventStore;
					//					eventController.Event = newEvent;
					// wire up a delegate to handle events from the controller
					eventControllerDelegate = new CreateEventEditViewDelegate (eventController);
					eventController.EditViewDelegate = eventControllerDelegate;

					// show the event controller
					PresentViewController (eventController, true, null);
				});
				//NavigationController.PushViewController (calendarListScreen, true);
			});

		}
Example #5
0
		public void LoadEvent(string eventID,LHRemindItem rmItem)
		{
			try
			{
				
				if (rmItem!=null)
				{
					ItemLH= new LHRemindItem();
					ItemLH=rmItem;
				}
				else
				{
					ItemLT=new LTRemindItem();
				}

				EKEvent mySavedEvent = App.Current.EventStore.EventFromIdentifier (eventID);
				EventKitUI.EKEventEditViewController eventController =
					new EventKitUI.EKEventEditViewController ();

				eventController.EventStore = App.Current.EventStore;
				eventController.Event = mySavedEvent;

				// wire up a delegate to handle events from the controller
				eventControllerDelegate = new CreateEventEditViewDelegate (eventController);
				eventController.EditViewDelegate = eventControllerDelegate;
				isUpdate=true;
				controller.PresentViewController (eventController, true, null);
			
			}
			catch {
				BRemind.RemoveRemind (SQLite_iOS.GetConnection (), eventID);
				UIAlertView _error = new UIAlertView ("Lỗi", "Không tìm thấy Nhắc lịch đã tạo", null, "Ok", null);
				if (VCLichHoc.instance != null)
					VCLichHoc.Instance.LoadData ();
				if (VCLichHocTuan.instance != null)
					VCLichHocTuan.Instance.LoadData_Tuan (VCLichHocTuan.LoadedDate);
				if (VCLichThi.instance != null)
					VCLichThi.Instance.LoadData ();
				_error.Show ();
			}
		}
Example #6
0
		protected void LaunchCreateNewEvent ()
		{  


			// create a new EKEventEditViewController. This controller is built in an allows
			// the user to create a new, or edit an existing event.


			EKEvent newEvent = EKEvent.FromStore (App.Current.EventStore);
			// set the alarm for 10 minutes from now
			newEvent.AddAlarm (EKAlarm.FromDate ((NSDate)srtTime.AddMinutes (-60)));
			// make the event start 20 minutes from now and last 30 minutes
			newEvent.StartDate = (NSDate)srtTime;
			newEvent.EndDate = (NSDate)endTime;
			newEvent.Title = title;
			if (title.Equals("Lịch Thi")) {
				newEvent.Notes = "Môn:" + tenmh + " Phòng Thi: " + lt.PhongThi + " Ghi chú";
				ItemLT = new LTRemindItem ();
				ItemLT.EventID = newEvent.EventIdentifier;
				ItemLT.MaMH = lt.MaMH;
				ItemLT.NamHoc = lt.NamHoc;
				ItemLT.HocKy = lt.HocKy;

			} else {
				newEvent.Notes = "Môn:" + tenmh + " Phòng Học:" + ct.Phong +  " Ghi chú:";
				ItemLH = new LHRemindItem ();
				ItemLH.EventID = newEvent.EventIdentifier;
				ItemLH.Date = time;
				ItemLH.IDLH = lh.Id;
			}
			// create a new EKEventEditViewController. This controller is built in an allows
			// the user to create a new, or edit an existing event.					
			EventKitUI.EKEventEditViewController eventController =
				new EventKitUI.EKEventEditViewController ();

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

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



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