private void textBox_ChatlogInput_PreviewKeyDown(object sender, KeyEventArgs e)
{
var input = (TextBox)sender;
if (e.Key == Key.Enter)
{
FFACEInstance.Instance.Windower.SendString(input.Text);
ChatInputBuffer.AddLine(input.Text);
}
if (e.Key == Key.Escape||e.Key == Key.Enter)
{
input.Clear();
e.Handled = true;
}
if (e.Key == Key.Up)
input.Text = ChatInputBuffer.Up(input.Text);
if (e.Key == Key.Down)
input.Text = ChatInputBuffer.Down();
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control || (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
{
Regex findname;
int fields;
string name = "";
if (input.Text.Length >= 2 && input.Text.Substring(0, 2).ToLower() == "/t")
{
findname = new Regex(@"/\S* (\S*)\s?(.*)");
fields = 2;
}
else
{
findname = new Regex(@"/.*? (.*)");
fields = 1;
}
string text = input.Text.Trim();
if (findname.IsMatch(input.Text))
{
text = findname.Matches(input.Text)[0].Groups[fields].Value.Trim();
if (fields > 1)
name = findname.Matches(input.Text)[0].Groups[1].Value.Trim();
}
if (e.Key == Key.R)
input.Text = "/t " + Chatlog.Instance.LastTell(name) + " " + text;
else if (e.Key == Key.T)
input.Text = "/t " + text;
else if (e.Key == Key.P)
input.Text = "/p " + text;
else if (e.Key == Key.L)
input.Text = "/l " + text;
else if (e.Key == Key.S)
input.Text = "/s " + text;
input.CaretIndex = input.Text.Length;
}
}