• About
    • Blog
    • Business Process
    • Charity Work
    • History
    • News
  • Services
    • Legacy System Support
    • Bespoke System Development
    • Web Design & Development
    • View all services
  • Products
  • Our work
    • Customers
    • Case Studies
  • Careers
  • Contact
Microsoft Partner - Application Development
14th April 2015

DevExpress XAF – Scheduler Control Change Event Colours Depending on a Custom Field

DevExpress PSP Knowledge
DevExpress XAF – Scheduler Control Change Event Colours Depending on a Custom Field

By default when using the Win Scheduler List Editor List Editor Type when viewing your Events using the Scheduler Control, the colour of the Event will depend on the colour set up against your Event Type. It may be required for the colour of the Event within the listing to change depending on a custom field such as an Event Status. The code snippet below examples changing the Event colour depending on the value selected within a custom field against your Event, it needs to be implemented within a View Controller against the Module.Win project.

using System.Drawing;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.Persistent.Base.General;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
 
/// <summary>
/// Scheduler Calendar View Controller
/// </summary>
public partial class SchedulerCalendarViewController : ObjectViewController<ListView, IRecurrentEvent>

/// <summary> /// Initializes a new instance of the <see cref="SchedulerCalendarViewController"/> class. /// </summary> public SchedulerCalendarViewController()

this.InitializeComponent(); this.RegisterActions(this.components);

/// <summary> /// Called when [view controls created]. /// </summary> protected override void OnViewControlsCreated()

base.OnViewControlsCreated(); SchedulerListEditor listEditor = View.Editor as SchedulerListEditor; if (listEditor != null)

SchedulerControl scheduler = listEditor.SchedulerControl; if (scheduler != null)

scheduler.CustomDrawAppointmentBackground += new CustomDrawObjectEventHandler(this.SchedulerControl_CustomDrawObject);

/// <summary> /// Handles the CustomDrawObject event of the SchedulerControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="CustomDrawObjectEventArgs"/> instance containing the event data.</param> private void SchedulerControl_CustomDrawObject(object sender, CustomDrawObjectEventArgs e)

AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo; if (aptViewInfo != null)

MyEvent myEvent = this.ObjectSpace.GetObjectByKey<MyEvent>(aptViewInfo.Appointment.Id); if (myEvent != null)

if (myEvent.MyCustomField == "ValueOne")

Brush fillBrush = e.Cache.GetSolidBrush(System.Drawing.Color.LightBlue); e.Graphics.FillRectangle(fillBrush, e.Bounds); if (aptViewInfo.Selected)

Pen selectedPen = e.Cache.GetPen(System.Drawing.Color.Black); Brush selectedBrush = e.Cache.GetSolidBrush(System.Drawing.Color.LightSlateGray); e.Graphics.FillRectangle(selectedBrush, e.Bounds);

else

Brush fillBrush = e.Cache.GetSolidBrush(System.Drawing.Color.LightGreen); e.Graphics.FillRectangle(fillBrush, e.Bounds); if (aptViewInfo.Selected)

Pen selectedPen = e.Cache.GetPen(System.Drawing.Color.Black); Brush selectedBrush = e.Cache.GetSolidBrush(System.Drawing.Color.LightSlateGray); e.Graphics.FillRectangle(selectedBrush, e.Bounds);

e.Handled = true;

Share:
PSP IT Design & Development
About Us
  • Privacy Policy
  • History
  • Customers
  • News
  • Blogs
Services
  • Legacy System Modernisation
  • Website Design & Development
  • Bespoke Application Development
  • Outsource IT Strategy
  • All Services
Contact
  • 01775 722377
  • letstalk@psp-it.co.uk
  • Carver House, Apex Court, Spalding Office Park, Elsoms Way, Pinchbeck, Spalding,Lincolnshire, PE11 3UL

Terms & Conditions Privacy Policy

© PSP People Systems Process Ltd. 2022. All Rights Reserved.

MENU

MENU

  • About

    • Blog

    • Business Process

    • Charity Work

    • History

    • News

  • Services

    • Legacy System Support

    • Bespoke System Development

    • Web Design & Development

    • View all services

  • Products

  • Our work

    • Customers

    • Case Studies

  • Careers

  • Contact

© PSP People Systems Process Ltd. 2022. All Rights Reserved. Privacy Policy

give us a call
01775 722377
drop us an email