Exemplo n.º 1
0
        protected void SetupCreditCards(UITextField field, UIImageView image, List <KeyValuePair <object, string> > list, List <KeyValuePair <object, object> > list1)
        {
            // Setup the picker and model
            MyPickerModel model = new MyPickerModel(list);

            model.PickerChanged += (sender, e) => {
                Facade.Instance.CurrentRide.CreditCardId = e.SelectedKey.ToString();
                field.Text = e.SelectedValue;
                field.SendActionForControlEvents(UIControlEvent.ValueChanged);

                for (int i = 0; i < list1.Count; i++)
                {
                    if (list1[i].Key.ToString() == e.SelectedKey.ToString())
                    {
                        image.Image = (UIImage)list1[i].Value;
                    }
                }

                AppSettings.SelectedCard = e.SelectedKey.ToString();
            };

            UIPickerView picker = new UIPickerView();

            picker.ShowSelectionIndicator = true;
            picker.Model           = model;
            picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0);

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                if (String.IsNullOrEmpty(Facade.Instance.CurrentRide.CreditCardId) && list.Count > 0)
                {
                    Facade.Instance.CurrentRide.CreditCardId = list [0].Key.ToString();
                    field.Text = list [0].Value.ToString();

                    field.SendActionForControlEvents(UIControlEvent.ValueChanged);

                    AppSettings.SelectedCard = list [0].Key.ToString();
                }
                field.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            field.InputView          = picker;
            field.InputAccessoryView = toolbar;

            field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) {
                return(false);
            });
        }
Exemplo n.º 2
0
        protected void SetupGenericSelector(UITextField field, List <KeyValuePair <object, string> > list)
        {
            // Setup the picker and model
            MyPickerModel model = new MyPickerModel(list);

            model.PickerChanged += (sender, e) => {
                field.Text = e.SelectedValue;
                field.SendActionForControlEvents(UIControlEvent.ValueChanged);
            };

            UIPickerView picker = new UIPickerView();

            picker.ShowSelectionIndicator = true;
            picker.Model           = model;
            picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0);

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                //Nothing was selected, just press done
                if (String.IsNullOrEmpty(field.Text) && list.Count > 0)
                {
                    field.Text = list [0].Value;
                    field.SendActionForControlEvents(UIControlEvent.ValueChanged);
                }
                field.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            field.InputView          = picker;
            field.InputAccessoryView = toolbar;

            field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) {
                return(false);
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Setups the airlines.
        /// </summary>
        /// <param name="field">Field.</param>
        /// <param name="list">List.</param>
        /// <param name="direction">Direction 1 - Pick-Up and 2 - Drop-off </param>
        protected void SetupAirlines(UITextField field, List <KeyValuePair <object, string> > list, int direction = 0)
        {
            // Setup the picker and model
            MyPickerModel model = new MyPickerModel(list);

            if (direction == 1)
            {
                Facade.Instance.CurrentRide.PickUpAirlinesId = string.Empty;
                Facade.Instance.CurrentRide.PickUpAirlines   = string.Empty;
            }
            if (direction == 2)
            {
                Facade.Instance.CurrentRide.DropOffAirlinesId = string.Empty;
                Facade.Instance.CurrentRide.DropOffAirlines   = string.Empty;
            }

            model.PickerChanged += (sender, e) => {
                switch (direction)
                {
                case 1:
                    Facade.Instance.CurrentRide.PickUpAirlinesId = e.SelectedKey.ToString();
                    Facade.Instance.CurrentRide.PickUpAirlines   = e.SelectedValue.ToString();
                    break;

                case 2:
                    Facade.Instance.CurrentRide.DropOffAirlinesId = e.SelectedKey.ToString();
                    Facade.Instance.CurrentRide.DropOffAirlines   = e.SelectedValue.ToString();
                    break;

                default:
                    throw new NotImplementedException();
                }
                field.Text = e.SelectedValue;
                field.SendActionForControlEvents(UIControlEvent.ValueChanged);
            };

            UIPickerView picker = new UIPickerView();

            picker.ShowSelectionIndicator = true;
            picker.Model           = model;
            picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0);

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                //Default selection if nothing was selected
                if (direction == 1 && String.IsNullOrEmpty(Facade.Instance.CurrentRide.PickUpAirlinesId) && list.Count > 0)
                {
                    Facade.Instance.CurrentRide.PickUpAirlinesId = list [0].Key.ToString();
                    Facade.Instance.CurrentRide.PickUpAirlines   = list [0].Value.ToString();

                    field.Text = list [0].Value;
                }
                if (direction == 2 && String.IsNullOrEmpty(Facade.Instance.CurrentRide.DropOffAirlinesId) && list.Count > 0)
                {
                    Facade.Instance.CurrentRide.DropOffAirlinesId = list [0].Key.ToString();
                    Facade.Instance.CurrentRide.DropOffAirlines   = list [0].Value.ToString();

                    field.Text = list [0].Value;
                }

                field.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            field.InputView          = picker;
            field.InputAccessoryView = toolbar;

            field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) {
                return(false);
            });
        }
Exemplo n.º 4
0
        protected void SetupFlightType(UITextField field, bool IsPickUp)
        {
            List <KeyValuePair <object, string> > list = new List <KeyValuePair <object, string> > ();

            list.Add(new KeyValuePair <object, string>(true, String.Format("Domestic")));
            list.Add(new KeyValuePair <object, string>(false, String.Format("International")));
            //SetupGenericSelector (field, list);

            if (IsPickUp == true)
            {
                Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic = null;
                //field.Text = list [0].Value;
            }
            if (IsPickUp == false)
            {
                Facade.Instance.CurrentRide.DropOffFlightTypeIsDomestic = null;
                //field.Text = list [0].Value;
            }

            MyPickerModel model = new MyPickerModel(list);

            model.PickerChanged += (sender, e) => {
                field.Text = e.SelectedValue;

                bool outResult;
                if (bool.TryParse(e.SelectedKey.ToString(), out outResult))
                {
                    if (IsPickUp)
                    {
                        Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic = outResult;
                    }
                    else
                    {
                        Facade.Instance.CurrentRide.DropOffFlightTypeIsDomestic = outResult;
                    }
                }
                else
                {
                    if (list.Count > 0)
                    {
                        field.Text = list [0].Value;

                        if (IsPickUp)
                        {
                            Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic = (bool)list [0].Key;
                        }
                        else
                        {
                            Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic = (bool)list [0].Key;
                        }
                    }
                }

                field.SendActionForControlEvents(UIControlEvent.ValueChanged);
            };

            UIPickerView picker = new UIPickerView();

            picker.ShowSelectionIndicator = true;
            picker.Model           = model;
            picker.BackgroundColor = new UIColor((nfloat)(19.0 / 255.0), (nfloat)(36.0 / 255.0), (nfloat)(65.0 / 255.0), (nfloat)1.0);

            // Setup the toolbar
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
                //Default selection if nothing was selected
                if (IsPickUp == true && Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic == null && list.Count > 0)
                {
                    Facade.Instance.CurrentRide.PickUpFlightTypeIsDomestic = (bool)list [0].Key;
                    field.Text = list [0].Value;
                }
                if (IsPickUp == false && Facade.Instance.CurrentRide.DropOffFlightTypeIsDomestic == null && list.Count > 0)
                {
                    Facade.Instance.CurrentRide.DropOffFlightTypeIsDomestic = (bool)list [0].Key;
                    field.Text = list [0].Value;
                }

                field.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            field.InputView          = picker;
            field.InputAccessoryView = toolbar;

            field.ShouldChangeCharacters = new UITextFieldChange(delegate(UITextField textField, NSRange range, string replacementString) {
                return(false);
            });
        }