|
Option Strict On
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design 'ComponentChangedEventArgs
Imports System.Data
Imports System.Diagnostics ' Debug
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls ' DataboundControlDesigner definition
Imports System.Web.UI.WebControls
' -------------------------- Databound Schedule Controls v2.4 -----------------------
'
' ------------------------------ www.rekenwonder.com ---------------------------------
''' -----------------------------------------------------------------------------
''' Project : schedule
''' Class : rw.ScheduleDesigner
'''
''' -----------------------------------------------------------------------------
''' <summary>
''' ScheduleDesigner is a virtual class that adds design-time support
''' Base class for ScheduleCalendarDesigner and ScheduleGeneralDesiger
''' </summary>
''' -----------------------------------------------------------------------------
Public MustInherit Class ScheduleDesigner
Inherits DataBoundControlDesigner
Private internalControl As BaseSchedule = Nothing
Protected Sub New() ' hide constructor in this abstract class
End Sub
Public Overrides Sub Initialize(ByVal component As IComponent)
' Ensure that only a Schedule control can be created in this designer.
If Not TypeOf component Is BaseSchedule Then
Throw New ArgumentException("The component is not a Schedule control.")
End If
internalControl = CType(component, BaseSchedule)
MyBase.Initialize(component)
' Enable template editing from the smart tag menu
SetViewFlags(ViewFlags.TemplateEditing, True)
End Sub ' Initialize
Protected MustOverride Function GetDummyDataTable(ByVal minimumRows As Integer) As DataTable
''' -----------------------------------------------------------------------------
''' <summary>
''' Shows a Property Builder dialog box
''' This method is overridden in ScheduleCalendarDesigner and ScheduleGeneralDesigner
''' to show the appropriate dialog box
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' -----------------------------------------------------------------------------
Public MustOverride Sub OnPropertyBuilder(ByVal sender As Object, ByVal e As EventArgs)
Protected Overrides Function GetDesignTimeDataSource() As System.Collections.IEnumerable
Return New DataView(GetDummyDataTable(5))
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' Gets the HTML that is used to represent the control at design time..
''' </summary>
''' <returns>A string with the HTML</returns>
''' -----------------------------------------------------------------------------
Public Overrides Function GetDesignTimeHtml() As String
Dim designTimeHTML As String = Nothing
Dim hasATemplate As Boolean = Not Me.TemplatesAreEmpty()
If hasATemplate Then
Dim strCheckConfiguration As String = internalControl.CheckConfiguration()
If (strCheckConfiguration <> "") Then
Return CreatePlaceHolderDesignTimeHtml(strCheckConfiguration)
End If
Try
designTimeHTML = MyBase.GetDesignTimeHtml()
Finally
'control.DataSource = Nothing
End Try
Else
designTimeHTML = GetEmptyDesignTimeHtml()
End If
Return designTimeHTML
End Function
Protected Overrides Function GetErrorDesignTimeHtml(ByVal e As Exception) As String
'Return CreatePlaceHolderDesignTimeHtml("There was an error rendering the control.<br>Check to make sure all properties are valid.")
Return CreatePlaceHolderDesignTimeHtml(e.Message)
End Function
Private Shared validNames() As String = {"AlternatingItemStyle", "DataSourceID", _
"DataMember", "RangeHeaderStyle", "TitleStyle", "BackgroundStyle", _
"ItemStyle"}
Public Overrides Sub OnComponentChanged(ByVal sender As Object, ByVal e As ComponentChangedEventArgs)
If Not (e.Member Is Nothing) Then
Dim memberName As String = e.Member.Name
Dim current As String
For Each current In validNames
If memberName = current Then
Exit For
End If
Next current
Dim DataMemberNames() As String = {"DataSourceID", "DataMember", "TitleField", "DateField", _
"DataRangeStartField", "DataRangeEndField", "StartTimeField", "EndTimeField"}
If Array.IndexOf(DataMemberNames, memberName) > -1 Then
OnDataSourceChanged(True)
End If
End If
MyBase.OnComponentChanged(sender, e)
End Sub 'OnComponentChanged
Private lists As DesignerActionListCollection
''' -----------------------------------------------------------------------------
''' <summary>
''' Action lists for the smart menu of the Schedule control.
''' </summary>
''' -----------------------------------------------------------------------------
Public Overrides ReadOnly Property ActionLists() As DesignerActionListCollection
Get
If lists Is Nothing Then
lists = MyBase.ActionLists
lists.Add(New ScheduleDesignerActionList(Me.Component, Me))
End If
Return lists
End Get
End Property
''' -----------------------------------------------------------------------------
''' <summary>
''' Create a read-only property that determines whether the control
''' is using templates at design time.
''' </summary>
''' <returns>True if Templates are empty</returns>
''' -----------------------------------------------------------------------------
Protected ReadOnly Property TemplatesAreEmpty() As Boolean
Get
Return TemplateGroups.Count = 0
End Get
End Property
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.