/// <summary> /// Updates the help text. /// </summary> private void UpdateHelpText() { var fakeSchedule = new Rock.Model.Schedule(); fakeSchedule.iCalendarContent = sbSchedule.iCalendarContent; sbSchedule.ToolTip = fakeSchedule.ToFriendlyScheduleText(); hbSchedulePreview.Text = @"<strong>iCalendar Content</strong> <div style='white-space: pre' Font-Names='Consolas' Font-Size='9'><br />" + sbSchedule.iCalendarContent + "</div>"; iCalendar calendar = iCalendar.LoadFromStream(new StringReader(sbSchedule.iCalendarContent)).First() as iCalendar; DDay.iCal.Event calendarEvent = calendar.Events[0] as Event; if (calendarEvent.DTStart != null) { List <Occurrence> nextOccurrences = calendar.GetOccurrences(RockDateTime.Now, RockDateTime.Now.AddYears(1)).Take(26).ToList(); string listHtml = "<hr /><strong>Occurrences Preview</strong><ul>"; foreach (var occurrence in nextOccurrences) { listHtml += "<li>" + GetOccurrenceText(occurrence) + "</li>"; } listHtml += string.Format("<li>{0}</li>", "..."); listHtml += "</ul>"; hbSchedulePreview.Text += listHtml; } }
/// <summary> /// Updates the help text. /// </summary> private void UpdateHelpText() { var fakeSchedule = new Rock.Model.Schedule(); fakeSchedule.iCalendarContent = sbSchedule.iCalendarContent; sbSchedule.ToolTip = fakeSchedule.ToFriendlyScheduleText(true); var sbPreviewHtml = new System.Text.StringBuilder(); sbPreviewHtml.Append($@"<strong>iCalendar Content</strong><div style='white-space: pre' Font-Names='Consolas' Font-Size='9'><br />{ sbSchedule.iCalendarContent }</div>"); var calendar = Calendar.LoadFromStream(new StringReader(sbSchedule.iCalendarContent)).First() as Calendar; var calendarEvent = calendar.Events[0] as Event; if (calendarEvent.DtStart != null) { var nextOccurrences = calendar.GetOccurrences(RockDateTime.Now, RockDateTime.Now.AddYears(1)).Take(26).ToList(); var sbOccurrenceItems = new System.Text.StringBuilder(); if (nextOccurrences.Any()) { foreach (var occurrence in nextOccurrences) { sbOccurrenceItems.Append($"<li>{GetOccurrenceText( occurrence )}</li>"); } } else { sbOccurrenceItems.Append("<li>No future occurrences</l1>"); } sbPreviewHtml.Append($"<hr /><strong>Occurrences Preview</strong><ul>{sbOccurrenceItems}</ul>"); } litPreview.Text = litPreviewFormat.Text.Replace("{previewHtml}", sbPreviewHtml.ToString()); }
/// <summary> /// Updates the help text. /// </summary> private void UpdateHelpText() { var fakeSchedule = new Rock.Model.Schedule(); fakeSchedule.iCalendarContent = sbSchedule.iCalendarContent; sbSchedule.ToolTip = fakeSchedule.ToFriendlyScheduleText(); hbSchedulePreview.Text = @"<strong>iCalendar Content</strong> <div style='white-space: pre' Font-Names='Consolas' Font-Size='9'><br />" + sbSchedule.iCalendarContent + "</div>"; iCalendar calendar = iCalendar.LoadFromStream(new StringReader(sbSchedule.iCalendarContent)).First() as iCalendar; DDay.iCal.Event calendarEvent = calendar.Events[0] as Event; if (calendarEvent.DTStart != null) { List <Occurrence> nextOccurrences = calendar.GetOccurrences(DateTime.Now.Date, DateTime.Now.Date.AddYears(1)).Take(26).ToList(); string listHtml = "<hr /><strong>Occurrences Preview</strong><ul>"; foreach (var occurrence in nextOccurrences) { if (occurrence.Period.StartTime.Value.Date.Equals(occurrence.Period.EndTime.Value.Date)) { listHtml += string.Format("<li>{0} - {1} to {2} ( {3} hours) </li>", occurrence.Period.StartTime.Value.Date.ToShortDateString(), occurrence.Period.StartTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.EndTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.Duration.TotalHours.ToString("#0.00")); } else { listHtml += string.Format("<li>{0} to {1} ( {2} hours) </li>", occurrence.Period.StartTime.Value.ToString("g"), occurrence.Period.EndTime.Value.ToString("g"), occurrence.Period.Duration.TotalHours.ToString("#0.00")); } } listHtml += string.Format("<li>{0}</li>", "..."); listHtml += "</ul>"; hbSchedulePreview.Text += listHtml; } }
/// <summary> /// Updates the help text. /// </summary> private void UpdateHelpText() { var fakeSchedule = new Rock.Model.Schedule(); fakeSchedule.iCalendarContent = sbSchedule.iCalendarContent; sbSchedule.ToolTip = fakeSchedule.ToFriendlyScheduleText(); hbSchedulePreview.Text = @"<strong>iCalendar Content</strong> <div style='white-space: pre' Font-Names='Consolas' Font-Size='9'><br />" + sbSchedule.iCalendarContent + "</div>"; iCalendar calendar = iCalendar.LoadFromStream( new StringReader( sbSchedule.iCalendarContent ) ).First() as iCalendar; DDay.iCal.Event calendarEvent = calendar.Events[0] as Event; if ( calendarEvent.DTStart != null ) { List<Occurrence> nextOccurrences = calendar.GetOccurrences( RockDateTime.Now, RockDateTime.Now.AddYears( 1 ) ).Take( 26 ).ToList(); string listHtml = "<hr /><strong>Occurrences Preview</strong><ul>"; foreach ( var occurrence in nextOccurrences ) { listHtml += "<li>" + GetOccurrenceText( occurrence ) + "</li>"; } listHtml += string.Format( "<li>{0}</li>", "..." ); listHtml += "</ul>"; hbSchedulePreview.Text += listHtml; } }
/// <summary> /// Updates the help text. /// </summary> private void UpdateHelpText() { var fakeSchedule = new Rock.Model.Schedule(); fakeSchedule.iCalendarContent = sbSchedule.iCalendarContent; sbSchedule.ToolTip = fakeSchedule.ToFriendlyScheduleText(); hbSchedulePreview.Text = @"<strong>iCalendar Content</strong> <div style='white-space: pre' Font-Names='Consolas' Font-Size='9'><br />" + sbSchedule.iCalendarContent + "</div>"; iCalendar calendar = iCalendar.LoadFromStream( new StringReader( sbSchedule.iCalendarContent ) ).First() as iCalendar; DDay.iCal.Event calendarEvent = calendar.Events[0] as Event; if ( calendarEvent.DTStart != null ) { List<Occurrence> nextOccurrences = calendar.GetOccurrences( DateTime.Now.Date, DateTime.Now.Date.AddYears( 1 ) ).Take( 26 ).ToList(); string listHtml = "<hr /><strong>Occurrences Preview</strong><ul>"; foreach ( var occurrence in nextOccurrences ) { if ( occurrence.Period.StartTime.Value.Date.Equals( occurrence.Period.EndTime.Value.Date ) ) { listHtml += string.Format( "<li>{0} - {1} to {2} ( {3} hours) </li>", occurrence.Period.StartTime.Value.Date.ToShortDateString(), occurrence.Period.StartTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.EndTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.Duration.TotalHours.ToString( "#0.00" ) ); } else { listHtml += string.Format( "<li>{0} to {1} ( {2} hours) </li>", occurrence.Period.StartTime.Value.ToString( "g" ), occurrence.Period.EndTime.Value.ToString( "g" ), occurrence.Period.Duration.TotalHours.ToString( "#0.00" ) ); } } listHtml += string.Format( "<li>{0}</li>", "..." ); listHtml += "</ul>"; hbSchedulePreview.Text += listHtml; } }