Exemplo n.º 1
0
        private DialogBox(DialogBoxSettings dialogBoxSettings, MiyagiSystem system)
        {
            this.GUIManager     = system.GUIManager;
            this.SpriteRenderer = system.RenderManager.Create2DRenderer();
            system.LocaleManager.CurrentCultureChanged += this.LocaleManagerCultureChanged;

            if (dialogBoxSettings == null)
            {
                Size screenRes = system.RenderManager.MainViewport.Size;
                this.location         = new Point(screenRes.Width / 3, screenRes.Height / 4);
                this.labelTextOffset  = new Point(3, 5);
                this.buttonTextOffset = Point.Empty;
                this.size             = new Size(screenRes.Width / 3, screenRes.Height / 4);
                this.buttonSize       = new Size(this.size.Width / 5, this.size.Height / 8);
            }
            else
            {
                this.location         = dialogBoxSettings.Location;
                this.labelTextOffset  = dialogBoxSettings.LabelTextOffset;
                this.buttonTextOffset = dialogBoxSettings.ButtonTextOffset;
                this.size             = dialogBoxSettings.Size;
                this.buttonSize       = dialogBoxSettings.ButtonSize;
            }

            system.GUIManager.ReleaseFocusedAndGrabbedControl();

            // reset result
            this.dialogResult = DialogResult.None;

            // set this to the top of the ModalDialogs stack
            system.GUIManager.PushModalDialog(this);
            this.Visible = true;
        }
Exemplo n.º 2
0
        public static DialogResult Show(string text, string title, DialogBoxButtons buttons, DialogBoxSettings settings)
        {
            var dialogBox = new DialogBox(settings, MiyagiSystem.Latest);

            dialogBox.CreateControls(text, title, buttons);

            while (dialogBox.dialogResult == DialogResult.None)
            {
                if (dialogBox.MiyagiSystem == null || !dialogBox.MiyagiSystem.Backend.MessagePump())
                {
                    dialogBox.Close();
                    return(DialogResult.None);
                }
            }

            dialogBox.Close();
            return(dialogBox.dialogResult);
        }