private void InitializeMonthPicker(int month)
 {
     _monthPicker.MinValue = MinNumberOfMonths;
     _monthPicker.MaxValue = MaxNumberOfMonths;
     _monthPicker.SetDisplayedValues(GetMonthNames());
     _monthPicker.Value = month;
     if (!InfiniteScroll)
     {
         _monthPicker.WrapSelectorWheel      = false;
         _monthPicker.DescendantFocusability = DescendantFocusability.BlockDescendants;
     }
 }
Example #2
0
        public static Task <int> ShowPickerDialog(Context context, int defaultIndex, string[] displayedData)
        {
            var tcs = new TaskCompletionSource <int>();

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            var picker = new NumberPicker(context);

            picker.MinValue = 0;
            picker.MaxValue = displayedData.Length - 1;
            picker.Value    = defaultIndex;
            picker.SetDisplayedValues(displayedData);
            var parent = new FrameLayout(context);

            parent.AddView(picker, new FrameLayout.LayoutParams(
                               FrameLayout.LayoutParams.WrapContent,
                               FrameLayout.LayoutParams.WrapContent,
                               GravityFlags.Center));
            builder.SetView(parent);
            builder.SetPositiveButton("OK", (senderAlert, args) =>
            {
                tcs.SetResult(picker.Value);
            });
            builder.SetNegativeButton("Cancel", (senderAlert, args) =>
            {
                tcs.SetResult(-1);
            });

            var listener = new PickerDialogInterfaceOnCancelListener(tcs);

            builder.SetOnCancelListener(listener);
            builder.Create().Show();
            return(tcs.Task);
        }
 public void SetAverageSelection(string[] intervalSelection)
 {
     averagePicker.SetDisplayedValues(intervalSelection);
     averagePicker.MinValue          = 0;
     averagePicker.MaxValue          = intervalSelection.Length - 1;
     averagePicker.WrapSelectorWheel = true;
 }
        protected override void OnBindDialogView(View view)
        {
            base.OnBindDialogView(view);

            var currentValue = GetPersistedInt(SettingsScreen.DefaultRadiusValue);

            if (BuildVersionCodes.Honeycomb > Build.VERSION.SdkInt)
            {
                _radioGroup = (RadioGroup)view;
                foreach (var distance in Constants.AlarmRadiusValues)
                {
                    var radioButton = new RadioButton(Context);
                    radioButton.SetText(string.Format(Context.GetString(Resource.String.settings_default_radius_sum), distance), TextView.BufferType.Normal);
                    radioButton.Checked = distance == currentValue;
                    radioButton.Id      = distance;
                    _radioGroup.AddView(radioButton);
                }
            }
            else
            {
                _numberPicker = (NumberPicker)view;
                SetNumberPickerTextColor(_numberPicker, Context.Resources.GetColor(Resource.Color.dark));
                _numberPicker.DescendantFocusability = DescendantFocusability.BlockDescendants;
                _numberPicker.SetDisplayedValues(Constants.AlarmRadiusValues.Select(v => v.ToString()).ToArray());
                _numberPicker.MinValue          = 0;
                _numberPicker.MaxValue          = Constants.AlarmRadiusValues.Count() - 1;
                _numberPicker.WrapSelectorWheel = false;
                _numberPicker.Value             = Constants.AlarmRadiusValues.IndexOf(currentValue);
            }
        }
Example #5
0
        public void OnClick(Android.Views.View v)
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = Android.Views.DescendantFocusability.BlockDescendants;
                picker.Value = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            EController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton(blankPicker.CancelButtonText ?? "Cancel", (s, a) =>
            {
                blankPicker.SendCancelClicked();
                EController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                _dialog = null;
            });
            builder.SetPositiveButton(blankPicker.DoneButtonText ?? "OK", (s, a) =>
            {
                EController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                //blankPicker.SelectedItem = picker.Value;
                blankPicker.SendDoneClicked();
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    EController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (sender, args) =>
            {
                EController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
            };
            _dialog.Show();
        }
        public override void OnAttachedToWindow()
        {
            base.OnAttachedToWindow();

            Java.Lang.Class         classForId      = Java.Lang.Class.ForName("com.android.internal.R$id");
            Java.Lang.Reflect.Field timePickerField = classForId.GetField("timePicker");

            timePicker = FindViewById <TimePicker> (timePickerField.GetInt(null));

            Java.Lang.Reflect.Field field = classForId.GetField("minute");

            NumberPicker mMinuteSpinner = timePicker.FindViewById <NumberPicker> (field.GetInt(null));

            if (mMinuteSpinner != null)
            {
                mMinuteSpinner.MinValue = 0;
                mMinuteSpinner.MaxValue = (60 / interval) - 1;

                List <string> displayedValues = new List <string> ();

                for (int i = 0; i < 60; i += interval)
                {
                    displayedValues.Add(i.ToString("00"));
                }

                mMinuteSpinner.SetDisplayedValues(displayedValues.ToArray());
            }
            OnTimeChanged(timePicker, hourOfDay, minute / interval);
        }
Example #7
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your fragment here
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
            var inflater = Activity.LayoutInflater;

            var dialogView = inflater.Inflate(Resource.Layout.dialog_gender, null);

            if (dialogView != null)
            {
                NumberPicker genderPicker = dialogView.FindViewById <NumberPicker>(Resource.Id.genderPicker);
                genderPicker.MinValue          = 0;
                genderPicker.MaxValue          = 1;
                genderPicker.WrapSelectorWheel = false;
                genderPicker.SetDisplayedValues(new string[] { "Male", "Female" });
            }

            builder.SetView(dialogView);

            builder.SetMessage(Resource.String.gender)
            .SetPositiveButton("Set", OnClick_Set)
            .SetNegativeButton("Cancel", OnClick_Cancel);

            return(builder.Create());
        }
Example #8
0
 public void Include(NumberPicker numberPicker)
 {
     numberPicker.ValueChanged += (sender, args) => numberPicker.Value = 0 + args.NewVal + numberPicker.MinValue + numberPicker.MaxValue;
     numberPicker.MinValue      = numberPicker.MinValue + 1;
     numberPicker.MaxValue      = numberPicker.MaxValue + 1;
     numberPicker.SetDisplayedValues(new string[] { "" });
 }
Example #9
0
        void OnClick()
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
                picker.Value = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton(global::Android.Resource.String.Cancel, (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                // It is possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
                _dialog = null;
            });
            builder.SetPositiveButton(global::Android.Resource.String.Ok, (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                    Control?.ClearFocus();
                }
                _dialog = null;
            });

            (_dialog = builder.Create()).Show();
        }
Example #10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            LinearLayout linLayoutH = new LinearLayout(this.Activity);

            LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            linLayoutH.LayoutParameters = params1;

            var numPicker = new NumberPicker(this.Activity);

            numPicker.MaxValue = maxValue;
            numPicker.MinValue = 0;
            if (isType)
            {
                numPicker.SetDisplayedValues(Constants.PRACTICE_TYPES);
                numPicker.Value = Array.IndexOf(Constants.PRACTICE_TYPES, textView.Text);
            }
            else
            {
                numPicker.Value = (int)float.Parse(textView.Text);
            }

            linLayoutH.AddView(numPicker);


            LinearLayout linLayoutV = new LinearLayout(this.Activity);

            linLayoutV.Orientation = Orientation.Vertical;
            linLayoutV.AddView(linLayoutH);

            Button okButton = new Button(this.Activity);

            okButton.Click += (sender, e) =>
            {
                textView.Text = numPicker.Value.ToString();

                if (isType)
                {
                    textView.Text = Constants.PRACTICE_TYPES[numPicker.Value];
                }
                else
                {
                    textView.Text    = numPicker.Value.ToString();
                    seekBar.Progress = (int)float.Parse(textView.Text);
                }

                Dismiss();
            };

            params1.Gravity           = GravityFlags.CenterHorizontal;
            okButton.LayoutParameters = params1;
            okButton.Text             = "Done";

            linLayoutV.AddView(okButton);
            return(linLayoutV);
        }
        private void Control_Click(object sender, EventArgs e)
        {
            Picker model  = Element;
            var    picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;

                picker.SetDisplayedValues(model.Items.ToArray());

                picker.WrapSelectorWheel = false;
                picker.Value             = model.SelectedIndex;
            }
            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);
            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);
            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton("Cancel  ", (s, a) =>
            {
                MessagingCenter.Send <Object>(this, "Cancel_Clicked");
            });
            builder.SetPositiveButton("Ok ", (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                }
                MessagingCenter.Send <Object>(this, "Ok_Clicked");
            });
            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            };
            _dialog.Show();
        }
Example #12
0
        private void ShowPauseDialog()
        {
            View dialogView = LayoutInflater.Inflate(Resource.Layout.spinner_dialog, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetView(dialogView);
            builder.SetCancelable(false);
            builder.SetTitle(INFECTION_STATUS_PAUSE_DIALOG_TITLE);
            builder.SetMessage(INFECTION_STATUS_PAUSE_DIALOG_MESSAGE);
            _picker          = dialogView.FindViewById(Resource.Id.picker) as NumberPicker;
            _picker.MinValue = 0;
            _picker.MaxValue = 4;
            _picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
            _picker.SetDisplayedValues(
                new[]
            {
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_NO_REMINDER,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_ONE_HOUR,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_TWO_HOURS,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_FOUR_HOURS,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_EIGHT_HOURS,
            });

            builder.SetPositiveButton(INFECTION_STATUS_PAUSE_DIALOG_OK_BUTTON, (sender, args) =>
            {
                switch (_picker.Value)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    StartReminderService((int)Math.Pow(2, _picker.Value - 1));
                    break;
                }
                StopGoogleAPI();
                (sender as AlertDialog)?.Dismiss();
            });

            if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.M)
            {
                AlertDialog alertDialog = builder.Create();
                alertDialog.Window.DecorView.LayoutDirection = LayoutUtils.GetLayoutDirection();
                alertDialog.Show();
            }
            else
            {
                builder.Create();
                builder.Show();
            }
        }
Example #13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.LogPlayer);

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            paintingView   = FindViewById <PaintingView>(Resource.Id.LogPaintingView);
            speedPicker    = FindViewById <NumberPicker>(Resource.Id.SpeedPicker);
            playStopButton = FindViewById <Button>(Resource.Id.Play3dButton);
            rewindSeekbar  = FindViewById <SeekBar>(Resource.Id.seekBar1);

            rewindSeekbar.Enabled = false;

            speedPicker.MinValue          = 0;
            speedPicker.MaxValue          = 7;
            speedPicker.WrapSelectorWheel = false;
            var speeds = new string[] { "0.25", "0.5", "0.75", "1", "1.25", "1.5", "1.75", "2" };

            speedPicker.SetDisplayedValues(speeds);

            playStopButton.Click += OnPlayStopButtonClicked;

            paintingView.DrawTrajectory = Storage.TrajectoryTracingEnabled;

            speedPicker.Value         = 3;
            speedPicker.ValueChanged += (o, e) =>
            {
                paintingView.SpeedMultiplier = float.Parse(speeds[speedPicker.Value]);
            };

            rewindSeekbar.Max = Storage.NumberOfFrames;
            paintingView.CoordinatesUpdated += () => RunOnUiThread(() =>
            {
                rewindSeekbar.Progress = Storage.CurrentFrame;
                rewindSeekbar.RefreshDrawableState();
            });

            paintingView.Finished += () =>
            {
                OnPlayStopButtonClicked(playStopButton, null);
            };

            rewindSeekbar.ProgressChanged += (o, e) =>
            {
                Storage.CurrentFrame = rewindSeekbar.Progress;
            };
        }
Example #14
0
        public Dialog CreateStringPickerDialog(Bundle savedInstanceState, int AlertInd, int Value)
        {
            NumberPicker strPicker = new NumberPicker(this);

            strPicker.MinValue = 0;
            strPicker.MaxValue = 6;
            string[] StrValueNames = { "Secs", "Mins", "Hours", "Days", "Weeks", "Months", "Years" };
            strPicker.SetDisplayedValues(StrValueNames);
            strPicker.Value = Value;
            var builder = new AlertDialog.Builder(this)
                          .SetView(strPicker)
                          .SetNegativeButton("Cancel", (sender, args) =>
            {
                // Do something when this button is clicked.
            })
                          .SetPositiveButton("Set", (sender, args) =>
            {
                if (AlertInd == 1)
                {
                    _AlertOneSelectStr  = strPicker.Value;
                    _UiAlertOneStr.Text = StrValueNames[_AlertOneSelectStr];
                }
                else if (AlertInd == 2)
                {
                    _AlertTwoSelectStr  = strPicker.Value;
                    _UiAlertTwoStr.Text = StrValueNames[_AlertTwoSelectStr];
                }
                else if (AlertInd == 3)
                {
                    _AlertThreeSelectStr  = strPicker.Value;
                    _UiAlertThreeStr.Text = StrValueNames[_AlertThreeSelectStr];
                }
                else if (AlertInd == 4)
                {
                    _AlertForeSelectStr  = strPicker.Value;
                    _UiAlertForeStr.Text = StrValueNames[_AlertForeSelectStr];
                }
                else if (AlertInd == 5)
                {
                    _AlertFiveSelectStr  = strPicker.Value;
                    _UiAlertFiveStr.Text = StrValueNames[_AlertFiveSelectStr];
                }
            })
                          .SetTitle("Select");

            return(builder.Create());
        }
Example #15
0
        public virtual void AddData(List <string> data, string varName, string title, string extra)
        {
            if (ViewX is NumberPicker)
            {
                NumberPicker pickerView = ViewX as NumberPicker;

                pickerView.SaveFromParentEnabled = false;
                pickerView.SaveEnabled           = true;

                pickerView.SetDisplayedValues(data.ToArray());
                pickerView.MinValue          = 0;
                pickerView.MaxValue          = data.Count - 1;
                pickerView.Value             = 0;
                pickerView.WrapSelectorWheel = false;

                AddAction(varName, title);
            }
            else if (ViewX is Spinner)
            {
                Spinner spinner = ViewX as Spinner;
                var     adapter = spinner.Adapter as TextImageAdapter;
                if (adapter == null)
                {
                    adapter = new TextImageAdapter(MainActivity.TheView);
                }
                string first = null;//InitValue == null ? null : InitValue.AsString();
                adapter.SetItems(data, first);
                spinner.Adapter = adapter;
                AddAction(varName, title);
            }
            else if (ViewX is ListView)
            {
                ListView listView = ViewX as ListView;
                var      adapter  = listView.Adapter as TextImageAdapter;
                if (adapter == null)
                {
                    adapter = new TextImageAdapter(MainActivity.TheView);
                }
                adapter.SetItems(data);
                listView.Adapter = adapter;
                AddAction(varName, title);
            }
        }
Example #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.activity_drink_info);

            var mToolbar = FindViewById <Toolbar>(Resource.Id.app_bar_drink);

            SetActionBar(mToolbar);
            ActionBar.Title = ""; //No title

            drinkGlass   = FindViewById <NumberPicker>(Resource.Id.drink_glass);
            drinkModel   = FindViewById <NumberPicker>(Resource.Id.drink_model);
            drinkPercent = FindViewById <TextView>(Resource.Id.drink_percent_consumed_text);
            SeekBar seekbar = FindViewById <SeekBar>(Resource.Id.drink_percent_consumed_seekbar);

            drinkAdd    = FindViewById <Button>(Resource.Id.app_bar_add);
            drinkCancel = FindViewById <Button>(Resource.Id.app_bar_cancel);

            //Set Control Properties
            drinkGlass.MinValue          = 0;
            drinkGlass.MaxValue          = 8;
            drinkGlass.WrapSelectorWheel = true;
            drinkGlass.SetDisplayedValues(new string[] { "Beer", "Brandy", "Martini", "Whiskey", "Wine", "Vodka", "Tequila", "Liquor", "Bottle" });

            drinkModel.MinValue          = 0;
            drinkModel.MaxValue          = 6;
            drinkModel.WrapSelectorWheel = true;
            drinkModel.SetDisplayedValues(new string[] { "Lightbeer", "Liquor", "Whiskey", "Gin", "Vodka", "Red Wine", "White Wine" });

            seekbar.Max = 100;
            seekbar.SetOnSeekBarChangeListener(this);

            drinkPercent.Text = "Percent Consumed: " + seekbar.Progress.ToString() + "%";

            drinkAdd.Click    += delegate { };
            drinkCancel.Click += delegate { Finish(); };
        }
 private void SetupTime()
 {
     //Til timepicker - bestemmer hvilke vƦrdier man kan vƦlge mellem pƄ timePickeren
     hour            = view.FindViewById <NumberPicker>(Resource.Id.numberPickerHour);
     minute          = view.FindViewById <NumberPicker>(Resource.Id.numberPickerMinute);
     hour.MaxValue   = 23;
     hour.MinValue   = 0;
     hour.Value      = DateTime.Now.Hour;
     minute.MaxValue = 3;
     minute.MinValue = 0;
     minute.SetDisplayedValues(new String[] { "0", "15", "30", "45" }); //Interval pƄ 15,30,45 minutter startid
     //minute.Value = DateTime.Now.Minute;
     hour1            = view.FindViewById <NumberPicker>(Resource.Id.numberPickerHour2);
     minute1          = view.FindViewById <NumberPicker>(Resource.Id.numberPickerMinute2);
     hour1.MaxValue   = 23;
     hour1.MinValue   = 0;
     hour1.Value      = DateTime.Now.Hour;
     minute1.MaxValue = 3;
     minute1.MinValue = 0;
     minute1.SetDisplayedValues(new String[] { "0", "15", "30", "45" }); //Interval pƄ 15,30,45 minutter sluttid
     //minute1.Value = DateTime.Now.Minute;
 }
        private void Control_Click(object sender, EventArgs e)
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
                picker.Value = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton(global::Android.Resource.String.Cancel, (s, a) => {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                // It is possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
                _dialog = null;
            });

            builder.SetPositiveButton(global::Android.Resource.String.Ok, (s, a) => {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                    Control?.ClearFocus();
                }
                _dialog = null;
            });



            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) => {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
            };
            _dialog.Show();
            _dialog.Window.SetBackgroundDrawable(new ColorDrawable(Android.Graphics.Color.White));
            //modify the color of the button in the dialog box
            Android.Widget.Button nbutton = _dialog.GetButton((int)Android.Content.DialogButtonType.Positive);
            nbutton.SetTextColor(Android.Graphics.Color.ParseColor("#3367b0"));
            nbutton = _dialog.GetButton((int)Android.Content.DialogButtonType.Negative);
            nbutton.SetTextColor(Android.Graphics.Color.ParseColor("#3367b0"));

            nbutton.TextSize = 16f;
        }
Example #19
0
        void IPickerRenderer.OnClick()
        {
            DoublePicker model = (DoublePicker)Element;

            if (_dialog != null)
            {
                return;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Horizontal
            };

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
                picker.Value         = model.SelectedIndexes[0];
                picker.TextAlignment = AViews.TextAlignment.Center;
            }
            picker.LayoutParameters = new TableLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent, 0.5f);
            layout.AddView(picker);

            var picker2 = new NumberPicker(Context);

            if (model.SecondaryItems != null && model.SecondaryItems.Any())
            {
                picker2.MaxValue = model.SecondaryItems.Count - 1;
                picker2.MinValue = 0;
                picker2.SetDisplayedValues(model.SecondaryItems.ToArray());
                picker2.WrapSelectorWheel      = false;
                picker2.DescendantFocusability = DescendantFocusability.BlockDescendants;
                picker2.Value         = model.SelectedIndexes[1];
                picker2.TextAlignment = AViews.TextAlignment.Center;
            }
            picker2.LayoutParameters = new TableLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent, 0.5f);
            layout.AddView(picker2);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);

            if (!Element.IsSet(Picker.TitleColorProperty))
            {
                builder.SetTitle(model.Title ?? "");
            }
            else
            {
                var title = new SpannableString(model.Title ?? "");
                title.SetSpan(new ForegroundColorSpan(model.TitleColor.ToAndroid()), 0, title.Length(), SpanTypes.ExclusiveExclusive);

                builder.SetTitle(title);
            }

            builder.SetNegativeButton(global::Android.Resource.String.Cancel, (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                _dialog = null;
            });
            builder.SetPositiveButton(global::Android.Resource.String.Ok, (s, a) =>
            {
                var doublePicker = Element as DoublePicker;
                if (doublePicker != null)
                {
                    var selectedIndexes = new int[] { picker.Value, picker2.Value };
                    ElementController.SetValueFromRenderer(DoublePicker.SelectedIndexesProperty, selectedIndexes);
                    model.RaiseSelectedIndexesChanged(selectedIndexes);

                    //ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                    // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                    // In this case, the Element & Control will no longer exist.


                    string text = null;

                    if (doublePicker.Items.Count > 0 && selectedIndexes[0] >= 0)
                    {
                        text = doublePicker.Items[selectedIndexes[0]];
                    }

                    if (doublePicker.SecondaryItems.Count > 0 && selectedIndexes[1] >= 0)
                    {
                        text = $"{text}{doublePicker.Separator}{doublePicker.SecondaryItems[selectedIndexes[1]]}".Trim();
                    }

                    Control.Text = text;

                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (sender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                _dialog?.Dispose();
                _dialog = null;
            };
            _dialog.Show();
        }
Example #20
0
        private void Control_Click(object sender, EventArgs e)
        {
            var model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel = false;
                picker.Value             = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton(_negativeText, (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);

                //Clear focus to hold control about picker
                Control?.ClearFocus();
                _dialog = null;
            });
            builder.SetPositiveButton(_positiveText, (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);

                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);

                    //Clear focus to hold control about picker
                    Control?.ClearFocus();
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            };
            _dialog.Show();
        }
Example #21
0
        void IPickerRenderer.OnClick()
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
                picker.Value = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);

            if (!Element.IsSet(Picker.TitleColorProperty))
            {
                builder.SetTitle(model.Title ?? "");
            }
            else
            {
                var title = new SpannableString(model.Title ?? "");
                title.SetSpan(new ForegroundColorSpan(model.TitleColor.ToAndroid()), 0, title.Length(), SpanTypes.ExclusiveExclusive);

                builder.SetTitle(title);
            }

            builder.SetNegativeButton(global::Android.Resource.String.Cancel, (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                _dialog = null;
            });
            builder.SetPositiveButton(global::Android.Resource.String.Ok, (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (sender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
            };
            _dialog.Show();
        }
        private void Control_Click(object sender, EventArgs e)
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                // set style here
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel = false;
                picker.Value             = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Android.Widget.Orientation.Vertical
            };

            layout.AddView(picker);
            //layout.SetBackground(ContextCompat.GetDrawable(Android.App.Application.Context, Resource.Drawable.dialogBackground));

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);

            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton("Cancel  ", (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                // It is possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
                _dialog = null;
            });
            builder.SetPositiveButton("Ok ", (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                    Control?.ClearFocus();
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            };
            _dialog.ShowEvent += (ssender, args) =>
            {
                var dialog = (AlertDialog)ssender;
                Android.Widget.Button negativeButton = dialog.GetButton(DialogButtonType.Negative.GetHashCode());
                negativeButton.SetTextColor(Android.Graphics.Color.Gray);
            };

            _dialog.Show();
        }
Example #23
0
        private void Control_Click(object sender, EventArgs e)
        {
            Picker model      = Element;
            var    RCKWLLFont = Typeface.CreateFromAsset(Xamarin.Forms.Forms.Context.ApplicationContext.Assets, "RCKWLL.ttf");

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel      = false;
                picker.DescendantFocusability = Android.Views.DescendantFocusability.BlockDescendants;
                picker.Value = model.SelectedIndex;
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical
            };

            layout.AddView(picker);

            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);
            //Create a custom title element
            TextView title = new TextView(Context)
            {
                Text     = model.Title,
                Typeface = RCKWLLFont,
                Gravity  = Android.Views.GravityFlags.Center,
            };

            title.TextSize = 20;
            title.SetTextColor(Android.Graphics.Color.White);
            title.SetBackgroundColor(Android.Graphics.Color.Rgb(234, 49, 117));
            title.SetHeight(100);

            var builder = new AlertDialog.Builder(Context);

            builder.SetView(layout);
            builder.SetCustomTitle(title);

            builder.SetNegativeButton("CANCEL", (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                // It is possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
                _dialog = null;
            });

            builder.SetPositiveButton("OK", (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                    Control?.ClearFocus();
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            };
            _dialog.Show();
        }
        private void UpdateItemsSource()
        {
            Control.RemoveAllViews();

            if (Element.ItemsSource == null)
            {
                return;
            }

            IList <bool> wrapWheels = Element.WrapSelectorWheels;

            if (wrapWheels == null || wrapWheels.Count != Element.ItemsSource.Count)
            {
                wrapWheels = new List <bool>();

                for (int i = 0; i < Element.ItemsSource.Count; ++i)
                {
                    wrapWheels.Add(true);
                }
            }

            for (int i = 0; i < Element.ItemsSource.Count; ++i)
            {
                NumberPicker picker = new NumberPicker(Context)
                {
                    LayoutParameters = new TableLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent, 0.5f),
                    TextAlignment    = Android.Views.TextAlignment.Center,
                    Tag = i,

                    MinValue = 0,
                    MaxValue = Element.ItemsSource[i].Count - 1
                };


                picker.WrapSelectorWheel = wrapWheels[i];
                picker.SetDisplayedValues(Element.ItemsSource[i].ToArray());


                #region restore Indexes

                int curIndex = Element.SelectedIndexes[i];

                if (curIndex < picker.MinValue)
                {
                    curIndex = picker.MinValue;
                }

                if (curIndex > picker.MaxValue)
                {
                    curIndex = picker.MaxValue;
                }

                Element.SelectedIndexes[i] = curIndex;

                picker.Value = curIndex;

                #endregion

                picker.ValueChanged += Picker_ValueChanged;

                Control.AddView(picker);
            }
        }
Example #25
0
        private void Control_Click(object sender, EventArgs e)
        {
            Picker model = Element;

            var picker = new NumberPicker(Context);

            if (model.Items != null && model.Items.Any())
            {
                // set style here
                picker.MaxValue = model.Items.Count - 1;
                picker.MinValue = 0;
                //picker.SetBackgroundColor(Android.Graphics.Color.Pink);
                picker.SetDisplayedValues(model.Items.ToArray());
                picker.WrapSelectorWheel = false;
                picker.Value             = model.SelectedIndex;
                picker.ShowDividers      = ShowDividers.None;

                try
                {
                    //for (int i = 0; i < picker.ChildCount+1; i++)
                    //{
                    //    var tmp = picker.GetChildAt(i);
                    //    if (tmp is EditText texte)
                    //    {
                    //        texte.SetTextColor(Android.Graphics.Color.Green);
                    //    }
                    //}


                    var numberPickerType = Java.Lang.Class.FromType(typeof(NumberPicker));
                    var divider          = numberPickerType.GetDeclaredField("mSelectionDivider");
                    divider.Accessible = true;

                    var dividerDraw = new ColorDrawable(Android.Graphics.Color.Transparent);
                    divider.Set(picker, dividerDraw);
                }
                catch
                {
                    // ignored
                }
            }

            var layout = new LinearLayout(Context)
            {
                Orientation = Orientation.Vertical, ClipToOutline = true, ShowDividers = ShowDividers.None
            };

            layout.AddView(picker);
            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);

            var builder = new AlertDialog.Builder(Context, Resource.Style.DialogeTheme);

            builder.SetView(layout);

            builder.SetTitle(model.Title ?? "");
            builder.SetNegativeButton("Cancel  ", (s, a) =>
            {
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                // It is possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
                _dialog = null;
            });
            builder.SetPositiveButton("Ok ", (s, a) =>
            {
                ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
                // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
                // In this case, the Element & Control will no longer exist.
                if (Element != null)
                {
                    if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    {
                        Control.Text = model.Items[Element.SelectedIndex];
                    }
                    ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                    // It is also possible for the Content of the Page to be changed when Focus is changed.
                    // In this case, we'll lose our Control.
                    Control?.ClearFocus();
                }
                _dialog = null;
            });

            _dialog = builder.Create();
            _dialog.DismissEvent += (ssender, args) =>
            {
                ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            };
            _dialog.Show();
            //_dialog.GetButton((int)DialogButtonType.Positive).SetBackgroundColor(Android.Graphics.Color.Green);
        }
    private void Control_Click1(object sender, EventArgs e)
    {
        Picker model  = Element;
        var    picker = new NumberPicker(Context);

        if (model.Items != null && model.Items.Any())
        {
            picker.MaxValue = model.Items.Count - 1;
            picker.MinValue = 0;
            picker.SetDisplayedValues(model.Items.ToArray());
            picker.WrapSelectorWheel      = false;
            picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
            picker.Value = model.SelectedIndex;
        }
        var layout = new LinearLayout(Context)
        {
            Orientation = Orientation.Vertical
        };

        layout.AddView(picker);
        ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);
        var builder = new AlertDialog.Builder(Context);

        builder.SetView(layout);
        builder.SetTitle(model.Title ?? "");

        //change the text or color here
        builder.SetNegativeButton(Html.FromHtml("<font color='#039BE5'>Cancel</font>"), (s, a) =>
        {
            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            // It is possible for the Content of the Page to be changed when Focus is changed.
            // In this case, we'll lose our Control.
            Control?.ClearFocus();
            _dialog = null;
        });
        //change the text or color here
        builder.SetPositiveButton(Html.FromHtml("<font color='#039BE5'>OK</font>"), (s, a) =>
        {
            ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
            // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
            // In this case, the Element & Control will no longer exist.
            if (Element != null)
            {
                if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                {
                    Control.Text = model.Items[Element.SelectedIndex];
                }
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                // It is also possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
            }
            _dialog = null;
        });
        _dialog = builder.Create();
        _dialog.DismissEvent += (ssender, args) =>
        {
            ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
        };
        _dialog.Show();
    }