How do I properly change the Font Style of the text without using a lot of if / else if conditions when checking multiple checkboxes?
PS. I know what to use when having multiple styles in one text but I d not want a long if/else conditions to achieve it.
Here's what I Have:
public void updateFont()
{
//Individual
if (checkBox_Bold.Checked)
fontStyle = fontFamily.Style | FontStyle.Bold;
if (checkBox_Italic.Checked)
fontStyle = fontFamily.Style | FontStyle.Italic;
if (checkBox_Underlined.Checked)
fontStyle = fontFamily.Style | FontStyle.Underline;
if (checkBox_StrikeOut.Checked)
fontStyle = fontFamily.Style | FontStyle.Strikeout;
if (!checkBox_Bold.Checked && !checkBox_Italic.Checked && !checkBox_Underlined.Checked && !checkBox_StrikeOut.Checked)
fontStyle = FontStyle.Regular;
fontFamily = new Font(cbox_FontFamily.SelectedItem.ToString(), Convert.ToInt32(fontSize), fontStyle);
pictureBox_Canvass.Invalidate();
}