Imports Microsoft.VisualBasic
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts

Namespace Wrox.ConnectionManagement
    Public Class ModifyableCalendar
        Inherits WebPart

        Private _myProvider As IStringForCalendar
        Private _stringTitle As String
        Private myCalendar As Calendar = New Calendar()

        <ConnectionConsumer("Calendar Title Consumer", "CalendarTitleConsumer")> _
        Public Sub RetrieveTitle(ByVal Provider As IStringForCalendar)
            _myProvider = Provider
        End Sub

        Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
            EnsureChildControls()

            If Not (Me._myProvider Is Nothing) Then
                _stringTitle = _myProvider.CalendarString.Trim()
                myCalendar.Caption = _stringTitle
            End If
        End Sub

        Protected Overrides Sub CreateChildControls()
            Controls.Clear()
            Me.Controls.Add(myCalendar)
        End Sub
    End Class
End Namespace
