// sends text the user typed to client private void TxtInput_KeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Return && TxtInput.IsEnabled == true) { var keys = writers.Keys;//all threads foreach (var key in keys) { writers[key].Write("SERVER>>> " + TxtInput.Text); //writes to all threads } TxtDisplay.Text += "\r\nSERVER>>> " + TxtInput.Text; //displays it to the Display if (TxtInput.Text == "TERMINATE") //ako user-a na servara signalizira prekrarqvane na wryzkata na syrwywa s klienta { foreach (var key in keys) { connections[key]?.Close(); } } TxtInput.Clear(); } } catch (SocketException) { TxtDisplay.Text += "\nError writing object"; } }
private void BtnDone_Click(object sender, EventArgs e) { try { input = Convert.ToInt16(TxtInput.Text); for (int i = 0; i < output.Length; i++) { if (input == i + 1) { output[i, 1] += 1; } } TxtInput.Clear(); } catch (FormatException) { MessageBox.Show("Rating must be a number 1 - 10", "Hold up...", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (IndexOutOfRangeException) { MessageBox.Show("Rating must be a number 1 - 10", "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { TxtInput.Clear(); } }
// Submit button //For the user to input what they think is correct private void BtnInput_Click(object sender, EventArgs e) { // for the user to guess string UserGuess; // to compare user input to word UserGuess = TxtInput.Text.ToString(); bool value = cb.CompareWord(UserGuess); // The counter for each round if gussed correctly if (value == true) { // Display message box for right anwser MessageBox.Show("You are correct!!", "Correct", MessageBoxButtons.OK); { // What radio button is click for each word list: This is Easy if (RbtEasy.Checked) { LblWord.Text = cb.ScrambleEasy(); TxtInput.Clear(); TxtInput.Focus(); } //What radio button is click for each word list: This is Medium if (RbtMedium.Checked) { LblWord.Text = cb.ScrambleMedium(); TxtInput.Clear(); TxtInput.Focus(); } //What radio button is click for each word list: This is Hard if (RbtHard.Checked) { LblWord.Text = cb.ScrambleHard(); TxtInput.Clear(); TxtInput.Focus(); } } counter++; } // If the user is incorrect else { // Message box for incorrect MessageBox.Show("Wrong, try again!", "Incorrect", MessageBoxButtons.OK); } // Once counter has reached 5 if (counter == 5) { // Hide currect window Hide(); // Move to winner form Winner f3 = new Winner(); f3.ShowDialog(); Close(); } }
private void BtnOK_Click(object sender, EventArgs e) { if (IsValidData()) { decimal salesTax = Convert.ToDecimal(TxtInput.Text); Tag = salesTax; } else { TxtInput.Clear(); TxtInput.Focus(); } }
private void TxtInput_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && TxtInput.TextLength > 0) { if (LstData.Items.Contains(TxtInput.Text)) { MessageBox.Show("Frucht existiert schon!"); return; } LstData.Items.Add(TxtInput.Text); TxtInput.Clear(); } }
private void BtnF2C_Click(object sender, EventArgs e) { try { double f = Convert.ToDouble(TxtInput.Text); double c = (f - 32) * 5 / 9; TxtAns.Text = c.ToString("f2") + "度"; } catch { TxtAns.Text = "度數請數入數值!"; TxtInput.Clear(); } TxtInput.Focus(); }
public Form1() { InitializeComponent(); //Δήλωση του χειριστή συμβάντος (handler) για τη χρήση του "Enter" στο TxtInput RichTextBox this.TxtInput.KeyDown += new KeyEventHandler(TxtInput_KeyDown); TxtInput.Clear(); TxtInput.Focus(); VerseLine = null; ScansionLine = null; TotalLines = 0; ErrorLines = 0; Metrics = new metrics(); }
private void CmdVerse_Click(object sender, EventArgs e) { ErrorLines = 0; VerseLine = TxtInput.Text; Metrics.DoScansion(ref VerseLine, ref ScansionLine, ref ErrorLines); if (ErrorLines != 0) { ScansionLine = "Λάθος ανάλυση..."; } LblResult.Text = VerseLine + "\n" + ScansionLine; LblResult.SelectAll(); LblResult.SelectionColor = Color.Black; TxtInput.Clear(); CmdClear.Focus(); }
private void BtnLoadSelectedFiles_Click(object sender, EventArgs e) { TxtInput.Clear(); List <string> FilesToLoad = new List <string>(); foreach (var file in LstFiles.SelectedItems) { FilesToLoad.Add(file.ToString()); } TxtInput.Text = Functions.LoadFiles(FilesToLoad); TxtOutput.Clear(); TxtCount.Clear(); Tuple <Dictionary <char, uint>, Dictionary <char, uint> > tp = Functions.MakeOldCodeDict(TxtInput.Text.ToCharArray()); DictOldCode = tp.Item1; DictCountDup = tp.Item2; ShowLastDict(DictOldCode); }
private void BtnSend_Click(object sender, RoutedEventArgs e) { try { if (_clientSocket.Connected) { Stream s = _clientSocket.GetStream(); byte[] buffer = Encoding.ASCII.GetBytes(TxtInput.Text); s.Write(buffer, 0, buffer.Length); s.Flush(); TxtInput.Clear(); } else { MessageBox.Show("Connected."); } } catch (SocketException se) { MessageBox.Show("Message not sent: " + se); } }
private void CmdClear_Click(object sender, EventArgs e) { LblResult.Clear(); TxtInput.Clear(); TxtInput.Focus(); }