This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomAppointmentForm.xaml.cs
84 lines (70 loc) · 2.96 KB
/
CustomAppointmentForm.xaml.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
using System;
using System.Windows;
using System.Globalization;
using System.Windows.Controls;
using DevExpress.XtraScheduler;
using DevExpress.Xpf.Scheduler;
using DevExpress.Xpf.Scheduler.UI;
namespace WpfApplication1 {
public partial class CustomAppointmentForm : UserControl {
SchedulerControl control;
CustomAppointmentFormController controller;
Appointment apt;
public string TimeEditMask {
get { return CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern; }
}
public CustomAppointmentForm(SchedulerControl control, Appointment apt) {
InitializeComponent();
if (control == null || apt == null)
throw new ArgumentNullException("control");
if (control == null || apt == null)
throw new ArgumentNullException("apt");
this.control = control;
this.controller = new CustomAppointmentFormController(control, apt);
this.apt = apt;
}
public CustomAppointmentFormController Controller { get { return controller; } }
public SchedulerControl Control { get { return control; } }
public Appointment Appointment { get { return apt; } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) {
SchedulerFormBehavior.SetTitle(this, "Custom Appointment Form");
}
private void Ok_button_Click(object sender, RoutedEventArgs e) {
// Save all changes of the editing appointment.
Controller.ApplyChanges();
SchedulerFormBehavior.Close(this, true);
}
private void Cancel_button_Click(object sender, RoutedEventArgs e) {
SchedulerFormBehavior.Close(this, false);
}
#region #ShowRecurrenceForm
private void Recurrence_button_Click(object sender, RoutedEventArgs e) {
control.ShowRecurrenceForm(this, false);
}
#endregion #ShowRecurrenceForm
}
}
public class CustomAppointmentFormController : AppointmentFormController {
public CustomAppointmentFormController(SchedulerControl control, Appointment apt)
: base(control, apt) {
}
public string Contact {
get { return GetContactValue(EditedAppointmentCopy); }
set { EditedAppointmentCopy.CustomFields["Contact"] = value; }
}
string SourceContact {
get { return GetContactValue(SourceAppointment); }
set { SourceAppointment.CustomFields["Contact"] = value; }
}
public override bool IsAppointmentChanged() {
if (base.IsAppointmentChanged())
return true;
return SourceContact != Contact;
}
protected string GetContactValue(Appointment apt) {
return Convert.ToString(apt.CustomFields["Contact"]);
}
protected override void ApplyCustomFieldsValues() {
SourceContact = Contact;
}
}