using System; using ElmSharp; namespace Xamarin.Forms.Platform.Tizen.Native { /// /// Extends the ElmSharp.DateTimeSelector class with functionality useful to renderer. /// public class DatePicker : DateTimeSelector { const string DateLayoutStyle = "date_layout"; const string DefaultEFLFormat = "%d/%b/%Y"; static readonly DateTime s_defaultMaximumDate = new DateTime(2037, 12, 31); static readonly DateTime s_defaultMinimumDate = new DateTime(1970, 1, 1); DateTime _date; DateTime _maxDate; DateTime _minDate; /// /// Initializes a new instance of the class. /// /// The parent EvasObject. public DatePicker(EvasObject parent) : base(parent) { SetFieldVisible(DateTimeFieldType.Hour, false); Style = DateLayoutStyle; ApplyDate(Date); ApplyMinDate(s_defaultMinimumDate); ApplyMaxDate(s_defaultMaximumDate); //TODO use date format currently set on the platform Format = DefaultEFLFormat; DateTimeChanged += (sender, e) => { Date = e.NewDate; }; } /// /// Gets or sets the displayed date. /// public DateTime Date { get { return _date; } set { if (_date != value) { ApplyDate(value); } } } /// /// Gets of sets the highest date selectable for this . /// /// /// Default value is 31st Dec, 2037. /// public DateTime MaximumDate { get { return _maxDate; } set { if (_maxDate != value) { ApplyMaxDate(value); } } } /// /// Gets of sets the lowest date selectable for this . /// /// /// Default value is 1st Jan, 1970. /// public DateTime MinimumDate { get { return _minDate; } set { if (_minDate != value) { ApplyMinDate(value); } } } /// /// Sets the DateTime property according to the given . /// /// The date value to be applied to the date picker. void ApplyDate(DateTime date) { _date = date; DateTime = date; } /// /// Sets the MaximumDateTime property according to the given . /// /// The maximum date value to be applied to the date picker. void ApplyMaxDate(DateTime maxDate) { _maxDate = maxDate; MaximumDateTime = maxDate; } /// /// Sets the MinimumDateTime property according to the given . /// /// The minimum date value to be applied to the date picker. void ApplyMinDate(DateTime minDate) { _minDate = minDate; MinimumDateTime = minDate; } } }