Пример #1
0
        void CreateDialog()
        {
            if (_TextPickerCell.Items == null || _TextPickerCell.Items.Count == 0)
            {
                return;
            }

            var displayValues = _TextPickerCell.Items.Cast <object>().Select(x => x.ToString()).ToArray();

            _picker = new APicker(_context);
            _picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
            _picker.MinValue = 0;
            _picker.MaxValue = _TextPickerCell.Items.Count - 1;
            _picker.SetDisplayedValues(displayValues);
            _picker.Value             = Math.Max(_TextPickerCell.Items.IndexOf(_TextPickerCell.SelectedItem), 0);
            _picker.WrapSelectorWheel = _TextPickerCell.IsCircularPicker;

            if (_dialog == null)
            {
                using (var builder = new AlertDialog.Builder(_context)) {
                    builder.SetTitle(_title);

                    Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context);
                    parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams(
                                       ViewGroup.LayoutParams.WrapContent,
                                       ViewGroup.LayoutParams.WrapContent,
                                       GravityFlags.Center));
                    builder.SetView(parent);


                    builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => {
                        ClearFocus();
                    });
                    builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => {
                        _TextPickerCell.SelectedItem = _TextPickerCell.Items[_picker.Value];
                        _command?.Execute(_TextPickerCell.Items[_picker.Value]);
                        ClearFocus();
                    });

                    _dialog = builder.Create();
                }
                _dialog.SetCanceledOnTouchOutside(true);
                _dialog.DismissEvent += (ss, ee) => {
                    _dialog.Dispose();
                    _dialog = null;
                    _picker.RemoveFromParent();
                    _picker.Dispose();
                    _picker = null;
                };

                _dialog.Show();
            }
        }
Пример #2
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <returns>The dispose.</returns>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _picker?.Dispose();
         _picker = null;
         _dialog?.Dispose();
         _dialog  = null;
         _context = null;
         _command = null;
     }
     base.Dispose(disposing);
 }
Пример #3
0
 void DestroyDialog()
 {
     if (_dialog != null)
     {
         // Set _dialog to null to avoid racing attempts to destroy dialog - e.g. in response to dismiss event
         var dialog = _dialog;
         _dialog = null;
         _picker.RemoveFromParent();
         _picker.Dispose();
         _picker = null;
         // Dialog.Dispose() does not close an open dialog view so explicitly dismiss it before disposing
         dialog.Dismiss();
         dialog.Dispose();
     }
 }
Пример #4
0
        void CreateDialog()
        {
            _picker          = new APicker(_context);
            _picker.MinValue = _min;
            _picker.MaxValue = _max;
            _picker.Value    = _NumberPikcerCell.Number;

            if (_dialog == null)
            {
                using (var builder = new AlertDialog.Builder(_context)) {
                    builder.SetTitle(_title);

                    Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context);
                    parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams(
                                       ViewGroup.LayoutParams.WrapContent,
                                       ViewGroup.LayoutParams.WrapContent,
                                       GravityFlags.Center));
                    builder.SetView(parent);


                    builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) =>
                    {
                        ClearFocus();
                    });
                    builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) =>
                    {
                        _NumberPikcerCell.Number = _picker.Value;
                        _command?.Execute(_picker.Value);
                        ClearFocus();
                    });

                    _dialog = builder.Create();
                }
                _dialog.SetCanceledOnTouchOutside(true);
                _dialog.DismissEvent += (ss, ee) =>
                {
                    _dialog.Dispose();
                    _dialog = null;
                    _picker.RemoveFromParent();
                    _picker.Dispose();
                    _picker = null;
                };

                _dialog.Show();
            }
        }
Пример #5
0
        void CreateDialog()
        {
            if (_dialog != null)
            {
                return;
            }

            var picker = new APicker(_view.Context);

            picker.MinValue = _min;
            picker.MaxValue = _max;
            picker.Value    = _number;

            using (var builder = new AlertDialog.Builder(_view.Context)) {
                builder.SetTitle(AddNumberPicker.GetTitle(Element));

                Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_view.Context);
                parent.AddView(picker, new Android.Widget.FrameLayout.LayoutParams(
                                   ViewGroup.LayoutParams.WrapContent,
                                   ViewGroup.LayoutParams.WrapContent,
                                   GravityFlags.Center));
                builder.SetView(parent);

                builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { });

                builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => {
                    AddNumberPicker.SetNumber(Element, picker.Value);
                    _command?.Execute(picker.Value);
                });

                _dialog = builder.Create();
            }

            _dialog.SetCanceledOnTouchOutside(true);

            _dialog.DismissEvent += (ss, ee) => {
                _dialog.Dispose();
                _dialog = null;
                picker.RemoveFromParent();
                picker.Dispose();
                picker = null;
            };

            _dialog.Show();
        }