public void FromEventStore() { EKEventStore store = new EKEventStore(); var c = EKCalendar.FromEventStore(store); // defaults Assert.True(c.AllowsContentModifications, "AllowsContentModifications"); Assert.NotNull(c.CalendarIdentifier, "CalendarIdentifier"); Assert.Null(c.CGColor, "CGColor"); if (TestRuntime.CheckSystemAndSDKVersion(6, 0)) { // default value changed for iOS 6.0 beta 1 Assert.False(c.Immutable, "Immutable"); // new in 6.0 Assert.AreEqual(EKEntityMask.Event, c.AllowedEntityTypes, "AllowedEntityTypes"); } else { Assert.True(c.Immutable, "Immutable"); } Assert.Null(c.Source, "Source"); Assert.False(c.Subscribed, "Subscribed"); Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); Assert.Null(c.Title, "Title"); Assert.That(c.Type, Is.EqualTo(EKCalendarType.Local), "Type"); }
public void FromEventStore_Null() { #if MONOMAC EKCalendar.Create(EKEntityType.Event, null); #else EKCalendar.FromEventStore(null); #endif }
public void Title() { EKEventStore store = new EKEventStore(); var c = EKCalendar.FromEventStore(store); c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
public void FromEventStore_Null() { #if MONOMAC Assert.Throws <ArgumentNullException> (() => EKCalendar.Create(EKEntityType.Event, null)); #else Assert.Throws <ArgumentNullException> (() => EKCalendar.FromEventStore(null)); #endif }
public void FromEventStore() { RequestPermission(); EKEventStore store = new EKEventStore(); #if MONOMAC || __MACCATALYST__ var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif // defaults #if __WATCHOS__ Assert.False(c.AllowsContentModifications, "AllowsContentModifications"); #else Assert.True(c.AllowsContentModifications, "AllowsContentModifications"); #endif Assert.NotNull(c.CalendarIdentifier, "CalendarIdentifier"); #if MONOMAC Assert.Null(c.Color, "Color"); #else Assert.Null(c.CGColor, "CGColor"); #endif if (TestRuntime.CheckXcodeVersion(4, 5)) { // default value changed for iOS 6.0 beta 1 #if __WATCHOS__ Assert.True(c.Immutable, "Immutable"); #else Assert.False(c.Immutable, "Immutable"); #endif // new in 6.0 Assert.AreEqual(EKEntityMask.Event, c.AllowedEntityTypes, "AllowedEntityTypes"); } else { Assert.True(c.Immutable, "Immutable"); } Assert.Null(c.Source, "Source"); Assert.False(c.Subscribed, "Subscribed"); #if MONOMAC || __MACCATALYST__ Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); Assert.That(c.Title, Is.EqualTo(string.Empty), "Title"); #else Assert.That(c.SupportedEventAvailabilities, Is.EqualTo(EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); if (TestRuntime.CheckXcodeVersion(13, 2)) { Assert.That(c.Title, Is.EqualTo(string.Empty), "Title"); } else { Assert.Null(c.Title, "Title"); } #endif Assert.That(c.Type, Is.EqualTo(EKCalendarType.Local), "Type"); }
public void Title() { EKEventStore store = new EKEventStore(); #if MONOMAC var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
public void Title() { RequestPermission(); EKEventStore store = new EKEventStore(); #if MONOMAC || __MACCATALYST__ var c = EKCalendar.Create(EKEntityType.Event, store); #else var c = EKCalendar.FromEventStore(store); #endif c.Title = "my title"; Assert.That(c.Title, Is.EqualTo("my title"), "Title"); }
public async Task PushMeetingsToCalendarAsync(List <Meeting> meetings) { try { using (await _PushMeetingsToCalendarAsyncLock.LockAsync()) { if (!(await _eventStore.RequestAccessAsync(EKEntityType.Event)).Item1) { return; } var calendar = _eventStore.GetCalendar(AcraCalendarIdentifier); CGColor colorToUse = null; if (calendar != null) { colorToUse = calendar.CGColor; NSError errorToDelete;; _eventStore.RemoveCalendar(calendar, true, out errorToDelete); } var otherToDelete = _eventStore.GetCalendars(EKEntityType.Event).Where(c => c.Title.StartsWith("ACRA")); foreach (var item in otherToDelete) { NSError errorToDelete; _eventStore.RemoveCalendar(item, true, out errorToDelete); } // now recreate a calendar ! calendar = EKCalendar.FromEventStore(_eventStore); calendar.Title = "ACRA du " + DateTime.Now.ToString("g", new System.Globalization.CultureInfo("fr")); if (colorToUse != null) { calendar.CGColor = colorToUse; } EKSource[] sources = _eventStore.Sources; var sourceToSet = sources .FirstOrDefault(s => s.SourceType == EKSourceType.CalDav && s.Title.Equals("iCloud", StringComparison.InvariantCultureIgnoreCase)); if (sourceToSet == null) { sourceToSet = sources.FirstOrDefault(s => s.SourceType == EKSourceType.Local); } if (sourceToSet == null) { sourceToSet = _eventStore.DefaultCalendarForNewEvents.Source; } calendar.Source = sourceToSet; NSError error; _eventStore.SaveCalendar(calendar, true, out error); AcraCalendarIdentifier = calendar.CalendarIdentifier; var toSaves = meetings.OrderByDescending(ap => ap.StartDate).ToArray(); var howMuch = toSaves.Length; for (int index = 0; index < howMuch; index++) { var appointData = toSaves[index]; var toSave = EKEvent.FromStore(_eventStore); //if (!string.IsNullOrEmpty(appointData.)) //{ // toSave.Location = appointData.Location; //} toSave.StartDate = ConvertDateTimeToNSDate(appointData.StartDate); toSave.AllDay = appointData.AllDayEvent; if (appointData.IsRecurrent && appointData.AllDayEvent) { var end = EKRecurrenceEnd.FromEndDate(ConvertDateTimeToNSDate(appointData.EndDate)); var rule = new EKRecurrenceRule(EKRecurrenceFrequency.Weekly, 1, end); toSave.RecurrenceRules = new[] { rule }; } else { toSave.EndDate = ConvertDateTimeToNSDate(appointData.EndDate); } // If set to AllDay and given an EndDate of 12am the next day, EventKit // assumes that the event consumes two full days. // (whereas WinPhone/Android consider that one day, and thus so do we) // if (appointData.AllDayEvent) { toSave.EndDate = ConvertDateTimeToNSDate(appointData.EndDate.AddDays(-1)); } if (!appointData.IsHoliday) { if (appointData.Duration.TotalDays > 1 && !appointData.IsRecurrent) { toSave.Title = ((int)appointData.Duration.TotalDays + 1) + " " + appointData.Title; } else { toSave.Title = appointData.Title; } } else { //TODO : localisation toSave.Title = "[FERIE] " + appointData.Title; } toSave.Notes = appointData.Type.ToString(); toSave.Calendar = calendar; NSError errorCommit; _eventStore.SaveEvent(toSave, EKSpan.ThisEvent, out errorCommit); } } NSError errorEvent; _eventStore.Commit(out errorEvent); } catch (Exception e) { //TODO : localisation await App.Instance.AlertService.ShowExceptionMessageAsync(e, "Impossible de renseigner votre calendrier iOS"); } }
public void FromEventStore_Null() { EKCalendar.FromEventStore(null); }