/// <summary> /// Removes the text of the textbox on enter if the textbox has it's deafult text /// </summary> /// <param name="textBox">The textbox</param> private void DefaultTextBox_Enter(TextboxBorderColor textBox) { if (textBox.Text == textBox.DefaultText) { textBox.Text = ""; } }
/// <summary> /// Set the back color of the textbox depending of the verification /// </summary> /// <param name="textBox">The textbox</param> /// <param name="verificationOk">The verification paramter</param> private void DefaultTextBox_Leave(TextboxBorderColor textBox, bool verificationOk) { if (verificationOk) { ChangeBackColorTextBox(textBox, true); } else if (textBox.Text == "") { textBox.Text = textBox.defaultText; ChangeBackColorTextBox(textBox, false); } else { ChangeBackColorTextBox(textBox, false); } }
/// <summary> /// Changes the color of a textbox depending on it's verify status /// </summary> /// <param name="textBox">the text box</param> /// <param name="verify">The verify status </param> private void ChangeBackColorTextBox(TextboxBorderColor textBox, bool verify) { if (textBox.Text == textBox.defaultText) { textBox.BackColor = _neutralColor; textBox.ForeColor = Color.DarkGray; } else if (verify) { textBox.BackColor = _correctColor; textBox.ForeColor = _whitetextColor; } else { textBox.BackColor = _wrongColor; textBox.ForeColor = Color.Black; } }
private void ChangeBorderColorTextbox(TextboxBorderColor textbox, Label status, bool verify) { if (textbox.Text.Length == 0) { textbox.BorderColor = Color.Blue; status.Text = ""; } else if (verify) { status.Text = ""; textbox.BorderColor = Color.LawnGreen; } else { status.Text = "Invalid"; status.ForeColor = Color.Crimson; textbox.BorderColor = Color.Crimson; } }
/// <summary> /// Sets the correct backgroundcolor depending on the text. /// </summary> /// <param name="textBox">The TextBox to check</param> /// <param name="verify">A bool indicating if the TextBox is verified</param> private void ChangeBackColorTextBox(TextboxBorderColor textBox, bool verify) { if (textBox.Text == textBox.defaultText) { textBox.BackColor = ColorScheme.MainNeutralColor; textBox.ForeColor = Color.DarkGray; } if (verify && textBox.Text != textBox.defaultText) { textBox.BackColor = ColorScheme.MainThemeColorLight; textBox.ForeColor = ColorScheme.MainPanelColor; } else if (textBox.Text != textBox.defaultText && textBox.Text != textBox.defaultText) { textBox.BackColor = ColorScheme.MainWarningColor; textBox.ForeColor = Color.Black; } }