private void schedulerControl1_CustomDrawDayViewTimeRuler(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { SchedulerControl scheduler = (SchedulerControl)sender; TimeSpan now = DateTime.Now.TimeOfDay; TimeRulerViewInfo viewInfo = (TimeRulerViewInfo)e.ObjectInfo; Rectangle rect = viewInfo.ContentBounds; Rectangle nowRect = rect; DayViewInfo dayViewInfo = scheduler.DayView.ViewInfo as DayViewInfo; if (dayViewInfo.VisibleRowsCount == 0) { return; } float offsetRatio = (now - scheduler.DayView.TopRowTime).Ticks / (float)TimeSpan.FromTicks(scheduler.DayView.TimeScale.Ticks * dayViewInfo.VisibleRowsCount).Ticks; if (offsetRatio < 0) { return; } nowRect.Height = 4; nowRect.Y += (int)Math.Round(rect.Height * offsetRatio - (float)nowRect.Height / 2); e.DrawDefault(); e.Cache.FillRectangle(Brushes.Red, nowRect); e.Handled = true; }
public static void scheduler_CustomDrawDayViewTimeRuler(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { TimeRulerViewInfo info = e.ObjectInfo as TimeRulerViewInfo; // Clear all captions. foreach (var item in info.Items) { ViewInfoTextItem viewInfoText = item as ViewInfoTextItem; if (viewInfoText != null) { viewInfoText.Text = string.Empty; } } // Draw the TimeRuler as usual, but with empty captions. e.DrawDefault(); // Draw the image in the header. Image im = Image.FromFile("image.png"); Rectangle imageBounds = new Rectangle(info.HeaderBounds.X, info.HeaderBounds.Y, im.Width, im.Height); e.Cache.Graphics.DrawImage(im, imageBounds); // Cancel default painting procedure. e.Handled = true; }