Esempio n. 1
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);
                }
            };
        }
Esempio n. 2
0
        public RotatingCalendarView(RectangleF rect, IEventsSource source, float tabBarHeight)
        {
            dataSource = source;
            //notificationObserver = NSNotificationCenter.DefaultCenter.AddObserver ("EKEventStoreChangedNotification", EventsChanged);
            CurrentDate = DateTime.Today;
            SingleDayView = new CalendarDayTimelineView(rect, tabBarHeight, dataSource, true);
            SingleDayLandscapeView = new CalendarDayTimelineView(new RectangleF(0, 0, 480, 320), 0, dataSource, false);
            //WeekView = new TrueWeekView (CurrentDate, dataSource);
            //WeekView.UseCalendar = true;
            //LandscapeLeftView = WeekView;
            //LandscapeRightView = WeekView;
            LandscapeLeftView = SingleDayLandscapeView;
            LandscapeRightView = SingleDayLandscapeView;
            PortraitView = SingleDayView;
            //SingleDayView.ForceAutoRotate = delegate{ForceAutoRotate();};
            SingleDayView.OnEventClicked += theEvent =>
            {
                if (theEvent != null)
                {
                    if (OnEventClicked != null)
                    {
                        OnEventClicked(theEvent);
                    }
                }
            };

            SingleDayLandscapeView.OnEventClicked += theEvent =>
            {
                if (theEvent != null)
                {
                    if (OnEventClicked != null)
                    {
                        OnEventClicked(theEvent);
                    }
                }
            };

            SingleDayView.OnNewEvent += date =>
            {
                if (date != null)
                {
                    if (OnAddEvent != null)
                    {
                        OnAddEvent(date);
                    }
                }
            };

            SingleDayLandscapeView.OnNewEvent += date =>
            {
                if (date != null)
                {
                    if (OnAddEvent != null)
                    {
                        OnAddEvent(date);
                    }
                }
            };

            SingleDayView.dateChanged += theDate =>
            {
                if (!preventUpdates)
                {
                    preventUpdates = true;
                    CurrentDate = theDate;
                    //SingleDayLandscapeView.SetDate(theDate);
                    SingleDayLandscapeView.SetDateAndReloadDay(theDate);
                    preventUpdates = false;
                }
            };

            SingleDayLandscapeView.dateChanged += theDate =>
            {
                if (!preventUpdates)
                {
                    preventUpdates = true;
                    CurrentDate = theDate;
                    SingleDayView.SetDateAndReloadDay(theDate);
                    preventUpdates = false;
                }
            };

            //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);
            //    }
            //};
        }