public void WriteTextBox(Font f, Rectangle r, string text, bool color, Lcd.Alignment aln) { DrawRectangle(r, !color, true); // Clear background int xpos = 0; if (aln == Lcd.Alignment.Left) { } else if (aln == Lcd.Alignment.Center) { int width = TextWidth(f, text); xpos = (r.P2.X - r.P1.X) / 2 - width / 2; if (xpos < 0) { xpos = 0; } } else { int width = TextWidth(f, text); xpos = (r.P2.X - r.P1.X) - width; if (xpos < 0) { xpos = 0; } } WriteText(f, r.P1 + new Point(xpos, 0), text, color); }
protected void WriteTextOnLine(string text, int lineIndex, bool color = true, Lcd.Alignment alignment = Lcd.Alignment.Center) { Lcd.Instance.WriteTextBox(font, lines[lineIndex], text, color, alignment); }
protected void WriteTextOnLine(string text, int lineIndex, bool color = true, Lcd.Alignment alignment = Lcd.Alignment.Center) { Font f = font; string s = text; int lineWidth = lines [lineIndex].P2.X - lines [lineIndex].P1.X; if (f.TextSize(text.Remove(text.Length - 1)).X > lineWidth) { f = Font.SmallFont; while (f.TextSize(s).X > lineWidth) { s = s.Remove(s.Length - 1); } } Lcd.Instance.WriteTextBox(f, lines[lineIndex], s, color, alignment); }
public static void WriteTextBox(Font f, Rectangle r, string text, bool color, Lcd.Alignment aln) { writeTextBoxWithAlignment(f, r, text, color, aln); }