Back to Devexpress

CustomDrawObjectEventArgs Class

windowsforms-devexpress-dot-xtrascheduler-803249e6.md

latest8.4 KB
Original Source

CustomDrawObjectEventArgs Class

Provides data for the custom draw events of the SchedulerControl.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public class CustomDrawObjectEventArgs :
    EventArgs,
    IDxHtmlFieldValueProvider
vb
Public Class CustomDrawObjectEventArgs
    Inherits EventArgs
    Implements IDxHtmlFieldValueProvider

CustomDrawObjectEventArgs is the data class for the following events:

Show 25 events

Remarks

The custom draw events occur before any scheduler element is painted. The CustomDrawObjectEventArgs class introduces several properties to represent all objects necessary to implement the custom drawing of a scheduler element.

If CustomDrawObjectEventArgs.Handled is set to true, the default painting is not performed after the handler code execution. Use CustomDrawObjectEventArgs.DrawDefault method in the handler code to render the element using the default drawing mechanism.

Note

When handling custom draw events in Scheduler Reporting , use only CustomDrawObjectEventArgs.Cache or e.Cache.Paint methods. Do not use CustomDrawObjectEventArgs.Graphics methods.

Example

The following sample code handles the SchedulerControl.CustomDrawAppointment event to manually paint appointments. The image below shows the result.

View Example

csharp
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System.Drawing.Drawing2D;
private void schedulerControl1_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e) {
    TimeLineAppointmentViewInfo tlvi = e.ObjectInfo as TimeLineAppointmentViewInfo;
    // This code works only for the Timeline View.
    if(tlvi != null) {
        Rectangle r = e.Bounds;
        r.Offset(3, 3);
        string[] s = tlvi.Appointment.Subject.Split(' ');

        for(int i = 0; i < s.Length; i++) {
            using(var foreBrush = new SolidBrush(colorArray[i]))
                e.Cache.DrawString(s[i], tlvi.Appearance.Font, foreBrush,
r, StringFormat.GenericDefault);
            SizeF shift = e.Cache.CalcTextSize(s[i] + " ", tlvi.Appearance.Font);
            r.X += (int)shift.Width;
        }
        e.Handled = true;
    }
}
vb
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.Drawing
Imports System.Drawing.Drawing2D
Private Sub schedulerControl1_CustomDrawAppointment(ByVal sender As Object, ByVal e As CustomDrawObjectEventArgs) Handles schedulerControl1.CustomDrawAppointment
    Dim tlvi As TimeLineAppointmentViewInfo = TryCast(e.ObjectInfo, TimeLineAppointmentViewInfo)
    ' This code works only for the Timeline View.
    If tlvi IsNot Nothing Then
        Dim r As Rectangle = e.Bounds
        r.Offset(3, 3)
        Dim s() As String = tlvi.Appointment.Subject.Split(" "c)

        For i As Integer = 0 To s.Length - 1
            Using foreBrush = New SolidBrush(colorArray(i))
                e.Cache.DrawString(s(i), tlvi.Appearance.Font, foreBrush, r, StringFormat.GenericDefault)
            End Using
            Dim shift As SizeF = e.Cache.CalcTextSize(s(i) & " ", tlvi.Appearance.Font)
            r.X += CInt(shift.Width)
        Next i
        e.Handled = True
    End If
End Sub

Inheritance

Object EventArgs CustomDrawObjectEventArgs CustomDrawAppointmentFlyoutSubjectEventArgs

See Also

CustomDrawObjectEventArgs Members

How to: Custom Paint Appointments

How to: Custom Paint Day Headers

How to: Hide Grid Lines in the View

DevExpress.XtraScheduler Namespace