CustomDrawObjectEventArgs.Graphics Property
Gets an object used for painting.
Namespace: DevExpress.XtraScheduler
Assembly: DevExpress.XtraScheduler.v18.2.dll
Declaration
public virtual Graphics Graphics { get; }
Public Overridable ReadOnly Property Graphics As Graphics
Property Value
Type | Description |
---|---|
Graphics | A Graphics object which provides a means for painting. |
Remarks
The Graphics property returns an object which represents the painting surface and provides a means for painting. You can use methods and properties of this object to paint text, graphics primitives and images.
NOTE
Do not use this property for custom draw in Scheduler Reporting. Use the CustomDrawObjectEventArgs.Cache and the e.Cache.Paint method instead.
Examples
The following sample code handles the SchedulerControl.CustomDrawAppointment event to manually paint appointments. The image below shows the result.
NOTE
A complete sample project is available at https://github.com/DevExpress-Examples/customdrawappointment-customdrawappointmentbackground-e1142
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.X += 3;
r.Y += 3;
string[] s = tlvi.Appointment.Subject.Split(' ');
for(int i = 0; i < s.Length; i++) {
e.Cache.DrawString(s[i], tlvi.Appearance.Font, new SolidBrush(colorArray[i]),
r, StringFormat.GenericDefault);
SizeF shift = e.Graphics.MeasureString(s[i] + " ", tlvi.Appearance.Font);
r.X += (int)shift.Width;
}
e.Handled = true;
}
}