Skip to main content

SchedulerControl.CustomDrawAppointmentFlyoutSubject Event

Occurs before displaying the appointment flyout. Follows the SchedulerControl.CustomizeAppointmentFlyout event. Enables you to manually draw the visual elements composing the Subject rectangle without having to do a full default draw.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.2.dll

NuGet Package: DevExpress.Win.Scheduler

Declaration

public event CustomDrawAppointmentFlyoutSubjectEventHandler CustomDrawAppointmentFlyoutSubject

Event Data

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

Property Description
Appointment Provides access to an appointment for which the flyout is invoked.
Bounds Returns the bounding rectangle of the drawing area. Inherited from CustomDrawObjectEventArgs.
Cache Gets an object which specifies the storage for the pens, fonts and brushes. Use it for custom painting in Scheduler Reports. Inherited from CustomDrawObjectEventArgs.
Graphics Gets an object used for painting. Inherited from CustomDrawObjectEventArgs.
Handled Gets or sets whether an event was handled. If it was handled, the default actions are not required. Inherited from CustomDrawObjectEventArgs.
ObjectInfo Gets information on the painted element. Inherited from CustomDrawObjectEventArgs.
StatusBounds Gets the location and size of the status line in the flyout’s Subject rectangle.

The event data class exposes the following methods:

Method Description
DrawBackgroundDefault() Renders the Subject rectangle background using the default drawing mechanism.
DrawDefault() Renders the element using the default drawing mechanism. Inherited from CustomDrawObjectEventArgs.
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. Inherited from CustomDrawObjectEventArgs.
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event. Inherited from CustomDrawObjectEventArgs.
DrawStatusDefault() Renders the status line using the default drawing mechanism.
GetDisplayValue(String) Inherited from CustomDrawObjectEventArgs.
GetValue(String) Inherited from CustomDrawObjectEventArgs.

Remarks

If the SchedulerOptionsCustomization.AllowDisplayAppointmentFlyout property is false, the CustomDrawAppointmentFlyoutSubject event as well as the SchedulerControl.CustomizeAppointmentFlyout event do not occur.

If the SchedulerControl.CustomizeAppointmentFlyout event is handled and the CustomizeAppointmentFlyoutEventArgs.ShowSubject property is set to false, the CustomDrawAppointmentFlyoutSubject event does not occur.

Example

The following code handles the SchedulerControl.CustomDrawAppointmentFlyoutSubject event to draw a status line above the subject text and display a warning message if the status is AppointmentStatusType.Free.

CustomDrawAppointmentFlyoutSubject_Example

View Example

void OnSchedulerControlCustomDrawAppointmentFlyoutSubject(object sender, CustomDrawAppointmentFlyoutSubjectEventArgs e) {
    e.Handled = true;
    CustomDrawAppointmentFlyoutSubject(e);
}
void CustomDrawAppointmentFlyoutSubject(CustomDrawAppointmentFlyoutSubjectEventArgs e) {
    AppointmentBandDrawerViewInfoBase viewInfo = (AppointmentBandDrawerViewInfoBase)e.ObjectInfo;
    e.DrawBackgroundDefault();
    CustomDrawAppointmentFlyoutSubject(e.Appointment, viewInfo);
}
void CustomDrawAppointmentFlyoutSubject(Appointment appointment, AppointmentBandDrawerViewInfoBase viewInfo) {
    GraphicsCache cache = viewInfo.Cache;
    StringFormat stringFormat = new StringFormat(viewInfo.View.Appearance.GetStringFormat());
    stringFormat.Alignment = stringFormat.LineAlignment = StringAlignment.Center;
    try {
        // Draw status
        Rectangle statusRect = GetStatusBounds(viewInfo);
        cache.FillRectangle(viewInfo.View.Status.GetBrush(), statusRect);

        if (viewInfo.View.Status.Type == AppointmentStatusType.Free) {
            // Draw a warning
            cache.DrawImage(GetWarningIcon(new Size(statusRect.Height, statusRect.Height)), statusRect.Location);
            cache.DrawString("Status is unacceptable", fontStorage.StatusFont, Brushes.Red, statusRect, stringFormat);
        }
        // Draw subject                        
        cache.DrawString(appointment.Subject, fontStorage.SubjectFont, Brushes.Black, GetSubjectBounds(viewInfo), stringFormat);
    }
    finally {
        stringFormat.Dispose();
    }
}
Rectangle GetSubjectBounds(AppointmentBandDrawerViewInfoBase viewInfo) {
    Rectangle bounds = viewInfo.Bounds;
    if (viewInfo.View.Status.Type == AppointmentStatusType.Free) {
        bounds.Offset(0, 10);
    }
    return bounds;
}
Rectangle GetStatusBounds(AppointmentBandDrawerViewInfoBase viewInfo) {
    Rectangle bounds = Rectangle.Inflate(viewInfo.Bounds, -1, -1);
    if (viewInfo.View.Status.Type == AppointmentStatusType.Free) {
        bounds.Height = 20;
    }
    else {
        bounds.Height = 5;
    }
    return bounds;
}
Image GetWarningIcon(Size size) {
    using (Stream stream = AppAssembly.GetManifestResourceStream("CustomAppointmentFlyoutExample.warning.svg")) {
        var paletteProvider = SvgPaletteHelper.GetSvgPalette(schedulerControl1.LookAndFeel, ObjectState.Selected);
        return SvgBitmap.FromStream(stream).Render(size, paletteProvider);
    }
}
static readonly Assembly AppAssembly = Assembly.GetExecutingAssembly();

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawAppointmentFlyoutSubject event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also