using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; using System.Collections; using System.Collections.Specialized; using System.Globalization; namespace umbraco.controls { /// /// Summary description for datePicker. /// [DefaultProperty("Text"), ToolboxData("<{0}:datePicker runat=server>")] public class datePicker_old : System.Web.UI.WebControls.WebControl { private DateTime _datetime = new DateTime(1900, 1, 1); private bool _showTime = false; private int _yearsBack = 100; private string[] _minutes = {"00", "15", "30", "45"}; private string[] _hours = {"--", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"}; private string[] _days = {"--", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"}; private ArrayList _months = new ArrayList(); private ArrayList _years = new ArrayList(); private string _globalAlias = "Da-dk"; public string CustomMinutes { set {_minutes = value.Split(", ".ToCharArray());} } public bool ShowTime { set {_showTime = value;} get {return _showTime;} } public string GlobalizationAlias { set {_globalAlias = value;} get {return _globalAlias;} } public int YearsBack { set {_yearsBack = value;} get {return _yearsBack;} } [Bindable(true), Category("Appearance"), DefaultValue("")] public DateTime DateTime { get { return _datetime; } set { try { _datetime = value; } catch { } } } protected override void OnLoad(EventArgs e) { base.OnLoad (e); if (Page.IsPostBack) { try { _datetime = DateTime.Parse(System.Web.HttpContext.Current.Request.Form[this.ClientID]); } catch {} } } protected override void OnInit(EventArgs e) { base.OnInit (e); } /// /// Render this control to the output parameter specified. /// /// The HTML writer to write out to protected override void Render(HtmlTextWriter output) { System.Web.HttpContext.Current.Trace.Warn("rendering datetime control!"); DateTimeFormatInfo dtInfo = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat; string daySelect = "--", monthSelect = "--", yearSelect = "--", hourSelect = "--", minuteSelect = "--"; if (_datetime.Year > 1900) { daySelect = _datetime.Day.ToString(); monthSelect = dtInfo.MonthNames[_datetime.Month-1]; yearSelect = _datetime.Year.ToString(); hourSelect = _datetime.Hour.ToString(); if (hourSelect.Length < 2) hourSelect = "0" + hourSelect; minuteSelect = markMinute(_datetime.Minute); } _months.Add("--"); for (int i=0;i<12;i++) { _months.Add(dtInfo.MonthNames[i]); } _years.Add("--"); for (int i=DateTime.Now.Year-_yearsBack; i\"Pick")); base.RenderChildren(output); output.WriteLine(""); } private string markMinute(int minute) { int _currentDiff = 100; int _currentMinute = 0; System.Collections.ArrayList _localMinutes = new ArrayList(); foreach (string s in _minutes) { _localMinutes.Add(s); } _localMinutes.Add("60"); foreach (string s in _localMinutes) { if (s.Trim() != "") { if (_currentDiff > Math.Abs(int.Parse(s)-minute)) { _currentMinute = int.Parse(s); _currentDiff = Math.Abs(int.Parse(s)-minute); } } } if (_currentMinute == 60) return "00"; else { if (_currentMinute.ToString().Length == 1) return "0" + _currentMinute.ToString(); else return _currentMinute.ToString(); } } } }