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.v20.1.dll

Declaration

public event CustomDrawAppointmentFlyoutSubjectEventHandler CustomDrawAppointmentFlyoutSubject
Public Event CustomDrawAppointmentFlyoutSubject As CustomDrawAppointmentFlyoutSubjectEventHandler

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.

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.

Examples

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

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();
See Also