using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Wrox.ConnectionManagement
{
    public class ModifyableCalendar : WebPart
    {
        private IStringForCalendar _myProvider;
        string _stringTitle;
        Calendar myCalendar;

        [ConnectionConsumer("Calendar Title Consumer", "CalendarTitleConsumer")]
        public void RetrieveTitle(IStringForCalendar Provider)
        {
            _myProvider = Provider;
        }

        protected override void OnPreRender(EventArgs e)
        {
            EnsureChildControls();

            if (this._myProvider != null)
            {
                _stringTitle = _myProvider.CalendarString.Trim();
                myCalendar.Caption = _stringTitle;
            }
        }

        protected override void CreateChildControls()
        {
            Controls.Clear();
            myCalendar = new Calendar();
            this.Controls.Add(myCalendar);
        }
    }
}
