private void checkBox_colours_CheckStateChanged(object sender, EventArgs e) { if (checkBox_colours.Checked == true) { InputChecker inputCheck = new InputChecker(); String input = textBox_decimalNumber.Text; if (inputCheck.isSuccessful(input)) { textBox_decimalNumber.BackColor = Color.FromArgb(46, 204, 113); } else if (textBox_decimalNumber.Text == "") { textBox_decimalNumber.BackColor = Color.White; } else { textBox_decimalNumber.BackColor = Color.FromArgb(231, 76, 60); } inputCheck = null; System.GC.Collect(); } else { textBox_decimalNumber.BackColor = Color.White; } }
private void textBox_decimalNumber_TextChanged(object sender, EventArgs e) { preventInputOver4Chars(); // max valid number is 3999, so no need for larger input. Also this code prevents input over the size of int32 String input = textBox_decimalNumber.Text; ErrorHandler errorMessager = new ErrorHandler(); InputChecker inputCheck = new InputChecker(); if (inputCheck.isSuccessful(input)) { toolStripStatusLabel_errorMessage.Text = ""; setColoursIfDesired(true); RomanNumeralConverter converter = new RomanNumeralConverter(input); String romanNumberal = converter.getRomanNumeral(); textBox_romanNumber.Text = romanNumberal; addRomanNumberToClipboardIfDesired(); converter = null; trackBar1.Value = Convert.ToInt32(input); } else { int errorCode = inputCheck.getErrorCode(); toolStripStatusLabel_errorMessage.Text = errorMessager.getErrorMessage(errorCode); setColoursIfDesired(false); textBox_romanNumber.Clear(); } errorMessager = null; inputCheck = null; System.GC.Collect(); }