Set event bacground image without repeating
Asked by Cezar9 years ago.
How can I use event background image as one image (not million times repeated)? I'd like to have it on bottom-right place of event just once.
I used this code:
switch (ev.PaymentType)
{
case PaymentType.Cash:
{
e.BackgroundImage = "/Content/images/cash.png";
break;
}
case PaymentType.Invoice:
{
e.BackgroundImage = "/Content/images/invoice.png";
break;
}
case PaymentType.Groupon:
{
e.BackgroundImage = "/Content/images/groupon.png";
break;
}
}
Comment posted by Cezar9 years ago.
OK I used "no-repeat" in e.BackgroundRepeat, but how can I place my image in bottom left/right corner?
Answer posted by Dan Letecky [DayPilot]9 years ago.
You can use an active area (https://doc.daypilot.org/scheduler/event-active-areas/ ) to place a custom rectangle the the specified position. Like this:
e.Areas.Add(new Area().Bottom(0).Left(0).Width(15).Height(15).Html("<img src='yourimage.png' />").Visible();
You can also use a CSS class instead:
e.Areas.Add(new Area().Bottom(0).Left(0).Width(15).Height(15).CssClass("bg-yourimage").Visible();
Just note that the active areas are placed above the event content.
Comment posted by Cezar9 years ago.
Tried
e.Areas.Add(new Area().Bottom(0).Left(0).Width(15).Height(15).Html("<img src='/Content/images/cash.png'").Visible());
But nothing is visible. Also tried src='~/Content/images/cash.png'", src='Content/images/cash.png'", src=\"/Content/images/cash.png\""
Comment posted by Dan Letecky [DayPilot]9 years ago.
It looks like the tag isn't closed properly (missing '>'). Try this:
e.Areas.Add(new Area().Bottom(0).Left(0).Width(15).Height(15).Html("<img src='yourimage.png' />").Visible();
Comment posted by Cezar9 years ago.
Ah, right, we both forgot that. Now it works.
Comment posted by Dan Letecky [DayPilot]9 years ago.
Great, thanks for the update. I've fixed it in my answer above as well.
This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.