Skip to main content

SchedulerControl.CustomDrawNavigationButton Event

Enables navigation buttons to be painted manually.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.1.dll

NuGet Package: DevExpress.Win.Scheduler

Declaration

public event CustomDrawObjectEventHandler CustomDrawNavigationButton

Event Data

The CustomDrawNavigationButton event's data class is CustomDrawObjectEventArgs. The following properties provide information specific to this event:

Property Description
Bounds Returns the bounding rectangle of the drawing area.
Cache Gets an object which specifies the storage for the pens, fonts and brushes. Use it for custom painting in Scheduler Reports.
Graphics Gets an object used for painting.
Handled Gets or sets whether an event was handled. If it was handled, the default actions are not required.
ObjectInfo Gets information on the painted element.

The event data class exposes the following methods:

Method Description
DrawDefault() Renders the element using the default drawing mechanism.
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements.
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event.
GetDisplayValue(String)
GetValue(String)

Remarks

The CustomDrawNavigationButton event occurs before a navigation button is painted. The event parameter’s CustomDrawObjectEventArgs.ObjectInfo property provides information sufficient to paint a navigation button.

Example

This code example modifies the caption of the navigation button to display the number of appointments located within the discoverable time interval of a navigation button. This interval is specified by the SchedulerNavigationButtonOptions.AppointmentSearchInterval property. When one or more appointments fall in this interval, the navigation button becomes active and navigates to the nearest appointment. The navigation button is disabled if there are no appointments in that interval.

CustomDrawNavigationButton_New

public static void scheduler_CustomDrawNavigationButton(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
{
    NavigationButtonNext navButton = e.ObjectInfo as NavigationButtonNext;
    SchedulerControl scheduler = sender as SchedulerControl;
    SchedulerStorage storage = scheduler.Storage as SchedulerStorage;
    // Do not count by resources.
    if (scheduler.GroupType != SchedulerGroupType.None) return;

    if (navButton != null && scheduler != null && storage != null)
    {
        // Count appointments within the interval used by the Next navigation button.
        AppointmentBaseCollection apts = scheduler.Storage.Appointments.Items;
        TimeSpan aptSearchInterval = scheduler.OptionsView.NavigationButtons.AppointmentSearchInterval;
        DateTime lastVisibleTime = scheduler.ActiveView.GetVisibleIntervals().Last().End;
        int aptCount = apts.Where(a => (a.Start > lastVisibleTime) && (a.Start < lastVisibleTime.Add(aptSearchInterval))).Count();
        navButton.DisplayTextItem.Text = String.Format("Next {0} appointments", aptCount);
    }
}
See Also