-
Notifications
You must be signed in to change notification settings - Fork 204
/
Recurrence.cs
139 lines (118 loc) · 4.84 KB
/
Recurrence.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using Syncfusion.SfSchedule.iOS;
using System.Drawing;
using System.Collections.ObjectModel;
#if __UNIFIED__
using Foundation;
using UIKit;
using CoreGraphics;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using CGRect = System.Drawing.RectangleF;
using CGPoint = System.Drawing.PointF;
using CGSize = System.Drawing.SizeF;
using nfloat = System.Single;
using System.Drawing;
#endif
namespace SampleBrowser
{
public class Recurrence : SampleView
{
private SFSchedule schedule;
private UIPickerView scheduleTypePicker = new UIPickerView();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Recurrence()
{
schedule = new SFSchedule();
schedule.ScheduleView = SFScheduleView.SFScheduleViewMonth;
schedule.ItemsSource = CreateAppointments();
schedule.MonthViewSettings.ShowAppointmentsInline = true;
this.AddSubview(schedule);
}
public override void LayoutSubviews()
{
foreach (var view in this.Subviews)
{
view.Frame = new CGRect(Frame.X, 0, Frame.Width, Frame.Height);
}
base.LayoutSubviews();
}
protected override void Dispose(bool disposing)
{
if (schedule != null)
{
this.schedule.Dispose();
}
this.schedule = null;
if(scheduleTypePicker != null)
{
scheduleTypePicker.Dispose();
scheduleTypePicker = null;
}
}
private ObservableCollection<ScheduleAppointment> CreateAppointments()
{
NSDate today = new NSDate();
ObservableCollection<ScheduleAppointment> appCollection = new ObservableCollection<ScheduleAppointment>();
NSCalendar calendar = NSCalendar.CurrentCalendar;
//Client Meeting recusive appointments
// Get the year, month, day from the date
NSDateComponents components = calendar.Components(
NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
// Set the hour, minute, second
components.Hour = 10;
components.Minute = 0;
components.Second = 0;
// Get the year, month, day from the date
NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
// Set the hour, minute, second
endDateComponents.Hour = 12;
endDateComponents.Minute = 0;
endDateComponents.Second = 0;
NSDate startDate = calendar.DateFromComponents(components);
NSDate endDate = calendar.DateFromComponents(endDateComponents);
ScheduleAppointment clientMeetingRecurrence = new ScheduleAppointment();
clientMeetingRecurrence.StartTime = startDate;
clientMeetingRecurrence.EndTime = endDate;
clientMeetingRecurrence.Subject = (NSString)@"Occurs on Every 1 week";
//assigning RFC standard recurring rule.
clientMeetingRecurrence.RecurrenceRule = (NSString)@"FREQ=WEEKLY;INTERVAL=1;BYDAY=FR;COUNT=10";
clientMeetingRecurrence.AppointmentBackground = UIColor.FromRGB(0xD8, 0x00, 0x73);
appCollection.Add(clientMeetingRecurrence);
// Get the year, month, day from the date
NSDateComponents components1 = calendar.Components(
NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
// Set the hour, minute, second
components1.Hour = 12;
components1.Minute = 0;
components1.Second = 0;
// Get the year, month, day from the date
NSDateComponents endDateComponents1 = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today);
// Set the hour, minute, second
endDateComponents1.Hour = 13;
endDateComponents1.Minute = 0;
endDateComponents1.Second = 0;
NSDate startDate1 = calendar.DateFromComponents(components1);
NSDate endDate1 = calendar.DateFromComponents(endDateComponents1);
ScheduleAppointment generalMeetingRecurrence = new ScheduleAppointment();
generalMeetingRecurrence.StartTime = startDate1;
generalMeetingRecurrence.EndTime = endDate1;
generalMeetingRecurrence.Subject = (NSString)@"Occurs on Every 2 days";
//assinging RFC stardard recurring rule.
generalMeetingRecurrence.RecurrenceRule = (NSString)@"FREQ=DAILY;INTERVAL=2;COUNT=25";
generalMeetingRecurrence.AppointmentBackground = UIColor.FromRGB(0xA2, 0xC1, 0x39);
appCollection.Add(generalMeetingRecurrence);
return appCollection;
}
}
}