windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-376f3a80.md
Handle this event to manually re-paint Time Regions.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.dll
NuGet Package : DevExpress.Win.Scheduler
public event EventHandler<CustomDrawTimeRegionEventArgs> CustomDrawTimeRegion
Public Event CustomDrawTimeRegion As EventHandler(Of CustomDrawTimeRegionEventArgs)
The CustomDrawTimeRegion event's data class is DevExpress.XtraScheduler.CustomDrawTimeRegionEventArgs.
In the DevExpress Scheduler demo this event is handled to draw a “lunch” icon on top of the 1p.m.~2p.m. region.
SvgImage svgImage = DemoUtils.GetResourceSvgImage("Images.Dinner.svg");
scheduler.CustomDrawTimeRegion += (s, e) => {
if (e.TimeRegion == timeRegion2)
return;
e.DrawDefault();
Rectangle bounds = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
double scaleFactor = bounds.Height / svgImage.Height;
Image img = svgImage.Render(null, Math.Min(scaleFactor, 1));
int x = e.Bounds.Location.X + (e.Bounds.Width / 2 - img.Width / 2);
int y = e.Bounds.Location.Y + (e.Bounds.Height / 2 - img.Height / 2);
e.Cache.DrawImage(img, new Point(x, y));
e.Handled = true;
};
Imports System
Dim svgImage As SvgImage = DemoUtils.GetResourceSvgImage("Images.Dinner.svg")
AddHandler scheduler.CustomDrawTimeRegion, Sub(s, e)
If e.TimeRegion = timeRegion2 Then
Return
End If
e.DrawDefault()
Dim bounds As New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
Dim scaleFactor As Double = bounds.Height \ svgImage.Height
Dim img As Image = svgImage.Render(Nothing, Math.Min(scaleFactor, 1))
Dim x As Integer = e.Bounds.Location.X + (e.Bounds.Width \ 2 - img.Width \ 2)
Dim y As Integer = e.Bounds.Location.Y + (e.Bounds.Height \ 2 - img.Height \ 2)
e.Cache.DrawImage(img, New Point(x, y))
e.Handled = True
End Sub
See Also