Inheritance: ControlsConsole
示例#1
0
        public static void Prompt(ColoredString message, string yesPrompt, string noPrompt, Action<bool> resultCallback)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window._cellData.Print(2, 2, message);

            Button yesButton = new Button(yesPrompt.Length + 2, 1);
            Button noButton = new Button(noPrompt.Length + 2, 1);

            yesButton.Position = new Microsoft.Xna.Framework.Point(2, window._cellData.Height - 2);
            noButton.Position = new Microsoft.Xna.Framework.Point(window._cellData.Width - noButton.Width - 2, window._cellData.Height - 2);

            yesButton.Text = yesPrompt;
            noButton.Text = noPrompt;

            yesButton.ButtonClicked += (o, e) => { window.DialogResult = true; window.Hide(); };
            noButton.ButtonClicked += (o, e) => { window.DialogResult = false; window.Hide(); };

            window.Add(yesButton);
            window.Add(noButton);

            window.Closed += (o, e) =>
                {
                    resultCallback(window.DialogResult);
                };

            window.Show(true);
            window.Center();
        }
示例#2
0
        private void CreateWindow()
        {
            _window = new SadConsole.Consoles.Window(30, 10);
            _window.Title = " Popup Window 1 ";

            var closeButton = new SadConsole.Controls.Button(7, 1);
            closeButton.Text = "Close";
            closeButton.Position = new Point(_window.CellData.Width - 2 - closeButton.Width, _window.CellData.Height - 2);
            closeButton.ButtonClicked += (sender, e) => { _window.Hide(); };

            _window.Add(closeButton);
            _window.Center();
        }
示例#3
0
        public static void Message(ColoredString message, string closeButtonText)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window._cellData.Print(2, 2, message);

            Button closeButton = new Button(closeButtonText.Length + 2, 1);

            closeButton.Position = new Microsoft.Xna.Framework.Point(2, window._cellData.Height - 2);

            closeButton.Text = closeButtonText;

            closeButton.ButtonClicked += (o, e) => { window.DialogResult = true; window.Hide(); };

            window.Add(closeButton);

            window.Show(true);
            window.Center();
        }
示例#4
0
        /// <summary>
        /// Displays a dialog to the user with a specific message.
        /// </summary>
        /// <param name="message">The message. (background color is ignored)</param>
        /// <param name="closeButtonText">The text of the dialog's close button.</param>
        /// <param name="closedCallback">A callback indicating the message was dismissed.</param>
        public static void Message(ColoredString message, string closeButtonText, Action closedCallback = null)
        {
            Window window = new Window(message.ToString().Length + 4, 6);

            message.IgnoreBackground = true;

            window.Print(2, 2, message);

            Button closeButton = new Button(closeButtonText.Length + 2);

            closeButton.Position = new Point(2, window.textSurface.Height - 2);

            closeButton.Text = closeButtonText;

            closeButton.Click += (o, e) => { window.DialogResult = true; window.Hide(); closedCallback?.Invoke(); };

            window.Add(closeButton);

            window.Show(true);
            window.Center();
        }