Example #1
0
        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;
        }
Example #2
0
        public static void scheduler_CustomDrawGroupSeparator(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
        {
            e.DrawDefault();
            Image     im          = Image.FromFile("image.png");
            Rectangle imageBounds = new Rectangle(e.Bounds.X - (im.Width / 2), e.Bounds.Y, im.Width, im.Height);

            e.Cache.Graphics.DrawImage(im, imageBounds);
            e.Handled = true;
        }
Example #3
0
        public static void scheduler_CustomDrawResourceHeader(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
        {
            ResourceHeader header = (ResourceHeader)e.ObjectInfo;
            // Get the resource information from custom fields.
            string postcode = (header.Resource.CustomFields["PostCode"] != null) ? header.Resource.CustomFields["PostCode"].ToString() : String.Empty;
            string address  = (header.Resource.CustomFields["Address"] != null) ? header.Resource.CustomFields["Address"].ToString() : String.Empty;

            // Specify the header caption and appearance.
            header.Appearance.HeaderCaption.ForeColor = Color.Blue;
            header.Caption = header.Resource.Caption + System.Environment.NewLine + address + System.Environment.NewLine + postcode;
            header.Appearance.HeaderCaption.Font = e.Cache.GetFont(header.Appearance.HeaderCaption.Font, FontStyle.Bold);
            // Draw the header using default methods.
            e.DrawDefault();
            e.Handled = true;
        }
Example #4
0
        public static void scheduler_CustomDrawWeekViewTopLeftCorner(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
        {
            e.DrawDefault();
            UpperLeftCorner objectToDraw = e.ObjectInfo as UpperLeftCorner;
            string          text         = "Employee";
            // Draw the text rotated 45 degrees counterclockwise.
            Font  myFont   = objectToDraw.CaptionAppearance.Font;
            SizeF textSize = e.Graphics.MeasureString(text, myFont);

            e.Graphics.TranslateTransform(e.Bounds.Width / 2, e.Bounds.Height / 2);
            e.Graphics.RotateTransform(-45f);
            e.Graphics.DrawString(text, myFont, Brushes.Blue, -(textSize.Width / 2.0f), -(textSize.Height / 2.0f));
            e.Graphics.RotateTransform(45f);
            e.Graphics.TranslateTransform(-e.Bounds.Width / 2, -e.Bounds.Height / 2);
            e.Handled = true;
        }
Example #5
0
        public static void scheduler_CustomDrawTimeIndicator(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
        {
            TimeIndicatorViewInfo info      = e.ObjectInfo as TimeIndicatorViewInfo;
            SchedulerControl      scheduler = sender as SchedulerControl;

            foreach (var item in info.Items)
            {
                TimeIndicatorBaseItem timeIndicatorItem = item as TimeIndicatorBaseItem;
                if (timeIndicatorItem != null)
                {
                    e.DrawDefault();
                    Rectangle boundsText = Rectangle.Empty;
                    if (scheduler.ActiveView is DayView)
                    {
                        boundsText = Rectangle.Inflate(timeIndicatorItem.Bounds, 0, 5);
                        boundsText.Offset(((int)e.Graphics.ClipBounds.Width / 2), -10);
                    }
                    e.Cache.DrawString(info.Interval.Start.ToString(), scheduler.Appearance.HeaderCaption.Font, new SolidBrush(Color.Red), boundsText,
                                       scheduler.Appearance.HeaderCaption.GetStringFormat());
                }
            }
            e.Handled = true;
        }
Example #6
0
        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;
        }