Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ChatAI
- {
- public partial class Form1 : Form
- {
- int czaswyswietlajacy = 0;
- int przerzutnik = 0;
- string[] Table;
- public Form1()
- {
- InitializeComponent();
- }
- public void Form1_Load(object sender, EventArgs e)
- {
- }
- private void CheckKeys(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == (char)13)
- {
- //START "PISANIE"
- przerzutnik = 0;
- label2.Visible = true;
- czaswyswietlajacy = inputBox.Text.Length / 10;
- timer1.Start();
- //KONIEC "PISANIA"
- inputBox.Select(0, 0);
- putIntoHUMAN(inputBox.Text, Color.Green, true);
- }
- }
- private void inputBox_TextChanged(object sender, EventArgs e)
- {
- inputBox.Text = inputBox.Text.Replace(Environment.NewLine, "");
- }
- /// <podsumowanie>
- /// Funkcje putIntoHUMAN - dodajemy wpis jako czlowiek
- /// analogicznie dla putIntoAI - jako maszyna/robot/puszka/program itp. :D
- /// w checkkeys sprawdza czy zostal nacisniety enter, a nastepnie przesyla
- /// wraz z odpowiednimi argumentami polecenie funkcji putIntoHuman
- ///
- /// TODO:
- /// pobieranie z bazy danych
- /// gimbusiarskie, nastoletnie formatowanie (upodobnienie tekstu wyjsciowego do tekstu typowego nastolatka)
- /// GOTOWE moment pisania przez bota
- ///
- /// </podsumowanie>
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (timer1.Enabled == true)
- {
- if (czaswyswietlajacy > 0)
- {
- czaswyswietlajacy--;
- }
- else
- {
- label2.Visible = false;
- timer1.Stop();
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- label1.Text = ofd.FileName;
- listBox1.Items.Clear();
- List<string> lines = new List<string>();
- using (StreamReader r = new StreamReader(ofd.OpenFile()))
- {
- string line;
- while ((line = r.ReadLine()) != null)
- {
- listBox1.Items.Add(line);
- }
- }
- }
- }
- public void przeszukajBaze(string zdanie)
- {
- zdanie = zdanie.Replace(",", " ");
- zdanie = zdanie.Replace("?", " ");
- zdanie = zdanie.Replace("!", " ");
- zdanie = zdanie.Replace(";", " ");
- zdanie = zdanie.Replace("-", " ");
- zdanie = zdanie.Replace(".", " ");
- zdanie = zdanie.Replace("", " ");
- zdanie = zdanie.Replace(" ", " ");
- zdanie = zdanie.Replace(" ", " ");
- zdanie = zdanie.Replace(" ", " ");
- zdanie = zdanie.Replace(" ", " ");
- string[] Table = zdanie.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- listBox2.Items.Clear();
- listBox2.Items.AddRange(Table);
- bool wlaczone = true;
- for (int i = 0; i < listBox2.Items.Count && wlaczone == true; i++)
- {
- listBox2.SelectedIndex = i;
- zdanie = listBox2.SelectedItem.ToString().Trim();
- label7.Text = zdanie;
- if (zdanie != string.Empty)
- {
- int index = listBox1.FindString(zdanie);
- if (index != -1)
- {
- listBox1.SetSelected(index, true);
- wlaczone = false;
- string dopodzialu = listBox1.SelectedItem.ToString();
- string[] Table3 = listBox1.SelectedItem.ToString().Split(new string[] { "&&" }, StringSplitOptions.RemoveEmptyEntries);
- formater(Table3[1], Convert.ToInt16(Table3[2]), Convert.ToInt16(Table3[3]));
- }
- }
- }
- }
- public void putIntoHUMAN(string text, Color color, bool AddNewLine = false)
- {
- if (AddNewLine)
- {
- text += Environment.NewLine;
- }
- outputBox.SelectionStart = outputBox.TextLength;
- outputBox.SelectionLength = 0;
- label1.Text = text;
- outputBox.SelectionColor = color;
- outputBox.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] >> " + text);
- outputBox.SelectionColor = outputBox.ForeColor;
- inputBox.Clear();
- inputBox.Select(0, 0);
- przeszukajBaze(text);
- }
- public void putintoAI(string text, Color color, bool AddNewLine = false)
- {
- if (AddNewLine)
- {
- text += Environment.NewLine;
- }
- outputBox.SelectionStart = outputBox.TextLength;
- outputBox.SelectionLength = 0;
- outputBox.SelectionColor = color;
- outputBox.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] << " + text);
- outputBox.SelectionColor = outputBox.ForeColor;
- inputBox.Clear();
- inputBox.Select(0, 0);
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- public void formater(string tekstDoObrobki, int emocja, int licznik)
- {
- putintoAI(tekstDoObrobki, Color.Red,true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement