Option Strict On
Imports rw.Objects
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Data
Imports System.IO
Imports System.Reflection ' PropertyInfo definition
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
' -------------------------- Databound Schedule Controls v2.4 -----------------------
'
' ------------------------------ www.rekenwonder.com ---------------------------------
''' -----------------------------------------------------------------------------
''' Project : schedule
''' Class : rw.ScheduleCalendarDesigner
'''
''' -----------------------------------------------------------------------------
''' <summary>
''' ScheduleCalendarDesigner adds design-time support for the ScheduleCalendar control
''' </summary>
''' -----------------------------------------------------------------------------
Public Class ScheduleCalendarDesigner
Inherits ScheduleDesigner
''' -----------------------------------------------------------------------------
''' <summary>
''' Provides a dummy DataTable object, allowing the ScheduleCalendar control to
''' show some sample data in the designer.
''' </summary>
''' <param name="minimumRows"></param>
''' <returns>A dummy DataTable object</returns>
''' -----------------------------------------------------------------------------
Protected Overrides Function GetDummyDataTable(ByVal minimumRows As Integer) As DataTable
'Create a new dummy table every time this function gets called.
'The alternative is to raise OnDataSourceChanged every time DateField, TimeFieldsContainDate etc. change
Dim control As ScheduleCalendar = CType(Me.Component, ScheduleCalendar)
Dim dummyDataTable As DataTable
dummyDataTable = New DataTable
dummyDataTable.Columns.Add(New DataColumn(control.StartTimeField, System.Type.GetType("System.DateTime")))
If (control.EndTimeField <> control.StartTimeField) Then
dummyDataTable.Columns.Add(New DataColumn(control.EndTimeField, System.Type.GetType("System.DateTime")))
End If
If (Not control.TimeFieldsContainDate) Then
If (control.DateField Is Nothing Or control.DateField = "") Then
Throw New ScheduleException("When TimeFieldsContainDate=False, DateField may not be blank")
End If
dummyDataTable.Columns.Add(New DataColumn(control.DateField, System.Type.GetType("System.DateTime")))
End If
If (control.ItemStyleField <> "") Then
dummyDataTable.Columns.Add(New DataColumn(control.ItemStyleField, System.Type.GetType("System.String")))
Else
dummyDataTable.Columns.Add(New DataColumn("DummyStyleField", System.Type.GetType("System.String")))
End If
' create some dummy rows
control.ShiftStartDate()
Dim d As Date = control.StartDate()
Dim i As Integer
For i = 0 To minimumRows - 1
Dim row As DataRow = dummyDataTable.NewRow()
d = d.AddDays(1) ' create rows on successive days
If (Not control.TimeFieldsContainDate) Then
' put the date in the DateField, and the times in the TimeFields
row.Item(0) = New DateTime(1, 1, 1, 9 + i Mod 2, 0, 0)
If (control.EndTimeField <> control.StartTimeField) Then
row.Item(1) = New DateTime(1, 1, 1, 12 + i Mod 2, 0, 0)
row.Item(2) = d
row.Item(3) = "dummystyle"
Else
row.Item(1) = d
row.Item(2) = "dummystyle"
End If
Else
' ignore the DateField, and put the dates AND times in the TimeFields
row.Item(0) = New DateTime(d.Year, d.Month, d.Day, 9 + i Mod 2, 0, 0)
If (control.EndTimeField <> control.StartTimeField) Then
row.Item(1) = New DateTime(d.Year, d.Month, d.Day, 12 + i Mod 2, 0, 0)
End If
End If
dummyDataTable.Rows.Add(row)
Next
Return dummyDataTable
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' Shows a Property Builder dialog box
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' -----------------------------------------------------------------------------
Public Overrides Sub OnPropertyBuilder(ByVal sender As Object, ByVal e As EventArgs)
Dim control As ScheduleCalendar = CType(Me.Component, ScheduleCalendar)
Dim cpb As New CalendarPropertyBuilder
cpb.tbDateField.Enabled = Not control.TimeFieldsContainDate
cpb.tbDateField.Text = control.DateField
cpb.tbStartTimeField.Text = control.StartTimeField
cpb.tbEndTimeField.Text = control.EndTimeField
cpb.tbItemStyleField.Text = control.ItemStyleField
cpb.tbDateFormatString.Text = control.DateFormatString
cpb.tbTimeFormatString.Text = control.TimeFormatString
cpb.cbTimeFieldsContainDate.Checked = control.TimeFieldsContainDate
cpb.cbIncludeEndValue.Checked = control.IncludeEndValue
cpb.cbShowValueMarks.Checked = control.ShowValueMarks
cpb.tbNumberOfDays.Text = CStr(control.NumberOfDays)
cpb.tbNumberOfRepetitions.Text = CStr(control.NumberOfRepetitions)
cpb.cbStartDay.SelectedIndex = CInt(control.StartDay)
cpb.rbHorizontal.Checked = (control.Layout = LayoutEnum.Horizontal)
cpb.rbVertical.Checked = (control.Layout = LayoutEnum.Vertical)
cpb.cbFullTimeScale.Checked = control.FullTimeScale
cpb.tbStartTimeScale.Text = control.StartOfTimeScale.ToString()
cpb.tbEndTimeScale.Text = control.EndOfTimeScale.ToString()
cpb.tbInterval.Text = control.TimeScaleInterval.ToString()
cpb.tbStartTimeScale.Enabled = control.FullTimeScale
cpb.tbEndTimeScale.Enabled = control.FullTimeScale
cpb.tbInterval.Enabled = control.FullTimeScale
cpb.cbEnableEmptySlotClick.Checked = control.EnableEmptySlotClick
cpb.tbEmptySlotToolTip.Text = control.EmptySlotToolTip
cpb.tbEmptySlotToolTip.Enabled = control.EnableEmptySlotClick
If (cpb.ShowDialog() = Windows.Forms.DialogResult.OK) Then
control.DateField = cpb.tbDateField.Text
control.StartTimeField = cpb.tbStartTimeField.Text
control.EndTimeField = cpb.tbEndTimeField.Text
control.ItemStyleField = cpb.tbItemStyleField.Text
control.DateFormatString = cpb.tbDateFormatString.Text
control.TimeFormatString = cpb.tbTimeFormatString.Text
control.TimeFieldsContainDate = cpb.cbTimeFieldsContainDate.Checked
control.IncludeEndValue = cpb.cbIncludeEndValue.Checked
control.ShowValueMarks = cpb.cbShowValueMarks.Checked
control.NumberOfDays = CInt(cpb.tbNumberOfDays.Text)
control.NumberOfRepetitions = CInt(cpb.tbNumberOfRepetitions.Text)
control.StartDay = CType(cpb.cbStartDay.SelectedIndex, DayOfWeek)
control.Layout = CType(IIf(cpb.rbHorizontal.Checked, LayoutEnum.Horizontal, LayoutEnum.Vertical), LayoutEnum)
control.FullTimeScale = cpb.cbFullTimeScale.Checked
control.StartOfTimeScale = TimeSpan.Parse(cpb.tbStartTimeScale.Text)
control.EndOfTimeScale = TimeSpan.Parse(cpb.tbEndTimeScale.Text)
control.TimeScaleInterval = Int32.Parse(cpb.tbInterval.Text)
control.EnableEmptySlotClick = cpb.cbEnableEmptySlotClick.Checked
control.EmptySlotToolTip = cpb.tbEmptySlotToolTip.Text
RaiseComponentChanged(Nothing, Nothing, Nothing)
UpdateDesignTimeHtml()
End If
End Sub
Dim groups As TemplateGroupCollection
Private Const templateGroupName1 As String = "Item Templates"
Private Const templateDefinitionName1 As String = "ItemTemplate"
Private Const templateDefinitionName2 As String = "AlternatingItemTemplate"
Private Const templateGroupName2 As String = "Header Templates"
Private Const templateDefinitionName3 As String = "DateTemplate"
Private Const templateDefinitionName4 As String = "TimeTemplate"
Private internalGroup1 As TemplateGroup = Nothing
Private internalGroup2 As TemplateGroup = Nothing
''' -----------------------------------------------------------------------------
''' <summary>
''' Template definitions for the ScheduleCalendar control.
''' </summary>
''' -----------------------------------------------------------------------------
Public Overrides ReadOnly Property TemplateGroups() As TemplateGroupCollection
Get
' Start with the groups defined by the base designer class.
If groups Is Nothing Then
groups = MyBase.TemplateGroups
If internalGroup1 Is Nothing Then
Dim internalControl As ScheduleCalendar = CType(Component, ScheduleCalendar)
' Define a new group with two template definitions.
internalGroup1 = New TemplateGroup(templateGroupName1, internalControl.ControlStyle)
Dim templateDef1 As TemplateDefinition = New TemplateDefinition(Me, _
templateDefinitionName1, internalControl, _
templateDefinitionName1, internalControl.ControlStyle)
Dim templateDef2 As TemplateDefinition = New TemplateDefinition(Me, _
templateDefinitionName2, internalControl, _
templateDefinitionName2, internalControl.ControlStyle)
internalGroup1.AddTemplateDefinition(templateDef1)
internalGroup1.AddTemplateDefinition(templateDef2)
' Define a new group with two template definitions.
internalGroup2 = New TemplateGroup(templateGroupName2, internalControl.ControlStyle)
Dim templateDef3 As TemplateDefinition = New TemplateDefinition(Me, _
templateDefinitionName3, internalControl, _
templateDefinitionName3, internalControl.ControlStyle)
Dim templateDef4 As TemplateDefinition = New TemplateDefinition(Me, _
templateDefinitionName4, internalControl, _
templateDefinitionName4, internalControl.ControlStyle)
internalGroup2.AddTemplateDefinition(templateDef3)
internalGroup2.AddTemplateDefinition(templateDef4)
End If
' Add the new template group to the collection.
groups.Add(internalGroup1)
groups.Add(internalGroup2)
End If
Return groups
End Get
End Property
End Class