This example uses DevExpress Reports to print user appointments.
The key point is to obtain a collection of appointments and assign it to the report's DataSource property. The example uses the GetAppointments method to obtain appointments that fall within the time range specified by the GetVisibleIntervals method.
To display custom fields in the report, the example exposes custom fields (see the Task
class). The SetAppointmentFactory method replaces Scheduler Appointment objects with Task
class instances.
Important
You should own a DevExpress Reporting license.
Files to Review
- CustomEvents.cs (VB: CustomEvents.vb)
- Form1.cs (VB: Form1.vb)
- Form1.vb (VB: Form1.vb)
- MyAppointmentEditForm.cs (VB: MyAppointmentEditForm.vb)
- Task.cs (VB: Task.vb)
- XtraReport1.cs (VB: XtraReport1.vb)
Documentation
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#// Developer Express Code Central Example:
// Printing appointment details using the XtraReports Suite
//
// This example illustrates how you can print the appointment details for the
// appointments currently displayed in the Scheduler by means of the XtraReports
// Suite.
// The key point is to obtain a collection of appointments and assign it to
// the report's DataSource
// (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
// To accomplish this, the GetAppointments
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
// method is used to get a collection of appointments which fall within the time
// range specified by the GetVisibleIntervals
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
// method.
// To display custom fields in the report, the custom fields
// (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
// should be exposed as common object properties. So a wrapper class Task is
// implemented solely for this purpose. Using the SetAppointmentFactory
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
// method, Scheduler's Appointment objects are replaced with the Task class
// instances. A TaskCollection class holds Task objects and can be used as the
// report's data source.
// Note that you should have a valid license to the
// XtraReports Suite
// (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
// to use this approach in your application.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1183
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
namespace PrintingViaReports{
public class CustomEvent : IEditableObject {
DateTime fStart;
DateTime fEnd;
string fSubject;
int fStatus;
string fDescription;
int fLabel;
string fLocation;
bool fAllday;
int fEventType;
string fRecurrenceInfo;
string fReminderInfo;
object fOwnerId;
string fCustomText;
Color fCustomColor;
CustomEventList events;
bool committed = false;
public CustomEvent(CustomEventList events) {
this.events = events;
}
private void OnListChanged() {
int index = events.IndexOf(this);
events.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
}
public DateTime StartTime { get { return fStart; } set { fStart = value; } }
public DateTime EndTime { get { return fEnd; } set { fEnd = value; } }
public string Subject { get { return fSubject; } set { fSubject = value; } }
public int Status { get { return fStatus; } set { fStatus = value; } }
public string Description { get { return fDescription; } set { fDescription = value; } }
public int Label { get { return fLabel; } set { fLabel = value; } }
public string Location { get { return fLocation; } set { fLocation = value; } }
public bool AllDay { get { return fAllday; } set { fAllday = value; } }
public int EventType { get { return fEventType; } set { fEventType = value; } }
public string RecurrenceInfo { get { return fRecurrenceInfo; } set { fRecurrenceInfo = value; } }
public string ReminderInfo { get { return fReminderInfo; } set { fReminderInfo = value; } }
public object OwnerId { get { return fOwnerId; } set { fOwnerId = value; } }
public string CustomText { get { return fCustomText; } set { fCustomText = value; } }
public Color CustomColor { get { return fCustomColor; } set {fCustomColor = value; }
}
public void BeginEdit() {
}
public void CancelEdit() {
if (!committed) {
((IList)events).Remove(this);
}
}
public void EndEdit() {
committed = true;
}
}
public class CustomEventList : CollectionBase, IBindingList {
public CustomEvent this[int idx] { get { return (CustomEvent)base.List[idx]; } }
public new void Clear() {
base.Clear();
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
public void Add(CustomEvent appointment) {
base.List.Add(appointment);
}
public int IndexOf(CustomEvent appointment) {
return List.IndexOf(appointment);
}
public object AddNew() {
CustomEvent app = new CustomEvent(this);
List.Add(app);
return app;
}
public bool AllowEdit { get { return true; } }
public bool AllowNew { get { return true; } }
public bool AllowRemove { get { return true; } }
private ListChangedEventHandler listChangedHandler;
public event ListChangedEventHandler ListChanged {
add { listChangedHandler += value; }
remove { listChangedHandler -= value; }
}
internal void OnListChanged(ListChangedEventArgs args) {
if (listChangedHandler != null) {
listChangedHandler(this, args);
}
}
protected override void OnRemoveComplete(int index, object value) {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
}
protected override void OnInsertComplete(int index, object value) {
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
}
public void AddIndex(PropertyDescriptor pd) { throw new NotSupportedException(); }
public void ApplySort(PropertyDescriptor pd, ListSortDirection dir) { throw new NotSupportedException(); }
public int Find(PropertyDescriptor property, object key) { throw new NotSupportedException(); }
public bool IsSorted { get { return false; } }
public void RemoveIndex(PropertyDescriptor pd) { throw new NotSupportedException(); }
public void RemoveSort() { throw new NotSupportedException(); }
public ListSortDirection SortDirection { get { throw new NotSupportedException(); } }
public PropertyDescriptor SortProperty { get { throw new NotSupportedException(); } }
public bool SupportsChangeNotification { get { return true; } }
public bool SupportsSearching { get { return false; } }
public bool SupportsSorting { get { return false; } }
}
}
C#// Developer Express Code Central Example:
// Printing appointment details using the XtraReports Suite
//
// This example illustrates how you can print the appointment details for the
// appointments currently displayed in the Scheduler by means of the XtraReports
// Suite.
// The key point is to obtain a collection of appointments and assign it to
// the report's DataSource
// (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
// To accomplish this, the GetAppointments
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
// method is used to get a collection of appointments which fall within the time
// range specified by the GetVisibleIntervals
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
// method.
// To display custom fields in the report, the custom fields
// (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
// should be exposed as common object properties. So a wrapper class Task is
// implemented solely for this purpose. Using the SetAppointmentFactory
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
// method, Scheduler's Appointment objects are replaced with the Task class
// instances. A TaskCollection class holds Task objects and can be used as the
// report's data source.
// Note that you should have a valid license to the
// XtraReports Suite
// (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
// to use this approach in your application.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1183
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraScheduler;
using DevExpress.LookAndFeel;
using DevExpress.XtraReports.UserDesigner;
namespace PrintingViaReports
{
public partial class Form1 : Form
{
#region InitialDataConstants
public static Random RandomInstance = new Random();
public static string[] Users = new string[] {"Peter Dolan", "Ryan Fischer", "Richard Fisher",
"Tom Hamlett", "Mark Hamilton", "Steve Lee", "Jimmy Lewis", "Jeffrey W McClain",
"Andrew Miller", "Dave Murrel", "Bert Parkins", "Mike Roller", "Ray Shipman",
"Paul Bailey", "Brad Barnes", "Carl Lucas", "Jerry Campbell"};
#endregion
public Form1()
{
InitializeComponent();
InitializeTasks();
UpdateControls();
}
#region #initializetasks
private void InitializeTasks()
{
schedulerStorage1.SetAppointmentFactory(new TaskFactory());
FillResources(schedulerStorage1, 5);
SetMappings();
SetDataSource();
HighlightFirstAppointment();
}
#endregion #initializetasks
private void SetMappings()
{
this.schedulerStorage1.Appointments.Mappings.Start = "StartTime";
this.schedulerStorage1.Appointments.Mappings.End = "EndTime";
this.schedulerStorage1.Appointments.Mappings.Subject = "Subject";
this.schedulerStorage1.Appointments.Mappings.AllDay = "AllDay";
this.schedulerStorage1.Appointments.Mappings.Description = "Description";
this.schedulerStorage1.Appointments.Mappings.Label = "Label";
this.schedulerStorage1.Appointments.Mappings.Location = "Location";
this.schedulerStorage1.Appointments.Mappings.RecurrenceInfo = "RecurrenceInfo";
this.schedulerStorage1.Appointments.Mappings.ReminderInfo = "ReminderInfo";
this.schedulerStorage1.Appointments.Mappings.ResourceId = "OwnerId";
this.schedulerStorage1.Appointments.Mappings.Status = "Status";
this.schedulerStorage1.Appointments.Mappings.Type = "EventType";
AppointmentCustomFieldMapping customTextMapping = new AppointmentCustomFieldMapping("CustomTextField", "CustomText");
AppointmentCustomFieldMapping customColorMapping = new AppointmentCustomFieldMapping("CustomColorField", "CustomColor");
schedulerStorage1.Appointments.CustomFieldMappings.Add(customTextMapping);
schedulerStorage1.Appointments.CustomFieldMappings.Add(customColorMapping);
}
private void SetDataSource()
{
CustomEventList eventList = new CustomEventList();
GenerateEvents(eventList);
this.schedulerStorage1.Appointments.DataSource = eventList;
}
#region #highlight
private void HighlightFirstAppointment()
{
schedulerControl1.Start = DateTime.Now;
AppointmentBaseCollection abc = schedulerStorage1.GetAppointments(schedulerControl1.ActiveView.GetVisibleIntervals());
if (abc.Count > 0)
((Task)abc[0]).CustomColor = Color.IndianRed;
}
#endregion #highlight
#region InitialDataLoad
void FillResources(SchedulerStorage storage, int count)
{
ResourceCollection resources = storage.Resources.Items;
storage.BeginUpdate();
try
{
int cnt = Math.Min(count, Users.Length);
for (int i = 1; i <= cnt; i++)
resources.Add(Guid.NewGuid(), Users[i - 1]);
}
finally
{
storage.EndUpdate();
}
}
void GenerateEvents(CustomEventList eventList)
{
int count = schedulerStorage1.Resources.Count;
for (int i = 0; i < count; i++)
{
Resource resource = schedulerStorage1.Resources[i];
string subjPrefix = resource.Caption + "'s ";
eventList.Add(CreateEvent(eventList, subjPrefix + "meeting", resource.Id, 2, 5));
eventList.Add(CreateEvent(eventList, subjPrefix + "travel", resource.Id, 3, 6));
eventList.Add(CreateEvent(eventList, subjPrefix + "phone call", resource.Id, 0, 10));
}
}
CustomEvent CreateEvent(CustomEventList eventList, string subject, object resourceId, int status, int label)
{
CustomEvent apt = new CustomEvent(eventList);
apt.Subject = subject;
apt.OwnerId = resourceId;
Random rnd = RandomInstance;
int rangeInMinutes = 60 * 24;
apt.StartTime = DateTime.Today + TimeSpan.FromMinutes(rnd.Next(0, rangeInMinutes));
apt.EndTime = apt.StartTime + TimeSpan.FromMinutes(rnd.Next(0, rangeInMinutes / 4));
apt.Status = status;
apt.Label = label;
TimeSpan duration = apt.EndTime - apt.StartTime;
apt.Description = subject + " lasts for " + duration.ToString();
apt.CustomText = "TEST";
apt.CustomColor = Color.Transparent;
return apt;
}
#endregion
#region Update Controls
private void UpdateControls()
{
cbView.EditValue = schedulerControl1.ActiveViewType;
rgrpGrouping.EditValue = schedulerControl1.GroupType;
}
private void rgrpGrouping_SelectedIndexChanged(object sender, System.EventArgs e)
{
schedulerControl1.GroupType = (SchedulerGroupType)rgrpGrouping.EditValue;
}
private void schedulerControl_ActiveViewChanged(object sender, System.EventArgs e)
{
cbView.EditValue = schedulerControl1.ActiveViewType;
}
private void cbView_SelectedIndexChanged(object sender, System.EventArgs e)
{
schedulerControl1.ActiveViewType = (SchedulerViewType)cbView.EditValue;
}
#endregion
private void simpleButton1_Click(object sender, EventArgs e)
{
XtraReport1 xr = new XtraReport1();
// Assign the report's data source which is the collection of Task objects.
AppointmentBaseCollection abc = schedulerStorage1.GetAppointments(schedulerControl1.ActiveView.GetVisibleIntervals());
TaskCollection tc = new TaskCollection();
tc.AddAppointmentRange(abc);
xr.DataSource = tc;
// Create a report and preview it.
xr.CreateDocument();
XRDesignFormEx designForm = new XRDesignFormEx();
designForm.OpenReport(xr);
designForm.DesignPanel.SelectedTabIndex = 1;
designForm.ShowDialog();
}
private void schedulerControl1_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
{
Appointment apt = e.Appointment;
// Required to open the recurrence form via context menu.
bool openRecurrenceForm = apt.IsRecurring && schedulerStorage1.Appointments.IsNewAppointment(apt);
// Create a custom form.
MyAppointmentEditForm myForm = new MyAppointmentEditForm((SchedulerControl)sender, apt, openRecurrenceForm);
try
{
// Required for skin support.
myForm.LookAndFeel.ParentLookAndFeel = schedulerControl1.LookAndFeel;
e.DialogResult = myForm.ShowDialog();
schedulerControl1.Refresh();
e.Handled = true;
}
finally
{
myForm.Dispose();
}
}
private void schedulerControl1_AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e)
{
Color custColor = (Color)e.ViewInfo.Appointment.CustomFields["CustomColorField"];
// Change the appointment color if the custom color value is not default.
if (custColor != Color.Transparent)
e.ViewInfo.Appearance.BackColor = custColor;
}
private void schedulerControl1_InitNewAppointment(object sender, AppointmentEventArgs e)
{
// Set default custom color value for all newly created appointments.
e.Appointment.CustomFields["CustomColorField"] = Color.Transparent;
}
}
}
C#// Developer Express Code Central Example:
// Printing appointment details using the XtraReports Suite
//
// This example illustrates how you can print the appointment details for the
// appointments currently displayed in the Scheduler by means of the XtraReports
// Suite.
// The key point is to obtain a collection of appointments and assign it to
// the report's DataSource
// (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
// To accomplish this, the GetAppointments
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
// method is used to get a collection of appointments which fall within the time
// range specified by the GetVisibleIntervals
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
// method.
// To display custom fields in the report, the custom fields
// (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
// should be exposed as common object properties. So a wrapper class Task is
// implemented solely for this purpose. Using the SetAppointmentFactory
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
// method, Scheduler's Appointment objects are replaced with the Task class
// instances. A TaskCollection class holds Task objects and can be used as the
// report's data source.
// Note that you should have a valid license to the
// XtraReports Suite
// (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
// to use this approach in your application.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1183
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.UI;
namespace PrintingViaReports {
public partial class MyAppointmentEditForm : DevExpress.XtraEditors.XtraForm {
SchedulerControl control;
Appointment apt;
bool openRecurrenceForm = false;
int suspendUpdateCount;
// The MyAppointmentFormController class is inherited from
// the AppointmentFormController to add custom properties.
// See its declaration below.
MyAppointmentFormController controller;
protected AppointmentStorage Appointments {
get { return control.Storage.Appointments; }
}
protected bool IsUpdateSuspended { get { return suspendUpdateCount > 0; } }
public MyAppointmentEditForm(SchedulerControl control, Appointment apt, bool openRecurrenceForm) {
this.openRecurrenceForm = openRecurrenceForm;
this.controller = new MyAppointmentFormController(control, apt);
this.apt = apt;
this.control = control;
InitializeComponent();
UpdateForm();
}
#region Recurrence
private void MyAppointmentEditForm_Activated(object sender, System.EventArgs e) {
// Required to show the recurrence form.
if (openRecurrenceForm) {
openRecurrenceForm = false;
OnRecurrenceButton();
}
}
private void btnRecurrence_Click(object sender, System.EventArgs e) {
OnRecurrenceButton();
}
void OnRecurrenceButton() {
ShowRecurrenceForm();
}
void ShowRecurrenceForm() {
if (!control.SupportsRecurrence)
return;
// Prepare to edit the appointment's recurrence.
Appointment editedAptCopy = controller.EditedAppointmentCopy;
Appointment editedPattern = controller.EditedPattern;
Appointment patternCopy = controller.PrepareToRecurrenceEdit();
AppointmentRecurrenceForm dlg = new AppointmentRecurrenceForm(patternCopy, control.OptionsView.FirstDayOfWeek,controller);
// Required for skin support.
dlg.LookAndFeel.ParentLookAndFeel = this.LookAndFeel.ParentLookAndFeel;
DialogResult result = dlg.ShowDialog(this);
dlg.Dispose();
if (result == DialogResult.Abort)
controller.RemoveRecurrence();
else
if (result == DialogResult.OK) {
controller.ApplyRecurrence(patternCopy);
if (controller.EditedAppointmentCopy != editedAptCopy)
UpdateForm();
}
UpdateIntervalControls();
}
#endregion
#region Form control events
private void dtStart_EditValueChanged(object sender, System.EventArgs e) {
if (!IsUpdateSuspended)
controller.DisplayStart = dtStart.DateTime.Date + timeStart.Time.TimeOfDay;
UpdateIntervalControls();
}
private void timeStart_EditValueChanged(object sender, System.EventArgs e) {
if (!IsUpdateSuspended)
controller.DisplayStart = dtStart.DateTime.Date + timeStart.Time.TimeOfDay;
UpdateIntervalControls();
}
private void timeEnd_EditValueChanged(object sender, System.EventArgs e) {
if (IsUpdateSuspended) return;
if (IsIntervalValid())
controller.DisplayEnd = dtEnd.DateTime.Date + timeEnd.Time.TimeOfDay;
else
timeEnd.EditValue = new DateTime(controller.DisplayEnd.TimeOfDay.Ticks);
;
}
private void dtEnd_EditValueChanged(object sender, System.EventArgs e) {
if (IsUpdateSuspended) return;
if (IsIntervalValid())
controller.DisplayEnd = dtEnd.DateTime.Date + timeEnd.Time.TimeOfDay;
else
dtEnd.EditValue = controller.DisplayEnd.Date;
}
bool IsIntervalValid() {
DateTime start = dtStart.DateTime + timeStart.Time.TimeOfDay;
DateTime end = dtEnd.DateTime + timeEnd.Time.TimeOfDay;
return end >= start;
}
private void checkAllDay_CheckedChanged(object sender, System.EventArgs e) {
controller.AllDay = this.checkAllDay.Checked;
if (!IsUpdateSuspended)
UpdateAppointmentStatus();
UpdateIntervalControls();
}
#endregion
#region Updating Form
protected void SuspendUpdate() {
suspendUpdateCount++;
}
protected void ResumeUpdate() {
if (suspendUpdateCount > 0)
suspendUpdateCount--;
}
void UpdateForm() {
SuspendUpdate();
try {
txSubject.Text = controller.Subject;
edStatus.Status = Appointments.Statuses.GetById(controller.StatusKey);
edLabel.Label = Appointments.Labels.GetById(controller.LabelKey);
dtStart.DateTime = controller.DisplayStart.Date;
dtEnd.DateTime= controller.DisplayEnd.Date;
timeStart.Time = new DateTime(controller.DisplayStart.TimeOfDay.Ticks);
timeEnd.Time = new DateTime(controller.DisplayEnd.TimeOfDay.Ticks);
checkAllDay.Checked = controller.AllDay;
edStatus.Storage = control.Storage;
edLabel.Storage = control.Storage;
edtDescription.Text = controller.Description;
txCustomText.Text = controller.CustomText;
edtCustomColor.Color = controller.CustomColor;
} finally {
ResumeUpdate();
}
UpdateIntervalControls();
}
protected virtual void UpdateIntervalControls() {
if (IsUpdateSuspended)
return;
SuspendUpdate();
try {
dtStart.EditValue = controller.DisplayStart.Date;
dtEnd.EditValue = controller.DisplayEnd.Date;
timeStart.EditValue = new DateTime(controller.DisplayStart.TimeOfDay.Ticks);
timeEnd.EditValue = new DateTime(controller.DisplayEnd.TimeOfDay.Ticks);
timeStart.Visible = !controller.AllDay;
timeEnd.Visible = !controller.AllDay;
timeStart.Enabled = !controller.AllDay;
timeEnd.Enabled = !controller.AllDay;
}
finally {
ResumeUpdate();
}
}
void UpdateAppointmentStatus() {
AppointmentStatus currentStatus = edStatus.Status;
AppointmentStatus newStatus = controller.UpdateAppointmentStatus(currentStatus);
if (newStatus != currentStatus)
edStatus.Status = newStatus;
}
#endregion
#region Save changes
private void btnOK_Click(object sender, System.EventArgs e) {
// Required to check the appointment for conflicts.
if (!controller.IsConflictResolved())
return;
controller.Subject = txSubject.Text;
controller.SetStatus(edStatus.Status);
controller.SetLabel(edLabel.Label);
controller.AllDay = this.checkAllDay.Checked;
controller.DisplayStart = this.dtStart.DateTime.Date + this.timeStart.Time.TimeOfDay;
controller.DisplayEnd = this.dtEnd.DateTime.Date + this.timeEnd.Time.TimeOfDay;
controller.Description = edtDescription.Text;
controller.CustomText = txCustomText.Text;
controller.CustomColor = edtCustomColor.Color;
// Save all changes of the editing appointment.
controller.ApplyChanges();
}
#endregion
#region MyAppointmentFormController
public class MyAppointmentFormController : AppointmentFormController {
public string CustomText { get { return (string)EditedAppointmentCopy.CustomFields["CustomTextField"]; } set { EditedAppointmentCopy.CustomFields["CustomTextField"] = value; } }
public Color CustomColor { get { return (Color)EditedAppointmentCopy.CustomFields["CustomColorField"]; } set { EditedAppointmentCopy.CustomFields["CustomColorField"] = value; } }
string SourceCustomText { get { return (string)SourceAppointment.CustomFields["CustomTextField"]; } set { SourceAppointment.CustomFields["CustomTextField"] = value; } }
Color SourceCustomColor { get { return (Color)SourceAppointment.CustomFields["CustomColorField"]; } set { SourceAppointment.CustomFields["CustomColorField"] = value; } }
public MyAppointmentFormController(SchedulerControl control, Appointment apt) : base(control, apt) {
}
public override bool IsAppointmentChanged() {
if(base.IsAppointmentChanged())
return true;
return SourceCustomText != CustomText ||
SourceCustomColor != CustomColor;
}
protected override void ApplyCustomFieldsValues() {
SourceCustomText = CustomText;
SourceCustomColor = CustomColor;
}
}
#endregion
}
}
C#// Developer Express Code Central Example:
// Printing appointment details using the XtraReports Suite
//
// This example illustrates how you can print the appointment details for the
// appointments currently displayed in the Scheduler by means of the XtraReports
// Suite.
// The key point is to obtain a collection of appointments and assign it to
// the report's DataSource
// (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
// To accomplish this, the GetAppointments
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
// method is used to get a collection of appointments which fall within the time
// range specified by the GetVisibleIntervals
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
// method.
// To display custom fields in the report, the custom fields
// (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
// should be exposed as common object properties. So a wrapper class Task is
// implemented solely for this purpose. Using the SetAppointmentFactory
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
// method, Scheduler's Appointment objects are replaced with the Task class
// instances. A TaskCollection class holds Task objects and can be used as the
// report's data source.
// Note that you should have a valid license to the
// XtraReports Suite
// (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
// to use this approach in your application.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1183
using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraScheduler;
using System.Drawing;
//using DevExpress.XtraScheduler.Native;
namespace PrintingViaReports
{
#region #appointmentfactory
public class TaskFactory : IAppointmentFactory
{
public Appointment CreateAppointment(AppointmentType type)
{
Task task = new Task(type);
return task;
}
}
public class Task : DevExpress.XtraScheduler.Internal.Implementations.AppointmentInstance {
public Task() { }
public Task (AppointmentType type) : base(type){}
// Convert custom fields into the Task properties
public string CustomText {
get { return (string)base.CustomFields["CustomTextField"]; }
set { base.CustomFields["CustomTextField"] = value; }
}
public Color CustomColor {
get { return (Color)base.CustomFields["CustomColorField"]; }
set { base.CustomFields["CustomColorField"] = value; }
}
public int CustomColorARGB { get { return ((Color)base.CustomFields["CustomColorField"]).ToArgb(); } }
}
public class TaskCollection : List<Task> {
public void AddAppointment(Appointment appointment) {
Task task = (Task)appointment;
base.Add(task);
}
public virtual void AddAppointmentRange(AppointmentBaseCollection collection) {
foreach(Appointment item in collection)
this.AddAppointment(item);
}
}
#endregion #appointmentfactory
}
C#// Developer Express Code Central Example:
// Printing appointment details using the XtraReports Suite
//
// This example illustrates how you can print the appointment details for the
// appointments currently displayed in the Scheduler by means of the XtraReports
// Suite.
// The key point is to obtain a collection of appointments and assign it to
// the report's DataSource
// (http://documentation.devexpress.com/#XtraReports/DevExpressXtraReportsUIXtraReportBase_DataSourcetopic).
// To accomplish this, the GetAppointments
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerStorageBase_GetAppointmentstopic)
// method is used to get a collection of appointments which fall within the time
// range specified by the GetVisibleIntervals
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerSchedulerViewBase_GetVisibleIntervalstopic)
// method.
// To display custom fields in the report, the custom fields
// (http://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraSchedulerNativeCustomFieldtopic)
// should be exposed as common object properties. So a wrapper class Task is
// implemented solely for this purpose. Using the SetAppointmentFactory
// (http://documentation.devexpress.com/#WindowsForms/DevExpressXtraSchedulerAppointmentStorageBase_SetAppointmentFactorytopic)
// method, Scheduler's Appointment objects are replaced with the Task class
// instances. A TaskCollection class holds Task objects and can be used as the
// report's data source.
// Note that you should have a valid license to the
// XtraReports Suite
// (http://documentation.devexpress.com/#XtraReports/CustomDocument2162) to be able
// to use this approach in your application.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1183
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
namespace PrintingViaReports {
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
public XtraReport1() {
InitializeComponent();
}
private void xrLabel6_BeforePrint(object sender, CancelEventArgs e) {
// Fill the label with color
Color curColor = Color.FromArgb(Int32.Parse(((XRLabel)sender).Text));
((XRLabel)sender).BackColor = curColor;
((XRLabel)sender).ForeColor = curColor;
}
private void xrLabel7_BeforePrint(object sender, CancelEventArgs e) {
Color curColor = (Color)GetCurrentColumnValue("CustomColor");
((XRLabel)sender).ForeColor = curColor;
((XRLabel)sender).Text = ((XRLabel)sender).Text + "\n\r" + curColor.Name + " color";
}
}
}