예제 #1
0
        private void EditorView_TouchUpInside(object sender, EventArgs e)
        {
            scheduleEditor.Editor.Hidden = false;
            schedule.Hidden   = true;
            headerView.Hidden = true;
            tableView.Hidden  = true;

            NSDate     today    = new NSDate();
            NSCalendar calendar = NSCalendar.CurrentCalendar;
            // Get the year, month, day from the date
            NSDateComponents components = calendar.Components(
                NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
            NSDate startDate = calendar.DateFromComponents(components);

            scheduleEditor.label_subject.Text  = "Subject";
            scheduleEditor.label_location.Text = "Location";
            String _sDate = DateTime.Parse((startDate.ToString())).ToString();

            scheduleEditor.picker_startDate.SetDate(startDate, true);
            scheduleEditor.button_startDate.SetTitle(_sDate, UIControlState.Normal);
            String _eDate = DateTime.Parse((startDate.AddSeconds(3600).ToString())).ToString();

            scheduleEditor.picker_endDate.SetDate(startDate.AddSeconds(3600), true);
            scheduleEditor.button_endDate.SetTitle(_eDate, UIControlState.Normal);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.CurrentFrame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Size.Width, UIScreen.MainScreen.Bounds.Size.Height);
            this.AddButton();
            //Creating an instance for SfSchedule control
            SFSchedule schedule = new SFSchedule();

            schedule.Frame        = new CGRect(0, removeExceptionAppointment.Frame.Bottom, this.CurrentFrame.Size.Width, this.CurrentFrame.Size.Height - removeExceptionAppointment.Frame.Bottom);
            schedule.ScheduleView = SFScheduleView.SFScheduleViewWeek;

            NSCalendar calendar = new NSCalendar(NSCalendarType.Gregorian);
            NSDate     today    = NSDate.Now;
            // Get the year, month, day from the date
            NSDateComponents startDateComponents = calendar.Components(NSCalendarUnit.Year |
                                                                       NSCalendarUnit.Month |
                                                                       NSCalendarUnit.Day, today);

            // Set the year, month, day, hour, minute, second
            startDateComponents.Year   = 2017;
            startDateComponents.Month  = 09;
            startDateComponents.Day    = 03;
            startDateComponents.Hour   = 10;
            startDateComponents.Minute = 0;
            startDateComponents.Second = 0;

            //setting start time for the event
            NSDate startDate = calendar.DateFromComponents(startDateComponents);

            //setting end time for the event
            NSDate endDate = startDate.AddSeconds(2 * 60 * 60);

            // set moveto date to schedule
            schedule.MoveToDate(startDate);

            // Set the exception dates.
            var exceptionDate1 = startDate;
            var exceptionDate2 = startDate.AddSeconds(2 * 24 * 60 * 60);

            exceptionDate3 = startDate.AddSeconds(4 * 24 * 60 * 60);

            // Add Schedule appointment
            ScheduleAppointment recurrenceAppointment = new ScheduleAppointment();

            recurrenceAppointment.Id                       = 1;
            recurrenceAppointment.StartTime                = startDate;
            recurrenceAppointment.EndTime                  = endDate;
            recurrenceAppointment.Subject                  = (NSString)"Occurs Daily";
            recurrenceAppointment.AppointmentBackground    = UIColor.Blue;
            recurrenceAppointment.RecurrenceRule           = (NSString)"FREQ=DAILY;COUNT=20";
            recurrenceAppointment.RecurrenceExceptionDates = new System.Collections.ObjectModel.ObservableCollection <NSDate> {
                exceptionDate1,
                exceptionDate2,
                exceptionDate3
            };

            scheduleAppointmentCollection.Add(recurrenceAppointment);
            schedule.ItemsSource = scheduleAppointmentCollection;
            this.View.AddSubview(schedule);
        }
예제 #3
0
        private void EditorView_TouchUpInside(object sender, EventArgs e)
        {
            ScheduleEditor.Editor.Hidden = false;
            Schedule.Hidden   = true;
            HeaderView.Hidden = true;
            TableView.Hidden  = true;

            NSDate     today    = new NSDate();
            NSCalendar calendar = NSCalendar.CurrentCalendar;

            // Get the year, month, day from the date
            NSDateComponents components = calendar.Components(
                NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
            NSDate startDate = calendar.DateFromComponents(components);

            ScheduleEditor.LabelSubject.Text  = "Subject";
            ScheduleEditor.LabelLocation.Text = "Location";
            String startDate1 = DateTime.Parse(startDate.ToString()).ToString();

            ScheduleEditor.PickerStartDate.SetDate(startDate, true);
            ScheduleEditor.ButtonStartDate.SetTitle(startDate1, UIControlState.Normal);
            String endDate = DateTime.Parse(startDate.AddSeconds(3600).ToString()).ToString();

            ScheduleEditor.PickerEndDate.SetDate(startDate.AddSeconds(3600), true);
            ScheduleEditor.ButtonEndDate.SetTitle(endDate, UIControlState.Normal);
        }
        private void AddExceptionAppointment_TouchUpInside(object sender, EventArgs e)
        {
            var recurrenceAppointment = scheduleAppointmentCollection[0];

            Meeting exceptionAppointment = new Meeting();

            exceptionAppointment.From         = exceptionDate3.AddSeconds(2 * 60 * 60);
            exceptionAppointment.To           = exceptionAppointment.From.AddSeconds(2 * 60 * 60);
            exceptionAppointment.EventName    = (NSString)"Occurs Daily";
            exceptionAppointment.Color        = UIColor.Red;
            exceptionAppointment.RecurrenceID = recurrenceAppointment;
            exceptionAppointment.ActualDate   = exceptionDate3;
            scheduleAppointmentCollection.Add(exceptionAppointment);
        }
        private void AddExceptionAppointment_TouchUpInside(object sender, EventArgs e)
        {
            var recurrenceAppointment = scheduleAppointmentCollection[0];

            // Add appointment to current recurrence series.
            ScheduleAppointment exceptionAppointment = new ScheduleAppointment();

            exceptionAppointment.StartTime                     = exceptionDate3.AddSeconds(2 * 60 * 60);
            exceptionAppointment.EndTime                       = exceptionAppointment.StartTime.AddSeconds(2 * 60 * 60);
            exceptionAppointment.Subject                       = (NSString)"Occurs Daily";
            exceptionAppointment.AppointmentBackground         = UIColor.Red;
            exceptionAppointment.RecurrenceId                  = recurrenceAppointment.Id;
            exceptionAppointment.ExceptionOccurrenceActualDate = exceptionDate3;
            scheduleAppointmentCollection.Add(exceptionAppointment);
        }
예제 #6
0
        public void SetEvent(DateTime date, string title, string note)
        {
            if (eventStore == null)
            {
                requestAccess();
            }

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


            NSDate date2 = DateTimeToNSDate2(date);

            EKEvent newEvent = EKEvent.FromStore(eventController.EventStore);

            // set the alarm for 10 minutes from now

            newEvent.AddAlarm(EKAlarm.FromDate(date2));
            // make the event start 20 minutes from now and last 30 minutes
            newEvent.StartDate = date2;
            newEvent.EndDate   = date2.AddSeconds(1800);
            newEvent.Title     = title;
            newEvent.Notes     = note;
            newEvent.Calendar  = eventController.EventStore.DefaultCalendarForNewEvents;
            NSError a;

            eventController.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out a);
            Console.WriteLine("Event Saved, ID: " + newEvent.CalendarItemIdentifier);
        }
예제 #7
0
        public string OpenFileDialog(NSWindow window, string[] FileTypes, string title, bool canchoosedirectories = false, bool canchoosefiles = true)
        {
            string path = string.Empty;

            try {
                NSOpenPanel dlg = NSOpenPanel.OpenPanel;
                //dlg.Prompt = "Selecione um Arquivo";
                dlg.Title                   = title;
                dlg.CanChooseFiles          = canchoosefiles;
                dlg.CanChooseDirectories    = canchoosedirectories;
                dlg.AllowedFileTypes        = FileTypes;
                dlg.AllowsMultipleSelection = false;
                dlg.ResolvesAliases         = true;
                dlg.ReleasedWhenClosed      = true;

//				dlg.BeginSheet(window, (i) => {
//					try
//					{
//						if(dlg.Url != null)
//						{
//
//
//							var urlString = dlg.Url.Path;
//
//							if(!string.IsNullOrEmpty(urlString))
//							{
//								Console.WriteLine(urlString);
//							}
//						}
//					}
//					finally
//					{
//						dlg.Dispose();
//					}
//				});
//



                nint retDlg = dlg.RunModal();
                if (retDlg == 1)
                {
                    NSUrl url = dlg.Urls [0];
                    if (url != null)
                    {
                        path = url.Path;
                    }
                }
                NSDate DateLoop = new NSDate();
                DateLoop = DateLoop.AddSeconds(0.1);
                NSRunLoop.Current.RunUntil(DateLoop);
                dlg.Dispose();
                dlg = null;
            } catch (Exception) {
                //
            }
            return(path);
        }
예제 #8
0
        public override void GetNextRequestedUpdateDate(Action <NSDate> handler)
        {
            Console.WriteLine("GetNextRequestedUpdateDate");

            var nextUpdateDate = new NSDate();

            nextUpdateDate = nextUpdateDate.AddSeconds(30);
            handler(nextUpdateDate);
        }
예제 #9
0
        internal void SetDateByAddingDays(int days)
        {
            NSDate date = new NSDate();

            date = date.AddSeconds(60 * 60 * 24 * days);

            NSDateFormatter dateFormat = new NSDateFormatter();

            dateFormat.DateFormat = "EEEE d";
            DayNameLabel.Text     = dateFormat.ToString(date);
        }
예제 #10
0
        public SFChartDataPoint dataPointWithTimeInterval(double time)
        {
            int      count = (int)DataPoints.Count;
            NSNumber value;

            if (count > 320)
            {
                value = random.Next(0, 0);
            }
            else if (count > 280)
            {
                value = random.Next(-2, 2);
            }
            else if (count > 240)
            {
                value = random.Next(-3, 3);
            }
            else if (count > 200)
            {
                value = random.Next(-5, 5);
            }
            else if (count > 180)
            {
                value = random.Next(-6, 6);
            }
            else if (count > 120)
            {
                value = random.Next(-7, 7);
            }
            else if (count > 30)
            {
                value = random.Next(-9, 9);
            }
            else
            {
                value = random.Next(-3, 3);
            }

            date = date.AddSeconds(time);

            SFChartDataPoint datapoint = new SFChartDataPoint();

            datapoint.XValue = NSObject.FromObject(date);
            datapoint.YValue = value;
            return(datapoint);
        }
예제 #11
0
        public void AddEventWithStartTime(NSDate startDate)
        {
            // Create a new EKEvent and then set the properties on it.
            var e = EKEvent.FromStore(EventStore);

            e.Title     = DefaultEventTitle;
            e.TimeZone  = NSTimeZone.LocalTimeZone;
            e.StartDate = startDate;
            e.EndDate   = startDate.AddSeconds(60 * 60);            // 1 hour
            e.Calendar  = SelectedCalendar;

            // Save our new EKEvent
            NSError err;
            bool    success = EventStore.SaveEvent(e, EKSpan.FutureEvents, true, out err);

            if (!success)
            {
                Console.WriteLine("There was an error saving a new event: " + err);
            }
        }
예제 #12
0
		public void AddEventWithStartTime (NSDate startDate)
		{
			// Create a new EKEvent and then set the properties on it.
			var e = EKEvent.FromStore (EventStore);
			e.Title = DefaultEventTitle;
			e.TimeZone = NSTimeZone.LocalTimeZone;
			e.StartDate = startDate;
			e.EndDate = startDate.AddSeconds (60 * 60); // 1 hour
			e.Calendar = SelectedCalendar;

			// Save our new EKEvent
			NSError err;
			bool success = EventStore.SaveEvent (e, EKSpan.FutureEvents, true, out err);

			if (!success) 
				Console.WriteLine ("There was an error saving a new event: " + err);
		}
        public override void GetNextRequestedUpdateDate(Action<NSDate> handler)
        {
            Console.WriteLine ("GetNextRequestedUpdateDate");

            var nextUpdateDate = new NSDate ();
            nextUpdateDate.AddSeconds (10);
            handler (nextUpdateDate);
        }
예제 #14
0
        public static DateTime DateTimeFromNSDate(NSDate sourceDate)
        {
            NSTimeZone sourceTimeZone = new NSTimeZone ("UTC"); NSTimeZone destinationTimeZone = NSTimeZone.LocalTimeZone;

            int sourceGMTOffset = sourceTimeZone.SecondsFromGMT (sourceDate);
            int destinationGMTOffset = destinationTimeZone.SecondsFromGMT (sourceDate);
            int interval = destinationGMTOffset - sourceGMTOffset;

            var destinationDate = sourceDate.AddSeconds (interval);

            var dateTime = new DateTime (2001, 1, 1, 0, 0, 0).AddSeconds (destinationDate.SecondsSinceReferenceDate);
            return dateTime;
        }