Dim scheduleProvider As SimpleScheduleDataProvider = New SimpleScheduleDataProvider()
scheduleControl1.DataSource = scheduleProvider
Public Class SimpleScheduleDataProvider
Inherits ScheduleDataProvider
Private dset As New DataSet()
Private Shared dt As New DataTable()
Public Sub New()
MyBase.New()
dset.ReadXml("..\..\default.xml")
dt = dset.Tables("MasterList")
End Sub
Public Shared Function InitializeRandomData() As SimpleScheduleAppointmentList
'int tc = Environment.TickCount;
'int tc = 26260100;// simple spread
Dim tc As Integer = 28882701 ' split the appointment across midnight & 3 items at 8am on 2 days ago
'Console.WriteLine("Random seed: {0}", tc);
Dim r As New Random(tc)
Dim r1 As New Random(tc)
' set the number of sample items you want in this list.
'int count = r.Next(20) + 4;
Dim count As Integer = dt.Rows.Count '1000;//200;//30;
Dim masterList As New SimpleScheduleAppointmentList()
Dim now As DateTime = DateTime.Now.Date
For i As Integer = 0 To count - 1
Dim item As ScheduleAppointment = TryCast(masterList.NewScheduleAppointment(), ScheduleAppointment)
Dim dayOffSet As Integer = 30 - r.Next(60)
Dim hourOffSet As Integer = 24 - r.Next(48)
Dim len As Integer = 30 * (r.Next(4) + 1)
item.StartTime = DateTime.Now.AddDays(i) 'Convert.ToDateTime(dt.Rows[i]["StartTime"]);
item.EndTime = DateTime.Now.AddDays(i) 'Convert.ToDateTime(dt.Rows[i]["EndTime"]);
item.Subject = dt.Rows(i)("Subject").ToString()
item.Content = dt.Rows(i)("Content").ToString()
item.LabelValue = Convert.ToInt16(dt.Rows(i)("LabelValue"))
item.LocationValue = dt.Rows(i)("LocationValue").ToString()
item.MarkerValue = (Convert.ToInt16(dt.Rows(i)("MarkerValue")))
item.Dirty = False
masterList.Add(item)
Next i
masterList.SortStartTime()
Return masterList
End Function
End Class |
AppointmentForm form;
//Hook the event for showing the appointment form.
this.scheduleControl1.ShowingAppointmentForm += scheduleControl1_ShowingAppointmentForm;
/// <summary>
/// Raise the event when showing the appointment form
/// </summary>
void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e)
{
//Cancel the default appointment form for schedule control.
e.Cancel = true;
//Shows the Custom appointment form.
form.ShowDialog();
}
|
AddHandler scheduleControl1.SetupContextMenu, AddressOfscheduleControl1_SetupContextmenu
Private Sub scheduleControl1_SetupContextmenu(sender As Object, e AsCancelEventArgs)
e.Cancel = True
End Sub |