private void schedulerControl1_CustomDrawDayViewAllDayArea(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { if (schedulerStorage1.Appointments != null) { AllDayAreaCell cell = (AllDayAreaCell)e.ObjectInfo; Resource resource = cell.Resource; TimeInterval interval = cell.Interval; AppointmentBaseCollection apts = ((SchedulerControl)sender).Storage.GetAppointments(interval); float percent = CalcCurrentWorkTimeLoad(apts, interval, resource); Brush brush; if (percent == 0.0) { brush = Brushes.LightYellow; } else if (percent < 0.5) { brush = Brushes.LightBlue; } else { brush = Brushes.LightCoral; } e.Cache.FillRectangle(brush, e.Bounds); e.Cache.DrawString(string.Format("{0:P}", percent), cell.Appearance.Font, Brushes.Black, e.Bounds, cell.Appearance.TextOptions.GetStringFormat()); e.Handled = true; } }
public static void scheduler_CustomDrawDayViewAllDayArea(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { AllDayAreaCell cell = (AllDayAreaCell)e.ObjectInfo; Resource resource = cell.Resource; TimeInterval interval = cell.Interval; AppointmentBaseCollection apts = ((SchedulerControl)sender).Storage.GetAppointments(interval); // Specify what precentage of the appointment duration should be painted. float percent = CalcCurrentWorkTimeLoad(apts, interval, resource); Brush brush; // Select the brush color. if (percent == 0.0) { brush = Brushes.LightYellow; } else if (percent < 0.5) { brush = Brushes.LightBlue; } else { brush = Brushes.LightCoral; } // Paint the area with the selected color. e.Cache.FillRectangle(brush, e.Bounds); // Draw the percentage text. StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; e.Cache.DrawString(string.Format("{0:P}", percent), cell.Appearance.Font, Brushes.Black, e.Bounds, format); e.Handled = true; }
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; }
private void schedulerControl1_CustomDrawTimeCell(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { SchedulerViewCellBase cell = (SchedulerViewCellBase)e.ObjectInfo; bool isOddMonth = hijriCalHelper.IsOddHijriMonths(cell.Interval); Color color = isOddMonth ? Color.White : Color.LightSteelBlue; cell.Appearance.BackColor = color; }
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; }
private void schedulerControl1_CustomDrawTimeCell(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { if (e.ObjectInfo is TimeCell) { TimeCell tc = e.ObjectInfo as TimeCell; if (tc.Interval.Start.Hour >= 12 && tc.Interval.Start.Hour < 14) { tc.Appearance.BackColor = Color.LightBlue; } } }
private void schedulerControl1_CustomDrawTimeCell(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { if (e.ObjectInfo is TimeCell) { TimeCell tc = e.ObjectInfo as TimeCell; if (tc.Interval.Start.Hour >= Convert.ToInt32(tc.Resource.CustomFields["LunchStart"]) && tc.Interval.Start.Hour < Convert.ToInt32(tc.Resource.CustomFields["LunchEnd"])) { tc.Appearance.BackColor = Color.LightBlue; } } }
public static void scheduler_CustomDrawTimeCell_3(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { SelectableIntervalViewInfo cell = e.ObjectInfo as SelectableIntervalViewInfo; if (cell != null) { if (cell.Selected) { e.Cache.FillRectangle(Brushes.Lime, e.Bounds); e.Handled = true; } } }
public static void scheduler_CustomDrawTimeCell(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { // Get the cell to draw. SelectableIntervalViewInfo cell = e.ObjectInfo as SelectableIntervalViewInfo; if (cell != null) { // Draw the cell. Brush myBrush = (cell.Selected) ? SystemBrushes.Highlight : SystemBrushes.Window; e.Cache.FillRectangle(myBrush, cell.Bounds); } e.Handled = true; }
private void schedulerControl1_CustomDrawAppointment(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { if (((SchedulerControl)sender).ActiveView is DayView) { AppointmentViewInfo viewInfo = e.ObjectInfo as AppointmentViewInfo; // Get DevExpress images. //Image im = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/add_16x16.png"); //Rectangle imageBounds = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y, im.Width, im.Height); //Rectangle mainContentBounds = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y + im.Width + 1, //viewInfo.InnerBounds.Width, viewInfo.InnerBounds.Height - im.Height - 1); //// Draw image in the appointment. //e.Cache.Graphics.DrawImage(im, imageBounds); } }
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; }
public static void scheduler_CustomDrawTimeCell_3(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { Brush solidBrush = new SolidBrush(Color.Lime); SelectableIntervalViewInfo cell = e.ObjectInfo as SelectableIntervalViewInfo; if (cell != null) { if (cell.Selected) { e.Graphics.FillRectangle(solidBrush, e.Bounds); e.Handled = true; } } }
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; }
public static void scheduler_CustomDrawNavigationButton(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { NavigationButtonNext navButton = e.ObjectInfo as NavigationButtonNext; SchedulerControl scheduler = sender as SchedulerControl; SchedulerStorage storage = scheduler.Storage as SchedulerStorage; // Do not count by resources. if (scheduler.GroupType != SchedulerGroupType.None) { return; } if (navButton != null && scheduler != null && storage != null) { // Count appointments within the interval used by the Next navigation button. AppointmentBaseCollection apts = scheduler.Storage.Appointments.Items; TimeSpan aptSearchInterval = scheduler.OptionsView.NavigationButtons.AppointmentSearchInterval; DateTime lastVisibleTime = scheduler.ActiveView.GetVisibleIntervals().Last().End; int aptCount = apts.Where(a => (a.Start > lastVisibleTime) && (a.Start < lastVisibleTime.Add(aptSearchInterval))).Count(); navButton.DisplayTextItem.Text = String.Format("Next {0} appointments", aptCount); } }
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; }
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; }
private void schedulerControl1_CustomDrawResourceHeader(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { DevExpress.XtraScheduler.Drawing.ResourceHeader resourceHeader = e.ObjectInfo as ResourceHeader; if (resourceHeader != null) { DataRowView rowView = (DataRowView)resourceHeader.Resource.GetRow(schedulerControl1.Storage); if (rowView != null) { string dtstartTime = ACMS.Convert.ToDateTime(rowView["dtStartTime"]).ToString("T"); string dtEndTime = ACMS.Convert.ToDateTime(rowView["dtEndTime"]).ToString("T"); string strCaption = resourceHeader.Resource.Caption + "\n" + dtstartTime + " -- " + dtEndTime; AppearanceObject appObj = resourceHeader.Appearance.Selection; appObj.Font = new Font(appObj.Font.FontFamily.Name, 7); appObj.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; appObj.BackColor = Color.White; appObj.DrawBackground(e.Graphics, e.Cache, e.Bounds, false); appObj.DrawString(e.Cache, strCaption, e.Bounds); e.Handled = true; } } }
private void schedulerControl1_CustomDrawAppointmentBackground(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e) { DevExpress.XtraScheduler.Drawing.AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo; if (aptViewInfo != null) { AppearanceObject app = aptViewInfo.Appearance; DevExpress.XtraScheduler.Appointment appointment = aptViewInfo.Appointment; DataRowView rowView = (DataRowView)appointment.GetRow(schedulerControl1.Storage); if (rowView != null) { DataRow row = rowView.Row; if (ACMS.Convert.ToInt32(row["nStatusID"]) == 2) { app.BackColor = Color.Aqua; app.DrawBackground(e.Cache, e.Bounds); } else if (ACMS.Convert.ToInt32(row["nStatusID"]) == 5) { app.BackColor = Color.Yellow; app.DrawBackground(e.Cache, e.Bounds); } if (ACMS.Convert.ToInt32(row["nStatusID"]) == 2 || ACMS.Convert.ToInt32(row["nStatusID"]) == 5) { // // // DevExpress.Utils.AppearanceObject app2 = new DevExpress.Utils.AppearanceObject(); // Rectangle rect1 = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); // // System.Drawing.StringFormat strFormat = new StringFormat(); // strFormat.Alignment = StringAlignment.Near; // // app2.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top; // app2.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; // // System.Drawing.FontStyle fs = new FontStyle(); // fs |= FontStyle.Bold; // fs |= FontStyle.Underline; // // app2.Font = new Font(app2.Font.FontFamily, app2.Font.Size, fs); // app2.DrawString(e.Cache, // "M'ID:" + row["strMembershipID"].ToString() + ", S'Code: " + aptViewInfo.DisplayText, // rect1, strFormat); // // app.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; // app.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; // // Rectangle rect2 = new Rectangle(e.Bounds.X, e.Bounds.Y + 5, e.Bounds.Width, e.Bounds.Height + 5); // // app.DrawString(e.Cache, aptViewInfo.DisplayDescription, rect2, app.TextOptions.GetStringFormat()); // // e.Handled = true; } } } }