0
我需要在运行时根据四个布尔值初始化具有多种样式的字体对象。具有多种样式的初始化字体对象
bool bold,italic,underline,strikeout;
myFont = new Font(fontText[0], size, FontStyle.Bold,FontStyle.Italic,FontStyle.Undeline,FontStyle.Strikeout);
//If all boolen values are true.
如果考虑到所有可能的值,那么将会有24个案例。
如何避免编写所有这些条件? 建议某种方式做到这一点?
在这里你去:http://stackoverflow.com/questions/2813134/how-to-set-multiple -fontstyles-when-instantiating-a-font顺便说一句,它只有16个案例。 – 2012-03-01 08:26:37
@ Mr.Lister字体样式可能完全不存在,因此4 * 3 * 2 * 1 = 24; – 2012-03-01 12:46:29
不,这是不正确的,对不起。您不能以多种方式组合字体样式。 'FontStyle.Italic | FontStyle.Bold'与'FontStyle.Bold | FontStyle.Italic'完全一样。我链接的问题有帮助吗? – 2012-03-01 13:01:43