private void MessageField_KeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Enter) { switch (TB_MessageField.Text) { case "exit": ServerModule.Stop(); break; case "disc": ServerModule.Send(new ToServerCommand() { Action = ServerCommands.Send, ReceiveBuffer = MainWindow.AssemblyRawPack(LowCommands.Disconnect) }); break; case "ver": ServerModule.Send(new ToServerCommand() { Action = ServerCommands.Send, ReceiveBuffer = MainWindow.AssemblyRawPack(LowCommands.Version) }); break; case "mode": ServerModule.Send(new ToServerCommand() { Action = ServerCommands.Send, ReceiveBuffer = MainWindow.AssemblyRawPack(LowCommands.RunType) }); break; case "buf": SendBuf(); break; case "cls": TB_Messages.Clear(); break; default: ServerModule.Send(new ToServerCommand() { Action = ServerCommands.Send, ReceiveBuffer = MainWindow.AssemblyRawPack(LowCommands.Data, Encoding.UTF8.GetBytes(TB_MessageField.Text)) }); break; } } } catch { } }
private void MessageField_KeyDown(object sender, KeyEventArgs e) { try { if ((e.Key == Key.Enter && (Keyboard.Modifiers & ModifierKeys.Control) > 0) || e.Key == Key.Enter) { int result = 0; if (int.TryParse(TB_MessageField.Text, out result) && result > 0) { ClientModule.SendCommand(new ToClientCommand() { Command = ClientCommands.Send, ReceiveBuffer = BitConverter.GetBytes(result) }); } else { switch (TB_MessageField.Text) { case "disc": ClientModule.SendCommand(new ToClientCommand() { Command = ClientCommands.Disconnect }); break; case "cls": TB_Messages.Clear(); break; default: ClientModule.SendCommand(new ToClientCommand() { Command = ClientCommands.Send, ReceiveBuffer = Encoding.UTF8.GetBytes(TB_MessageField.Text) }); TB_MessageField.IsEnabled = false; break; } } } } catch { } }