/// /// Copyright (c) 2020 Sensus Slovensko a.s. /// using System; using Config.CalendarEvent; namespace Config.Entities { public class CustomEvent : Config.CalendarEvent.ICalendarEvent { public virtual int Id { get; protected set; } public virtual DateTime Date { get; set; } /// The Date that the event occurs public virtual Frequency Frequency { get; set; } /// A value indicating how often the event occurs public virtual bool AllDay { get; set; } /// True if the time component of the date can be ignored public virtual 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 virtual string Source { get; set; } /// Source of this calendar event (becomes the source of the triggered event) public virtual string Title { get; set; } /// The name of the event (becomes the text of the triggered event) public virtual AutoAction AutoAction { get; set; } /// Automated action to be done or event to be triggered public virtual string Parameters { get; set; } /// Automated action parameters (e.g. name of a procedure to start) public virtual int Rank { get; set; } /// The ranking of the event that determines the order in which it is displayed on a particular day public virtual bool Hidden { get; set; } /// True if the event is enabled, otherwise false public virtual bool ReadOnly { get; set; } /// True if the event details cannot be modified public virtual int BackColor { get; set; } /// The color that the event show up in on the calendar: (MSB)AARRGGBB(LSB) public virtual int TextColor { get; set; } /// The text color of the event: (MSB)AARRGGBB(LSB) public virtual bool TooltipEnabled { get; set; } /// True if a tooltip should be displayed when hovering over the event public virtual CustomRecurringFrequenciesHandler CustomRecurringFunction { get; set; } /// Not mapped to DB, always null /// /// CustomEvent Constructor /// public CustomEvent() { } public CustomEvent(DateTime dateTime, string text) { Date = dateTime; Frequency = Config.CalendarEvent.Frequency.Once; AllDay = false; TriggerOnExactDayOnly = false; Source = "Calendar"; Title = text; AutoAction = AutoAction.None; Parameters = string.Empty; Rank = 2; Hidden = false; ReadOnly = false; BackColor = unchecked((int)0xFFFF5050); /// (MSB)AARRGGBB(LSB) ... pink TextColor = unchecked((int)0xFFFFFFFF); /// (MSB)AARRGGBB(LSB) ... white TooltipEnabled = true; CustomRecurringFunction = null; } public virtual Config.CalendarEvent.ICalendarEvent Clone() { return new CustomEvent { 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, }; } /// /// Returns true when updated /// /// Current date and time /// true when the entity was updated public virtual bool UpdateRecurringDate(DateTime currentDate) { return Config.CalendarEvent.Utils.UpdateRecurringDate(this, currentDate); } public override string ToString() { return Title; } } }