Skip to main content

SchedulerStoragePrintAdapter.TimeRegions Property

Allows access to the collection of TimeRegion objects displayed at Scheduler Reports.

Namespace: DevExpress.XtraScheduler.Reporting

Assembly: DevExpress.XtraScheduler.v24.2.Reporting.dll

Declaration

[Browsable(false)]
public IList<TimeRegion> TimeRegions { get; }

Property Value

Type Description
IList<TimeRegion>

Stores Time Regions displayed on Scheduler reports.

Remarks

TimeRegion objects allow you to create time intervals that impose specific restrictions on appointments. For instance, a Time Region can prevent users from adding new appointments to this interval, or modify appointments that already belong to it.

Time Regions have their own appearance so that users can identify them at runtime, but are hidden in Reports. Use the corresponding approach to display Time Regions based on whether you utilize the SchedulerControlPrintAdapter or SchedulerStoragePrintAdapter component to generate reports.

SchedulerControlPrintAdapter

A SchedulerControlPrintAdapter receives all data directly from the Scheduler Control, including Time Regions. To display them, enable the DisplayTimeRegions property.

buttonReport.Click += (s, e) => {
    var xr = new myXtraSchedulerReport();
    SchedulerControlPrintAdapter adp = new SchedulerControlPrintAdapter(schedulerControl1);
    adp.DisplayTimeRegions = true;
    xr.SchedulerAdapter = adp;
    var printTool = new DevExpress.XtraReports.UI.ReportPrintTool(xr);
    printTool.ShowPreview();
};

This approach does not allow you to choose which Time Regions should be visible.

SchedulerStoragePrintAdapter

A SchedulerStoragePrintAdapter receives data from a Scheduler Data Storage. Time Regions belong to a control itself and are not kept in the Storage. For this reason, the Adapter cannot access Time Regions and you need to populate the TimeRegions collection. This allows you to control which Time Regions should be visible in Reports.

buttonReport.Click += (s, e) => {
    var xr = new myXtraSchedulerReport();
    SchedulerStoragePrintAdapter adp = new SchedulerStoragePrintAdapter(schedulerStorage1);
    TimeRegion tr = new TimeRegion();
    tr.Start = baseDate.AddHours(6);
    tr.End = baseDate.AddHours(18);
    tr.Editable = true;
    tr.Recurrence = new RecurrenceInfo();
    tr.Recurrence.Start = tr.Start;
    tr.Recurrence.Type = RecurrenceType.Weekly;
    tr.Recurrence.WeekDays = WeekDays.WorkDays;
    adp.TimeRegions.Add(tr);
    xr.SchedulerAdapter = adp;
    var printTool = new DevExpress.XtraReports.UI.ReportPrintTool(xr);
    printTool.ShowPreview();
};

Custom Draw Time Regions

Regardless of the adapter component type used, you can handle the TimeCellsControlBase.CustomDrawTimeRegion event to redraw Time Regions.

private void DvTimeCells_CustomDrawTimeRegion(object sender, CustomDrawTimeRegionEventArgs e) {
    DateTime baseDate = DateTimeHelper.GetStartOfWeek(DateTime.Today);
    baseDate = baseDate.AddDays(-15);
    if (e.TimeRegion.Start == baseDate.AddHours(6) && e.TimeRegion.End == baseDate.AddHours(18)) {
        e.Cache.FillRectangle(System.Drawing.Brushes.IndianRed, e.Bounds);
    }
}
See Also