Exemplo n.º 1
0
        // These functions can be implemented the same on all screens,
        // so they are not virtual.

        /// <summary>
        /// Ask the user a yes/no question and capture the answer.
        /// </summary>
        /// <param name="question">Message to display to the user</param>
        /// <returns>
        /// True if the user selected Yes, and false if the user selected No.
        /// </returns>
        public virtual bool RaiseYesNoDialog(string question)
        {
            ConsoleMessageDialog d = new ConsoleMessageDialog(
                string.Join("", messagePieces) + question,
                new List <string>()
            {
                "Yes", "No"
            }
                );

            d.AddBinding(Keys.Y, (object sender, ConsoleTheme theme) => {
                d.PressButton(0);
                return(false);
            });
            d.AddBinding(Keys.N, (object sender, ConsoleTheme theme) => {
                d.PressButton(1);
                return(false);
            });
            messagePieces.Clear();
            bool val = d.Run(userTheme) == 0;

            DrawBackground(userTheme);
            Draw(userTheme);
            return(val);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Show a message and let the user choose one of several options
        /// This is only used by the Cmdline client.
        /// The Core algorithms don't call it.
        /// </summary>
        /// <param name="message">Text to show to the user</param>
        /// <param name="args">Array of options for user to choose</param>
        /// <returns>
        /// Index of option chosen by user
        /// </returns>
        public int RaiseSelectionDialog(string message, params object[] args)
        {
            ConsoleMessageDialog d = new ConsoleMessageDialog(
                string.Join("", messagePieces) + message,
                new List <string>(Array.ConvertAll <object, string>(args, p => p.ToString()))
                );

            messagePieces.Clear();
            int val = d.Run(userTheme);

            DrawBackground(userTheme);
            Draw(userTheme);
            return(val);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add an error message to the screen.
        /// It is assumed that the application WILL prompt the user for confirmation.
        /// </summary>
        /// <param name="message">Format string for the message</param>
        /// <param name="args">Values to be interpolated into the format string</param>
        public void RaiseError(string message, params object[] args)
        {
            ConsoleMessageDialog d = new ConsoleMessageDialog(
                string.Join("", messagePieces) + string.Format(message, args),
                new List <string>()
            {
                "OK"
            }
                );

            messagePieces.Clear();
            d.Run(userTheme);
            DrawBackground(userTheme);
            Draw(userTheme);
        }