Skip to main content

SchedulerControl.CustomDrawTimeRegion Event

Handle this event to manually re-paint Time Regions.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.2.dll

Declaration

public event EventHandler<CustomDrawTimeRegionEventArgs> CustomDrawTimeRegion

Event Data

The CustomDrawTimeRegion event's data class is DevExpress.XtraScheduler.CustomDrawTimeRegionEventArgs.

Remarks

In the DevExpress Scheduler demo this event is handled to draw a “lunch” icon on top of the 1p.m.~2p.m. region.

Time Regions

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;
};
See Also