Пример #1
0
 public static string PromptUser(string title, string instructions)
 {
     TextInputDialog textInputWindow = new TextInputDialog();
     textInputWindow.Title = title;
     textInputWindow.instructionsLabel.Content = instructions;
     textInputWindow.ShowDialog();
     return textInputWindow.inputBox.Text;
 }
Пример #2
0
        public static string PromptUser(string title, string instructions)
        {
            TextInputDialog textInputWindow = new TextInputDialog();

            textInputWindow.Title = title;
            textInputWindow.instructionsLabel.Content = instructions;
            textInputWindow.ShowDialog();
            return(textInputWindow.inputBox.Text);
        }
Пример #3
0
        //when the main window loads, prompt the user for connection info
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool successfulConnection;

            do
            {
                //prompts
                string address    = TextInputDialog.PromptUser("Server Address", "Input a MUD server address:");
                string portString = TextInputDialog.PromptUser("Server Port", "Enter the server's port number:");

                //convert port to int, default to port=23 in the event of any parsing issue
                int port;
                if (!int.TryParse(portString, out port))
                {
                    port = 23;
                }

                //attempt a connection
                successfulConnection = true;
                try
                {
                    //tell the user what we're doing first
                    this.appendText("Attempting a connection to " + address + ", port " + port.ToString() + "...");

                    //then give it a shot
                    this.serverConnection = new MUDServerConnection(address, port);
                }

                //if there's any problem, start over with prompts again
                catch (Exception)
                {
                    this.appendText("Connection failed.  Please verify your internet connectivity and server information, then try again.");
                    successfulConnection = false;
                }
            }while (!successfulConnection);

            //now that we've connected, start listening for messages and disconnections
            this.serverConnection.serverMessage += new MUDServerConnection.serverMessageEventHandler(serverConnection_serverMessage);
            this.serverConnection.disconnected  += new MUDServerConnection.disconnectionEventHandler(serverConnection_disconnected);
            this.serverConnection.telnetMessage += new MUDServerConnection.serverTelnetEventHandler(serverConnection_telnetMessage);
        }