tbf/TBF/UI/Calendar/CalibrationReminderEvent.cs

93 lines
4.1 KiB
C#
Raw Normal View History

using System;
using System.Drawing;
using Config.CalendarEvent;
namespace TBF.UI.Calendar
{
/// <summary>
/// An event that defines a calibration reminder
/// </summary>
public class CalibrationReminderEvent : ICalendarEvent
{
public DateTime Date { get; set; } /// The Date that the event occurs
public Frequency Frequency { get; set; } /// A value indicating how often the event occurs
public bool AllDay { get; set; } /// True if the time component of the date can be ignored
public bool TriggerOnExactDayOnly { get; set; } /// If this is a recurring event, set this to true to make the event show up only from the day specified forward
public string Source { get; set; } /// Source of this calendar event (becomes the source of the triggered event)
public string Title { get; set; } /// The name of the event (becomes the text of the triggered event)
public AutoAction AutoAction { get; set; } /// Automated action to be done or event to be triggered (triggered event Severity)
public string Parameters { get; set; } /// Automated action parameters (e.g. name of a procedure to start)
public int Rank { get; set; } /// The ranking of the event that determines the order in which it is displayed on a particular day
public bool Hidden { get; set; } /// True if the event is enabled, otherwise false
public bool ReadOnly { get; set; } /// True if the event details cannot be modified
public int BackColor { get; set; } /// The color that the event show up in on the calendar: (MSB)AARRGGBB(LSB)
public int TextColor { get; set; } /// The text color of the event: (MSB)AARRGGBB(LSB)
public bool TooltipEnabled { get; set; } /// True if a tooltip should be displayed when hovering over the event
public Config.CalendarEvent.CustomRecurringFrequenciesHandler CustomRecurringFunction { get; set; }
2023-04-18 12:01:23 +00:00
private CalibrationReminderEvent() { }
/// <summary>
/// CalibrationReminderEvent Constructor
/// </summary>
2023-04-18 12:01:23 +00:00
public CalibrationReminderEvent(AutoAction autoAction)
{
/// Date
2023-04-18 12:01:23 +00:00
Frequency = Frequency.Once;
AllDay = true;
TriggerOnExactDayOnly = false;
/// Source
/// Text
2023-04-18 12:01:23 +00:00
AutoAction = autoAction;
Parameters = string.Empty;
Rank = 1;
Hidden = true;
ReadOnly = true;
2023-04-18 12:01:23 +00:00
BackColor = unchecked((int)0xFFA00000); /// (MSB)AARRGGBB(LSB) ... red
TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white
TooltipEnabled = true;
}
2023-04-18 12:01:23 +00:00
public CalibrationReminderEvent(AutoAction autoAction, DateTime date, string source, string text)
: this(autoAction)
{
Date = date;
Source = source;
Title = text;
}
public ICalendarEvent Clone()
{
return new CalibrationReminderEvent
{
Date = this.Date,
Frequency = this.Frequency,
AllDay = this.AllDay,
TriggerOnExactDayOnly = this.TriggerOnExactDayOnly,
Source = this.Source,
Title = this.Title,
AutoAction = this.AutoAction,
Parameters = this.Parameters,
Rank = this.Rank,
Hidden = this.Hidden,
ReadOnly = this.ReadOnly,
BackColor = this.BackColor,
TextColor = this.TextColor,
TooltipEnabled = this.TooltipEnabled,
CustomRecurringFunction = this.CustomRecurringFunction,
};
}
public override string ToString()
{
if (string.IsNullOrEmpty(Source))
{
return Title;
}
return string.Format("{0}: {1}", Source, Title);
}
}
}