I know this is an old post but I thought I'd contribute to the knowledge community. I had a need for similar functionality. I needed to be able to change the event duration color or the event background color.
You have a couple of choices on how to implement this. The most basic thing you need to do is to modify the Event object to be able to take a BackColor and a DurationColor. This is in the Event.cs file. Simply add the following two variables:
public string BackColor;
public string DurationColor;
Then add a new Event constructor method that will accept the BackColor and DurationColor variables like this:
public Event(string pk, DateTime start, DateTime end, string name, string backcolor, string durationcolor, string resource)
{
this.PK = pk;
this.PK = pk;
this.Start = start;
this.End = end;
this.Name = name;
this.DurationColor = durationcolor;
this.BackColor = backcolor;
this.Resource = resource;
}
This is not all you need to do. You now need to go into the renderEvent method of the DayPilotCalendar.cs file and make sure you can set the correct colors. There is the following tag that will need to be modified. In my project it is on line 546 and you need to modify the following:
output.AddAttribute("onmouseout", "this.style.backgroundColor='" + (string.IsNullOrEmpty(e.BackColor) ? ColorTransform.ToHtml(EventBackColor) : e.BackColor) + "';event.cancelBubble=true;");
Then around line 556 you need to add:
output.AddStyleAttribute("background-color", string.IsNullOrEmpty(e.BackColor) ? ColorTranslator.ToHtml(EventBackColor) : e.BackColor);
finally to set the DurationColor you can set this on line 577
output.AddStyleAttribute("background-color", string.IsNullOrEmpty(e.DurationColor) ? ColorTranslator.ToHtml(DurationBarColor) : e.DurationColor);
That should allow you to start modifying the event colors based on the event. I have modified the Calendar Object to allow me to specify databound properties that will fill these values automatically but for brevity sake I'll leave those out of this response.
It is not too difficult to extend the Event object to allow for custom background colors or duration colors for the events. If you have questions just repond to this post.