This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
CustomAppointmentForm.cs
93 lines (88 loc) · 4.21 KB
/
CustomAppointmentForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#region Note
/*
{**************************************************************************************************************}
{ This file is automatically created when you open the Scheduler Control smart tag }
{ *and click Create Customizable Appointment Dialog. }
{ It contains a a descendant of the default appointment editing form created by visual inheritance. }
{ In Visual Studio Designer add an editor that is required to edit your appointment custom field. }
{ Modify the LoadFormData method to get data from a custom field and fill your editor with data. }
{ Modify the SaveFormData method to retrieve data from the editor and set the appointment custom field value. }
{ The code that displays this form is automatically inserted }
{ *in the EditAppointmentFormShowing event handler of the SchedulerControl. }
{ }
{**************************************************************************************************************}
*/
#endregion Note
using System;
using System.Collections.Generic;
namespace DXApplication5
{
public partial class CustomAppointmentForm : DevExpress.XtraScheduler.UI.AppointmentForm
{
private List<Priority> _AvailablePriorities;
private int priorityIndex = -1;
public List<Priority> AvailablePriorities
{
get { return _AvailablePriorities; }
set
{
_AvailablePriorities = value;
}
}
public CustomAppointmentForm()
{
InitializeComponent();
}
public CustomAppointmentForm(DevExpress.XtraScheduler.SchedulerControl control, DevExpress.XtraScheduler.Appointment apt)
: base(control, apt)
{
InitializeComponent();
}
public CustomAppointmentForm(DevExpress.XtraScheduler.SchedulerControl control, DevExpress.XtraScheduler.Appointment apt, bool openRecurrenceForm)
: base(control, apt, openRecurrenceForm)
{
InitializeComponent();
}
private void FillComboBox(DevExpress.XtraScheduler.Appointment appointment)
{
for (int i = 0; i < AvailablePriorities.Count; i++)
{
icbPriority.Properties.Items.Add(new DevExpress.XtraEditors.Controls.ImageComboBoxItem(AvailablePriorities[i].DisplayName, AvailablePriorities[i].Type));
}
}
/// <summary>
/// Add your code to obtain a custom field value and fill the editor with data.
/// </summary>
public override void LoadFormData(DevExpress.XtraScheduler.Appointment appointment)
{
FillComboBox(appointment);
if (appointment.CustomFields["Priority"] == null)
icbPriority.Text = "";
else
{
priorityIndex = Convert.ToInt32(appointment.CustomFields["Priority"]);
if (AvailablePriorities.Count > 0 && priorityIndex < AvailablePriorities.Count)
icbPriority.EditValue = icbPriority.Properties.Items[priorityIndex].Value;
}
base.LoadFormData(appointment);
}
/// <summary>
/// Add your code to retrieve a value from the editor and set the custom appointment field.
/// </summary>
public override bool SaveFormData(DevExpress.XtraScheduler.Appointment appointment)
{
appointment.CustomFields["Priority"] = icbPriority.SelectedIndex;
return base.SaveFormData(appointment);
}
/// <summary>
/// Add your code to notify that any custom field is changed. Return true if a custom field is changed, otherwise false.
/// </summary>
public override bool IsAppointmentChanged(DevExpress.XtraScheduler.Appointment appointment)
{
if (priorityIndex == Convert.ToInt32(appointment.CustomFields["Priority"]))
return false;
else
return true;
}
}
}