mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-20 05:48:14 +08:00
Add custom highligh style for single calendar event
This commit is contained in:

committed by
Patrik Svensson

parent
32361d3f15
commit
32384f7b8d
@ -195,10 +195,11 @@ public sealed class Calendar : JustInTimeRenderable, IHasCulture, IHasTableBorde
|
||||
while (currentDay <= daysInMonth)
|
||||
{
|
||||
if (weekdays[currentDay - 1] == weekday)
|
||||
{
|
||||
if (_calendarEvents.Any(e => e.Month == Month && e.Day == currentDay))
|
||||
{
|
||||
var todayEvent = _calendarEvents.LastOrDefault(e => e.Month == Month && e.Day == currentDay);
|
||||
if (todayEvent != null)
|
||||
{
|
||||
row.Add(new Markup(currentDay.ToString(CultureInfo.InvariantCulture) + "*", _highlightStyle));
|
||||
row.Add(new Markup(currentDay.ToString(CultureInfo.InvariantCulture) + "*", todayEvent.CustomHighlightStyle ?? _highlightStyle));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -25,29 +25,38 @@ public sealed class CalendarEvent
|
||||
/// </summary>
|
||||
public int Day { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the custom highlight style of the calendar event.
|
||||
/// </summary>
|
||||
public Style? CustomHighlightStyle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CalendarEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="year">The year of the calendar event.</param>
|
||||
/// <param name="month">The month of the calendar event.</param>
|
||||
/// <param name="day">The day of the calendar event.</param>
|
||||
public CalendarEvent(int year, int month, int day)
|
||||
: this(string.Empty, year, month, day)
|
||||
/// <param name="day">The day of the calendar event.</param>
|
||||
/// <param name="customHighlightStyle">The custom highlight style of the calendar event.</param>
|
||||
public CalendarEvent(int year, int month, int day, Style? customHighlightStyle = null)
|
||||
: this(string.Empty, year, month, day, customHighlightStyle)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CalendarEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="description">The calendar event description.</param>
|
||||
/// <param name="year">The year of the calendar event.</param>
|
||||
/// <param name="month">The month of the calendar event.</param>
|
||||
/// <param name="day">The day of the calendar event.</param>
|
||||
public CalendarEvent(string description, int year, int month, int day)
|
||||
/// <param name="day">The day of the calendar event.</param>
|
||||
/// <param name="customHighlightStyle">The custom highlight style of the calendar event.</param>
|
||||
public CalendarEvent(string description, int year, int month, int day, Style? customHighlightStyle = null)
|
||||
{
|
||||
Description = description ?? string.Empty;
|
||||
Year = year;
|
||||
Month = month;
|
||||
Day = day;
|
||||
Day = day;
|
||||
CustomHighlightStyle = customHighlightStyle;
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user