-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainViewModel.cs
52 lines (48 loc) · 1.97 KB
/
MainViewModel.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
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Xpf.Scheduling;
using DevExpress.XtraScheduler;
using System;
using System.Collections.ObjectModel;
namespace DXApplication14 {
public class MainViewModel : ViewModelBase {
public DateTimeRange Interval {
get { return GetValue<DateTimeRange>(); }
set { SetValue(value); }
}
public ObservableCollection<ApptViewModel> Appointments {
get { return GetValue<ObservableCollection<ApptViewModel>>(); }
set { SetValue(value); }
}
public ObservableCollection<ApptViewModel> SelectedAppointments {
get { return GetValue<ObservableCollection<ApptViewModel>>(); }
set { SetValue(value); }
}
public MainViewModel() {
Appointments = new ObservableCollection<ApptViewModel>();
SelectedAppointments = new ObservableCollection<ApptViewModel>();
}
protected ApptViewModel CreateAppt(string subj, DateTime start, DateTime end, string description) {
ApptViewModel apptViewModel = new ApptViewModel() {
Subject = subj,
Start = start,
End = end,
Description = "[add description]"
};
return apptViewModel;
}
[Command]
public void AddAppt(bool recurrent = false) {
var appt = CreateAppt($"New Appt #{Appointments.Count}", Interval.Start, Interval.End, "[add description]");
if(recurrent) {
appt.Type = (int)AppointmentType.Pattern;
appt.RecurrenceInfo = RecurrenceBuilder.Daily(Interval.Start, 10).Build().ToXml();
} else {
appt.Type = (int)AppointmentType.Normal;
}
this.Appointments.Add(appt);
this.SelectedAppointments.Clear();
this.SelectedAppointments.Add(appt);
}
}
}