Skip to main content

SchedulerControlPrintAdapter.DisplayTimeRegions Property

Gets or sets whether Scheduler Reports should display existing Time Regions.

Namespace: DevExpress.XtraScheduler.Reporting

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

NuGet Package: DevExpress.Win.SchedulerReporting

Declaration

[DefaultValue(true)]
public bool DisplayTimeRegions { get; set; }

Property Value

Type Default Description
Boolean true

true if Time Regions are visible; otherwise, false.

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