private void txtbx_TextChanged(object sender, System.EventArgs e) { TextBoxX txtbx = (TextBoxX)sender; if (updatingColor || handlingError) { return; } if (String.IsNullOrEmpty(txtbx.Text)) { txtbx.Text = "0"; return; } if (txtbx.Text == "0") { txtbx.SelectAll(); } if (ValueInRange(txtbx.Text, false) == 0) // Value is in range if 0. { short r = (String.IsNullOrEmpty(txtbxR.Text) ? (short)0 : Convert.ToInt16(txtbxR.Text)), g = (String.IsNullOrEmpty(txtbxG.Text) ? (short)0 : Convert.ToInt16(txtbxG.Text)), b = (String.IsNullOrEmpty(txtbxB.Text) ? (short)0 : Convert.ToInt16(txtbxB.Text)); updatingText = true; cpbColor.SelectedColor = System.Drawing.Color.FromArgb(r, g, b); updatingText = false; } }
private void txtbx_TextChanged(object sender, System.EventArgs e) { TextBoxX txtbx = (TextBoxX)sender; if (updatingColor || handlingError) { return; } if (String.IsNullOrEmpty(txtbx.Text)) { txtbx.Text = "0"; return; } if (txtbx.Text == "0") { txtbx.SelectAll(); } errorA = !(ValueInRange(txtbxA.Text, false) == 0); errorR = !(ValueInRange(txtbxR.Text, false) == 0); errorG = !(ValueInRange(txtbxG.Text, false) == 0); errorB = !(ValueInRange(txtbxB.Text, false) == 0); SetError(); // Forces error status evaluation since errorB will always be what it previously was until after ValueInRange() (and thus the last SetError() call) has finished excuting. if (Convert.ToBoolean(Error)) { return; // If there is something wrong with any of the values, we cannot proceed. } // The colors range between 0.0-1.0 --- we need to convert them to their RGB components. short r = Convert.ToInt16(Convert.ToSingle(txtbxR.Text) * 255f), g = Convert.ToInt16(Convert.ToSingle(txtbxG.Text) * 255f), b = Convert.ToInt16(Convert.ToSingle(txtbxB.Text) * 255f); updatingText = true; cpbColor.SelectedColor = System.Drawing.Color.FromArgb(r, g, b); updatingText = false; }
private void ButtonItem4_Click(object sender, EventArgs e) { activeTextBox.SelectAll(); }