This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.cs
58 lines (48 loc) · 2.18 KB
/
Form1.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
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace DateNavigatorCustomized {
public partial class Form1 : XtraForm {
const string aptDataFileName = @"..\..\Data\appointments.xml";
const string resDataFileName = @"..\..\Data\resources.xml";
public Form1() {
InitializeComponent();
schedulerControl1.Start = new DateTime(2010, 7, 11);
FillData();
dateNavigator1.SelectionBehavior = DevExpress.XtraEditors.Controls.CalendarSelectionBehavior.Simple;
}
#region FillData
void FillData() {
AppointmentCustomFieldMapping customNameMapping = new AppointmentCustomFieldMapping("CustomName", "CustomName");
AppointmentCustomFieldMapping customStatusMapping = new AppointmentCustomFieldMapping("CustomStatus", "CustomStatus");
schedulerStorage1.Appointments.CustomFieldMappings.Add(customNameMapping);
schedulerStorage1.Appointments.CustomFieldMappings.Add(customStatusMapping);
FillResourcesStorage(schedulerStorage1.Resources.Items, resDataFileName);
FillAppointmentsStorage(schedulerStorage1.Appointments.Items, aptDataFileName);
}
static Stream GetFileStream(string fileName) {
return new StreamReader(fileName).BaseStream;
}
static void FillAppointmentsStorage(AppointmentCollection c, string fileName) {
using (Stream stream = GetFileStream(fileName)) {
c.ReadXml(stream);
stream.Close();
}
}
static void FillResourcesStorage(ResourceCollection c, string fileName) {
using (Stream stream = GetFileStream(fileName)) {
c.ReadXml(stream);
stream.Close();
}
}
#endregion
private void schedulerStorage_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) {
schedulerStorage1.Appointments.Items.WriteXml(aptDataFileName);
}
}
}