Beispiel #1
0
    protected void OnSaveButtonPressed()
    {
        DialogBuilder builder = m_dialogBuilderFactory.Create();

        // if save is successful
        if (m_state.OnSave(m_inputNameField.text))
        {
            builder.SetTitle("Save successful!")
            .SetMessage("Would you like to keep editing this track or start a new one?\n" +
                        "Or you can race it immediately!")
            .SetIcon(DialogBuilder.Icon.STAR)
            .AddButton("Keep Editing", m_state.OnCancel)
            .AddButton("New Track", m_state.OnNewTrack)
            .AddButton("Race!", m_state.OnDone);
        }
        else
        {
            builder.SetTitle("Save unsuccessful!")
            .SetMessage("Please check the storage of your device or contact the developer.")
            .SetIcon(DialogBuilder.Icon.WARNING)
            .AddButton("Back")
            .AddButton("Try Again", () => m_state.OnSave(m_inputNameField.text));
        }

        builder.Build();
    }
Beispiel #2
0
            void OnActionSheetRequested(Page sender, ActionSheetArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                var builder = new DialogBuilder(Activity);

                builder.SetTitle(arguments.Title);
                string[] items = arguments.Buttons.ToArray();
                builder.SetItems(items, (o, args) => arguments.Result.TrySetResult(items[args.Which]));

                if (arguments.Cancel != null)
                {
                    builder.SetPositiveButton(arguments.Cancel, (o, args) => arguments.Result.TrySetResult(arguments.Cancel));
                }

                if (arguments.Destruction != null)
                {
                    builder.SetNegativeButton(arguments.Destruction, (o, args) => arguments.Result.TrySetResult(arguments.Destruction));
                }

                var dialog = builder.Create();

                builder.Dispose();
                //to match current functionality of renderer we set cancelable on outside
                //and return null
                dialog.SetCanceledOnTouchOutside(true);
                dialog.SetCancelEvent((o, e) => arguments.SetResult(null));
                dialog.Show();
            }
Beispiel #3
0
 /// <summary>
 /// Takes an exception and creates a generic dialog builder ready
 /// to build to display the exception.
 /// </summary>
 public static DialogBuilder MakeGenericExceptionDialog(this DialogBuilder value, Exception _exception)
 {
     return(value.SetTitle("Error!")
            .SetIcon(DialogBuilder.Icon.ERROR)
            .SetMessage(_exception.Message)
            .AddButton("OK", () => Debug.LogError(_exception)));
 }
Beispiel #4
0
            void OnActionSheetRequested(Page sender, ActionSheetArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                var builder = new DialogBuilder(Activity);

                builder.SetTitle(arguments.Title);
                string[] items = arguments.Buttons.ToArray();
                builder.SetItems(items, (o, args) => arguments.Result.TrySetResult(items[args.Which]));

                if (arguments.Cancel != null)
                {
                    builder.SetPositiveButton(arguments.Cancel, (o, args) => arguments.Result.TrySetResult(arguments.Cancel));
                }

                if (arguments.Destruction != null)
                {
                    builder.SetNegativeButton(arguments.Destruction, (o, args) => arguments.Result.TrySetResult(arguments.Destruction));
                }

                var dialog = builder.Create();

                builder.Dispose();
                //to match current functionality of renderer we set cancelable on outside
                //and return null
                if (arguments.FlowDirection == FlowDirection.MatchParent && sender is IVisualElementController ve)
                {
                    dialog.Window.DecorView.UpdateFlowDirection(ve);
                }
                else if (arguments.FlowDirection == FlowDirection.LeftToRight)
                {
                    dialog.Window.DecorView.LayoutDirection = LayoutDirection.Ltr;
                }
                else if (arguments.FlowDirection == FlowDirection.RightToLeft)
                {
                    dialog.Window.DecorView.LayoutDirection = LayoutDirection.Rtl;
                }

                dialog.SetCanceledOnTouchOutside(true);
                dialog.SetCancelEvent((o, e) => arguments.SetResult(null));
                dialog.Show();

                dialog.GetListView().TextDirection = GetTextDirection(sender, arguments.FlowDirection);
                LayoutDirection layoutDirection    = GetLayoutDirection(sender, arguments.FlowDirection);

                if (arguments.Cancel != null)
                {
                    ((dialog.GetButton((int)DialogButtonType.Positive).Parent) as global::Android.Views.View).LayoutDirection = layoutDirection;
                }
                if (arguments.Destruction != null)
                {
                    ((dialog.GetButton((int)DialogButtonType.Negative).Parent) as global::Android.Views.View).LayoutDirection = layoutDirection;
                }
            }
Beispiel #5
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();
            }
Beispiel #6
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);
                }
            }
    public void CreateDialog()
    {
        DialogBuilder builder = m_builderFactory.Create();

        builder.SetTitle(Title)
        .SetMessage(Message)
        .SetIcon(Icon);

        for (int i = 0; i < Buttons.Length; ++i)
        {
            builder.AddButton(Buttons [i].ButtonText, DummyCallback);
        }

        builder.Build();
    }
Beispiel #8
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();
            }
Beispiel #9
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();
        });
    }