-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
45 lines (39 loc) · 1.05 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Windows;
using AIMLbot.Utils;
using System.Windows.Input;
namespace AIMLbot.UI
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
readonly ChatBot _chatBot = new ChatBot();
public MainWindow()
{
InitializeComponent();
var loader = new AIMLLoader();
const string path = @"Human.aiml";
loader.LoadAIML(path);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var text = TextBox.Text;
if (String.IsNullOrWhiteSpace(text))
{
return;
}
var output = _chatBot.Chat(text, "1");
TextBlock.Text = output.Output;
}
private void TextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
e.Handled = true;
Button_Click(sender, e);
}
}
}
}