public void Add(string text, TextFromBaseLine stat) { if (!string.IsNullOrEmpty(text)) { lst.Add(new TextAndState(stat, text, false)); OnTextChanged(); } }
public void Add(string text, TextFromBaseLine stat, bool continuous) { if (!string.IsNullOrEmpty(text)) { lst.Add(new TextAndState(stat, text, continuous)); OnTextChanged(); } }
public void Add(string text, char normal, char subscript, char superscript) { StringBuilder sb = new StringBuilder(); TextFromBaseLine stat = TextFromBaseLine.Normal; TextFromBaseLine statHelper = TextFromBaseLine.Normal; bool bNew = true; bool bAdd = false; sb.Remove(0, sb.Length); foreach (char c in text.ToCharArray()) { bNew = true; if (c == normal) { statHelper = TextFromBaseLine.Normal; } else if (c == subscript) { statHelper = TextFromBaseLine.Subscript; } else if (c == superscript) { statHelper = TextFromBaseLine.Superscript; } else { bNew = false; sb.Append(c); } if (bNew) { string s = sb.ToString(); if (!string.IsNullOrEmpty(s)) { lst.Add(new TextAndState(stat, s, false)); bAdd = true; } sb.Remove(0, sb.Length); } stat = statHelper; } string ss = sb.ToString(); if (!string.IsNullOrEmpty(ss)) { lst.Add(new TextAndState(stat, ss, false)); bAdd = true; } if (bAdd) { OnTextChanged(); } }
private SizeF MeasureStringWindows(Graphics g, Font font, bool fixedHeight) { Init(font, out Font subsup, out int subsupY); float x = 0; float y = subsupY; float xx, yy; xx = yy = 0; float x2 = x; TextFromBaseLine old = TextFromBaseLine.Normal; foreach (TextAndState ts in lst) { xx = x2; if (old != ts.Stat) { xx += 2; } yy = (ts.Stat == TextFromBaseLine.Normal ? y : (ts.Stat == TextFromBaseLine.Subscript ? y + font.Height / 2 : y - subsupY)); x2 += MyDrawString(ts.Text, g, null, (ts.Stat == TextFromBaseLine.Normal ? font : subsup), ref xx, ref yy, true, ts.Continuous); old = ts.Stat; } if (fixedHeight) { return(new SizeF(xx - x, 2 * subsupY + font.Height)); } foreach (TextAndState ts in lst) { if (ts.Stat != TextFromBaseLine.Normal) { return(new SizeF(xx - x, 2 * subsupY + font.Height)); } } return(new SizeF(xx - x, font.Height)); }
private void DrawStringWindows(Graphics g, Font font, Brush br, float x, float y, bool fixedHeight) { Init(font, out Font subsup, out int subsupY); y += subsupY; bool allIsNormal = true; foreach (TextAndState ts in lst) { allIsNormal &= (ts.Stat == TextFromBaseLine.Normal); } float xx = x; TextFromBaseLine old = TextFromBaseLine.Normal; foreach (TextAndState ts in lst) { xx = x; if (old != ts.Stat) { xx += 2; } float yy = (ts.Stat == TextFromBaseLine.Normal ? y : (ts.Stat == TextFromBaseLine.Subscript ? y + font.Height / 2 : y - subsupY)); if (allIsNormal && !fixedHeight) { yy = y - subsupY; } x += MyDrawString(ts.Text, g, br, (ts.Stat == TextFromBaseLine.Normal ? font : subsup), ref xx, ref yy, false, ts.Continuous); old = ts.Stat; } }
public TextAndState(TextFromBaseLine stat, string text, bool continuous) { Stat = stat; Text = text; Continuous = continuous; }
public void Insert(int index, string text, TextFromBaseLine stat, bool continuous) { lst.Insert(index, new TextAndState(stat, text, continuous)); OnTextChanged(); }
public void Insert(int index, string text, TextFromBaseLine stat) { lst.Insert(index, new TextAndState(stat, text, false)); OnTextChanged(); }