/// <summary>
        /// Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <ExtendedTimePicker> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // todo: handle this scenario properly
            }

            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    var entry = new NoCaretField {
                        BorderStyle = UITextBorderStyle.RoundedRect
                    };
                    entry.Started += this.OnStarted;
                    entry.Ended   += this.OnEnded;
                    this._picker   = new UIDatePicker {
                        Mode     = UIDatePickerMode.Time,
                        TimeZone = new NSTimeZone("UTC")
                    };

                    nfloat width     = UIScreen.MainScreen.Bounds.Width;
                    var    uIToolbar = new UIToolbar(new CGRect(0, 0, width, 44))
                    {
                        BarStyle    = UIBarStyle.Default,
                        Translucent = true
                    };

                    var uIBarButtonItem  = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
                    var uIBarButtonItem2 = new UIBarButtonItem(
                        UIBarButtonSystemItem.Done,
                        delegate
                    {
                        entry.ResignFirstResponder();
                    });

                    uIToolbar.SetItems(new[] { uIBarButtonItem, uIBarButtonItem2 }, false);

                    if (Device.Idiom == TargetIdiom.Phone)
                    {
                        entry.InputView          = this._picker;
                        entry.InputAccessoryView = uIToolbar;
                    }
                    else
                    {
                        entry.InputView          = new UIView(CGRect.Empty);
                        entry.InputAccessoryView = new UIView(CGRect.Empty);
                    }

                    this._picker.ValueChanged += this.HandleValueChanged;
                    SetNativeControl(entry);
                }
            }

            UpdateTime();

            SetBorder();
        }
        /// <summary>
        /// Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <BindablePicker> e)
        {
            if (e.OldElement != null && e.OldElement.Items != null)
            {
                e.OldElement.Items.CollectionChanged -= RowsCollectionChanged;
            }

            if (e.NewElement != null && e.NewElement.Items != null)
            {
                e.NewElement.Items.CollectionChanged += RowsCollectionChanged;
            }

            if (this.Control != null || e.NewElement == null)
            {
                return;
            }

            var entry = new NoCaretField
            {
                BorderStyle = e.NewElement.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None
            };

            entry.Started += OnStarted;
            entry.Ended   += OnEnded;

            _picker = new UIPickerView
            {
                DataSource = new PickerSource(e.NewElement)
            };

            var width     = UIScreen.MainScreen.Bounds.Width;
            var uIToolbar = new UIToolbar(new CGRect(0, 0, width, 44))
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true
            };

            var uIBarButtonItem  = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            var uIBarButtonItem2 = new UIBarButtonItem(
                UIBarButtonSystemItem.Done,
                delegate { entry.ResignFirstResponder(); });

            uIToolbar.SetItems(new[] { uIBarButtonItem, uIBarButtonItem2 }, false);

            if (Device.Idiom == TargetIdiom.Phone)
            {
                entry.InputView          = _picker;
                entry.InputAccessoryView = uIToolbar;
            }
            else
            {
                entry.InputView          = new UIView(CGRect.Empty);
                entry.InputAccessoryView = new UIView(CGRect.Empty);
            }

            ((PickerSource)_picker.DataSource).ValueChanged += HandleValueChanged;
            SetNativeControl(entry);
            UpdatePicker();
        }
예제 #3
0
        /// <summary>
        /// Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <ExtendedDatePicker> e)
        {
            base.OnElementChanged(e);
            NoCaretField entry = new NoCaretField {
                BorderStyle = UITextBorderStyle.RoundedRect
            };

            entry.Started += new EventHandler(OnStarted);
            entry.Ended   += new EventHandler(OnEnded);
            _picker        = new UIDatePicker {
                Mode     = UIDatePickerMode.Date,
                TimeZone = new NSTimeZone("UTC")
            };
            nfloat    width     = UIScreen.MainScreen.Bounds.Width;
            UIToolbar uIToolbar = new UIToolbar(new CGRect(0, 0, width, 44))
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true
            };
            UIBarButtonItem uIBarButtonItem  = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            UIBarButtonItem uIBarButtonItem2 = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate(object o, EventArgs a) {
                entry.ResignFirstResponder();
            });

            uIToolbar.SetItems(new UIBarButtonItem[] {
                uIBarButtonItem,
                uIBarButtonItem2
            }, false);

            if (Device.Idiom == TargetIdiom.Phone)
            {
                entry.InputView          = _picker;
                entry.InputAccessoryView = uIToolbar;
            }
            else
            {
                entry.InputView          = new UIView(CGRect.Empty);
                entry.InputAccessoryView = new UIView(CGRect.Empty);
            }

            SetNativeControl(entry);
            UpdateDateFromModel(false);
            UpdateMaximumDate();
            UpdateMinimumDate();
            _picker.ValueChanged += new EventHandler(HandleValueChanged);

            var view = (ExtendedDatePicker)Element;

            SetBorder(view);
        }
예제 #4
0
        /// <summary>
        /// Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <BindablePicker> e)
        {
            ((ObservableCollection <string>)e.NewElement.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(RowsCollectionChanged);
            NoCaretField entry = new NoCaretField {
                BorderStyle = e.NewElement.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None
            };

            entry.Started += new EventHandler(OnStarted);
            entry.Ended   += new EventHandler(OnEnded);
            _picker        = new UIPickerView {
                Model = new PickerSource(e.NewElement)
            };
            nfloat    width     = UIScreen.MainScreen.Bounds.Width;
            UIToolbar uIToolbar = new UIToolbar(new CGRect(0, 0, width, 44))
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true
            };
            UIBarButtonItem uIBarButtonItem  = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            UIBarButtonItem uIBarButtonItem2 = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate(object o, EventArgs a) {
                entry.ResignFirstResponder();
            });

            uIToolbar.SetItems(new UIBarButtonItem[] {
                uIBarButtonItem,
                uIBarButtonItem2
            }, false);

            if (Device.Idiom == TargetIdiom.Phone)
            {
                entry.InputView          = _picker;
                entry.InputAccessoryView = uIToolbar;
            }
            else
            {
                entry.InputView          = new UIView(CGRect.Empty);
                entry.InputAccessoryView = new UIView(CGRect.Empty);
            }

            ((PickerSource)_picker.DataSource).ValueChanged += new EventHandler(HandleValueChanged);
            SetNativeControl(entry);
            UpdatePicker();
        }