private void printRecievedStr(byte data) { string recv_str = ""; // 受信値の表示 if (radioButtonDEC.Checked == true) { int ch_value = (int)data; recv_str += ch_value.ToString() + " "; } else if (radioButtonHEX.Checked == true) { int ch_value = (int)data; recv_str += String.Format("{0:X}", ch_value) + " "; } else { recv_str = ((char)data).ToString(); } ReceiveTextBox.Text += recv_str; // 自動スクロール ReceiveTextBox.SelectionStart = ReceiveTextBox.Text.Length; ReceiveTextBox.Focus(); ReceiveTextBox.ScrollToCaret(); SendText.Focus(); }
private async void Send_Click(object sender, RoutedEventArgs e) { var text = SendText.Text; if (!string.IsNullOrEmpty(text)) { if (this.server == null || !this.server.IsListening) { Content.Text += $"Server Unstart\n\n"; } else { if (string.IsNullOrEmpty(lastClient)) { Content.Text += $"No Connected Client\n\n"; } else { await this.server.SendAsync(lastClient, text); SendText.Text = ""; Content.Text += $"Send:\n{text}\n\n"; } } } SendText.Focus(); }
private void BotClient_OnResponse(string message, MessageType type) { switch (type) { case MessageType.History: this.Dispatcher.BeginInvoke((Action)(() => { if (message.Contains(requestName)) { StartButton_Click(this, new RoutedEventArgs()); } HistoryText.AppendText(message + "\n"); SendText.Focus(); HistoryText.ScrollToEnd(); })); break; case MessageType.Metadata: this.Dispatcher.BeginInvoke((Action)(() => { MetaText.AppendText(message + "\n"); SendText.Focus(); MetaText.ScrollToEnd(); })); break; default: break; } }
private void SendText_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { SendBtn_Click(null, null); SendText.Focus(); } }
private async void Send_Click(object sender, RoutedEventArgs e) { var text = SendText.Text; if (!string.IsNullOrEmpty(text)) { if (this.client == null || !this.client.Connected) { Content.Text += $"Server Unconnect\n\n"; } else { await this.client.SendAsync(text); SendText.Text = ""; Content.Text += $"Send:\n{text}\n\n"; } } SendText.Focus(); }