diff --git a/VisualCard.Calendar/Parsers/VCalendarConstants.cs b/VisualCard.Calendar/Parsers/VCalendarConstants.cs index 4e2c07b..bb3322e 100644 --- a/VisualCard.Calendar/Parsers/VCalendarConstants.cs +++ b/VisualCard.Calendar/Parsers/VCalendarConstants.cs @@ -56,6 +56,7 @@ internal static class VCalendarConstants internal const string _resourcesSpecifier = "RESOURCES"; internal const string _sequenceSpecifier = "SEQUENCE"; internal const string _attendeeSpecifier = "ATTENDEE"; + internal const string _transparencySpecifier = "TRANSP"; internal const string _xSpecifier = "X-"; internal const string _typeArgumentSpecifier = "TYPE="; internal const string _valueArgumentSpecifier = "VALUE="; diff --git a/VisualCard.Calendar/Parsers/VCalendarParser.cs b/VisualCard.Calendar/Parsers/VCalendarParser.cs index ab109c5..9636803 100644 --- a/VisualCard.Calendar/Parsers/VCalendarParser.cs +++ b/VisualCard.Calendar/Parsers/VCalendarParser.cs @@ -196,6 +196,14 @@ public Parts.Calendar Parse() if (finalValue != "TENTATIVE" && finalValue != "CONFIRMED" && finalValue != "CANCELLED") throw new ArgumentException($"Invalid status {finalValue}"); break; + case CalendarStringsEnum.Transparency: + // Unescape the value + finalValue = Regex.Unescape(value); + if (CalendarVersion.Major == 1 && !int.TryParse(finalValue, out _)) + throw new ArgumentException($"Invalid transparency number {finalValue}"); + else if (CalendarVersion.Major == 2 && finalValue != "TRANSPARENT" && finalValue != "OPAQUE") + throw new ArgumentException($"Invalid transparency {finalValue}"); + break; case CalendarStringsEnum.Uid: // Unescape the value finalValue = Regex.Unescape(value); diff --git a/VisualCard.Calendar/Parsers/VCalendarParserTools.cs b/VisualCard.Calendar/Parsers/VCalendarParserTools.cs index 6b2588a..dec5d95 100644 --- a/VisualCard.Calendar/Parsers/VCalendarParserTools.cs +++ b/VisualCard.Calendar/Parsers/VCalendarParserTools.cs @@ -45,6 +45,7 @@ internal static bool StringSupported(CalendarStringsEnum stringsEnum, Version ca CalendarStringsEnum.Status => true, CalendarStringsEnum.Summary => true, CalendarStringsEnum.Description => true, + CalendarStringsEnum.Transparency => true, _ => throw new InvalidOperationException("Invalid string enumeration type to get supported value"), }; @@ -88,6 +89,7 @@ internal static string GetPrefixFromStringsEnum(CalendarStringsEnum stringsEnum) CalendarStringsEnum.Status => VCalendarConstants._statusSpecifier, CalendarStringsEnum.Summary => VCalendarConstants._summarySpecifier, CalendarStringsEnum.Description => VCalendarConstants._descriptionSpecifier, + CalendarStringsEnum.Transparency => VCalendarConstants._transparencySpecifier, _ => throw new NotImplementedException($"String enumeration {stringsEnum} is not implemented.") }; @@ -170,6 +172,7 @@ internal static (PartType type, object enumeration, Type enumType, Func (PartType.Strings, CalendarStringsEnum.Status, null, null, "", "", []), VCalendarConstants._summarySpecifier => (PartType.Strings, CalendarStringsEnum.Summary, null, null, "", "", []), VCalendarConstants._descriptionSpecifier => (PartType.Strings, CalendarStringsEnum.Description, null, null, "", "", []), + VCalendarConstants._transparencySpecifier => (PartType.Strings, CalendarStringsEnum.Transparency, null, null, "", "", []), VCalendarConstants._prioritySpecifier => (PartType.Integers, CalendarIntegersEnum.Priority, null, null, "", "", []), VCalendarConstants._sequenceSpecifier => (PartType.Integers, CalendarIntegersEnum.Sequence, null, null, "", "", []), _ => diff --git a/VisualCard.Calendar/Parts/Enums/CalendarStringsEnum.cs b/VisualCard.Calendar/Parts/Enums/CalendarStringsEnum.cs index 65eb9ee..82a8e1f 100644 --- a/VisualCard.Calendar/Parts/Enums/CalendarStringsEnum.cs +++ b/VisualCard.Calendar/Parts/Enums/CalendarStringsEnum.cs @@ -60,5 +60,9 @@ public enum CalendarStringsEnum /// The calendar's summary (event, to-do, journal, or alarm) /// Summary, + /// + /// Event transparency + /// + Transparency, } } diff --git a/VisualCard.ShowCalendars/Properties/launchSettings.json b/VisualCard.ShowCalendars/Properties/launchSettings.json index 927f3b1..eb53e8b 100644 --- a/VisualCard.ShowCalendars/Properties/launchSettings.json +++ b/VisualCard.ShowCalendars/Properties/launchSettings.json @@ -11,6 +11,10 @@ "vCalendar 2.0 test - with attachment": { "commandName": "Project", "commandLineArgs": "TestFiles/veventAttach.vcs" + }, + "vCalendar 2.0 test - with transparency info": { + "commandName": "Project", + "commandLineArgs": "TestFiles/veventTransp.vcs" } } } diff --git a/VisualCard.ShowCalendars/TestFiles/veventTransp.vcs b/VisualCard.ShowCalendars/TestFiles/veventTransp.vcs new file mode 100644 index 0000000..e769796 --- /dev/null +++ b/VisualCard.ShowCalendars/TestFiles/veventTransp.vcs @@ -0,0 +1,12 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//ABC Corporation//NONSGML My Product//EN +BEGIN:VEVENT +UID:20070423T123432Z-541111@example.com +DTSTAMP:2007-04-23 12:34:32 +DTSTART;VALUE=DATE:2007-06-28 +DTEND;VALUE=DATE:2007-07-09 +SUMMARY:Festival International de Jazz de Montreal +TRANSP:TRANSPARENT +END:VEVENT +END:VCALENDAR diff --git a/VisualCard.ShowCalendars/VisualCard.ShowCalendars.csproj b/VisualCard.ShowCalendars/VisualCard.ShowCalendars.csproj index b7694a9..970dc1a 100644 --- a/VisualCard.ShowCalendars/VisualCard.ShowCalendars.csproj +++ b/VisualCard.ShowCalendars/VisualCard.ShowCalendars.csproj @@ -21,6 +21,9 @@ + + Always + Always