Esempio n. 1
0
            void OnAlertRequested(IView sender, AlertArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                int messageID = 16908299;
                var alert     = new DialogBuilder(Activity).Create();

                if (alert == null)
                {
                    return;
                }

                if (alert.Window != null)
                {
                    if (arguments.FlowDirection == FlowDirection.MatchParent && sender is IView view)
                    {
                        alert.Window.DecorView.UpdateFlowDirection(view);
                    }
                    else if (arguments.FlowDirection == FlowDirection.LeftToRight)
                    {
                        alert.Window.DecorView.LayoutDirection = LayoutDirection.Ltr;
                    }
                    else if (arguments.FlowDirection == FlowDirection.RightToLeft)
                    {
                        alert.Window.DecorView.LayoutDirection = LayoutDirection.Rtl;
                    }
                }

                alert.SetTitle(arguments.Title);
                alert.SetMessage(arguments.Message);
                if (arguments.Accept != null)
                {
                    alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true));
                }
                alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false));
                alert.SetCancelEvent((o, args) => { arguments.SetResult(false); });
                alert.Show();

                TextView textView = (TextView)alert.findViewByID(messageID);

                textView.TextDirection = GetTextDirection(sender, arguments.FlowDirection);


                if (alert.GetButton((int)DialogButtonType.Negative).Parent is AView parentView)
                {
                    parentView.LayoutDirection = GetLayoutDirection(sender, arguments.FlowDirection);
                }
            }
Esempio n. 2
0
            void OnPromptRequested(IView sender, PromptArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                var alertDialog = new DialogBuilder(Activity).Create();

                if (alertDialog == null)
                {
                    return;
                }

                alertDialog.SetTitle(arguments.Title);
                alertDialog.SetMessage(arguments.Message);

                var frameLayout = new FrameLayout(Activity);
                var editText    = new EditText(Activity)
                {
                    Hint = arguments.Placeholder, Text = arguments.InitialValue
                };
                var layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
                {
                    LeftMargin  = (int)(22 * Activity.Resources.DisplayMetrics.Density),
                    RightMargin = (int)(22 * Activity.Resources.DisplayMetrics.Density)
                };

                editText.LayoutParameters = layoutParams;
                editText.InputType        = arguments.Keyboard.ToInputType();
                if (arguments.Keyboard == Keyboard.Numeric)
                {
                    editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType);
                }

                if (arguments.MaxLength > -1)
                {
                    editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(arguments.MaxLength) });
                }

                frameLayout.AddView(editText);
                alertDialog.SetView(frameLayout);

                alertDialog.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(editText.Text));
                alertDialog.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(null));
                alertDialog.SetCancelEvent((o, args) => { arguments.SetResult(null); });

                alertDialog.Window.SetSoftInputMode(SoftInput.StateVisible);
                alertDialog.Show();
                editText.RequestFocus();
            }
Esempio n. 3
0
            void OnAlertRequested(Page sender, AlertArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                var alert = new DialogBuilder(Activity).Create();

                alert.SetTitle(arguments.Title);
                alert.SetMessage(arguments.Message);
                if (arguments.Accept != null)
                {
                    alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true));
                }
                alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false));
                alert.SetCancelEvent((o, args) => { arguments.SetResult(false); });
                alert.Show();
            }
Esempio n. 4
0
    public static void Confirm(String message, Action onConfirm = null, Action onCancel = null)
    {
        if (onConfirm == null)
        {
            onConfirm = delegate
            {
                ViewController.SwitchView(ViewIndex.WORLDMAP_WORLD_MAP);
            };
        }

        ViewController.SwitchView(delegate
        {
            DialogBuilder builder = new DialogBuilder();
            builder.SetTitle("###<color=yellow>超級機</color>###");
            builder.AddSubView(MenuIcon.Create(MenuIcon.IconType.LUCKYDRAW_DISNEY, null).gameObject);
            builder.SetMessage(message);
            builder.AddButton(Locale.t("LABEL_OK"), onConfirm);

            if (onCancel != null)
                builder.AddButton(Locale.t("LABEL_CANCEL"), onCancel);

            builder.Show();
        });
    }