Click here to Skip to main content
15,889,877 members
Home / Discussions / C#
   

C#

 
Questioncreating a pause? Pin
stephen.darling24-Sep-10 2:52
stephen.darling24-Sep-10 2:52 
AnswerRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:04
professionalManfred Rudolf Bihy24-Sep-10 3:04 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:12
stephen.darling24-Sep-10 3:12 
GeneralRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:25
professionalManfred Rudolf Bihy24-Sep-10 3:25 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:38
stephen.darling24-Sep-10 3:38 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:42
stephen.darling24-Sep-10 3:42 
GeneralRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:48
professionalManfred Rudolf Bihy24-Sep-10 3:48 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 4:13
stephen.darling24-Sep-10 4:13 
OK, here you go, but please bare in mind I am a learner.

Also, It sort of works now, but the text that is output last is added onto the new text, so I am going wrong somewhere.

This part is elisa (name of the AI reponder)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace AI
{
    class elisa
    {
        private string input;
        private string output;
        private int NumberOfReplies = 0;

        

        public string respond(string input)
        {
            output = ("");
            

                this.input = input;

                if (NumberOfReplies >= 1)
                {
                    output = ("Please wait!");

                }

                else
           
            output = ("Sorry am a bit buzy at the min. ");
            NumberOfReplies += 1;

            Thread.Sleep(4000);
                return output;
                

        }
        

    }
}



And this is from my form, it has a text box to enter what you want to say, and an edit box that then shows that text, and shows the responce from elisa...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace AI
{
    public partial class Form1 : Form
    {
        elisa _elisa = new elisa();
        string userInput;
        string elisaResponce;
        string you = ("You: ");
        string elisa = ("Elisa: ");


        public Form1()
        {
            InitializeComponent();

            status.Text = ("");

        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            

            updateInput(textBoxInput.Text);
            textBoxInput.Clear();

            status.Text = ("Elisa is typing a message");
             getResponceFromElisa();
             
            
        }

        private void updateInput(string input)
        {

            richTextBoxOutput.Text += you += input + ("\n");
           
        }

        private void getResponceFromElisa()
        {

            
            timer1.Start();
            

            

        }

        private void textBoxInput_TextChanged(object sender, EventArgs e)
        {
            if (textBoxInput.Text == (""))
            {
                status.Text = ("");

            }

            else
            status.Text = ("You are typing a message...");

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
            elisaResponce = _elisa.respond(userInput);
            richTextBoxOutput.Text += elisa += elisaResponce;
            timer1.Stop();
            status.Text = ("");
        }

    }
}


Thank you for asking to have a look, I appreciate it Smile | :)

Steve
GeneralRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 4:30
professionalManfred Rudolf Bihy24-Sep-10 4:30 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 4:36
stephen.darling24-Sep-10 4:36 
GeneralRe: creating a pause? Pin
Saksida Bojan24-Sep-10 6:11
Saksida Bojan24-Sep-10 6:11 
AnswerRe: creating a pause? Pin
Luc Pattyn24-Sep-10 4:06
sitebuilderLuc Pattyn24-Sep-10 4:06 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 18:41
stephen.darling24-Sep-10 18:41 
GeneralRe: creating a pause? Pin
Luc Pattyn24-Sep-10 22:52
sitebuilderLuc Pattyn24-Sep-10 22:52 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 23:16
stephen.darling24-Sep-10 23:16 
AnswerRe: creating a pause? Pin
Ravi Bhavnani24-Sep-10 7:11
professionalRavi Bhavnani24-Sep-10 7:11 
GeneralRe: creating a pause? Pin
Jim Crafton24-Sep-10 9:24
Jim Crafton24-Sep-10 9:24 
GeneralRe: creating a pause? Pin
Ravi Bhavnani24-Sep-10 9:27
professionalRavi Bhavnani24-Sep-10 9:27 
GeneralRe: creating a pause? Pin
Ravi Bhavnani24-Sep-10 9:29
professionalRavi Bhavnani24-Sep-10 9:29 
GeneralRe: creating a pause? Pin
Jim Crafton24-Sep-10 9:33
Jim Crafton24-Sep-10 9:33 
GeneralRe: creating a pause? Pin
Ravi Bhavnani24-Sep-10 9:34
professionalRavi Bhavnani24-Sep-10 9:34 
GeneralRe: creating a pause? Pin
AspDotNetDev24-Sep-10 10:10
protectorAspDotNetDev24-Sep-10 10:10 
GeneralRe: creating a pause? Pin
Ravi Bhavnani24-Sep-10 10:12
professionalRavi Bhavnani24-Sep-10 10:12 
GeneralRe: creating a pause? Pin
AspDotNetDev24-Sep-10 10:35
protectorAspDotNetDev24-Sep-10 10:35 
QuestionText Pin
SatyaKeerthi1524-Sep-10 2:37
SatyaKeerthi1524-Sep-10 2:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.