protected void ClearContent() { Lcd.LoadScreen(); Lcd.DrawRectangle(outherWindow, true, true); Lcd.DrawRectangle(innerWindow, false, true); Lcd.WriteTextBox(font, titleRect, title, false, Lcd.Alignment.Center); }
public Dialog(Font f, string title, int width = 170, int height = 90, int topOffset = 0) { dialogWidth = width; dialogHeight = height; this.font = f; this.title = title; int xEdge = (Lcd.Width - dialogWidth) / 2; int yEdge = (Lcd.Height - dialogHeight) / 2; Point startPoint1 = new Point(xEdge, yEdge); Point startPoint2 = new Point(xEdge + dialogWidth, yEdge + dialogHeight); this.titleSize = font.TextSize(this.title).X + (int)f.maxWidth; if (title == "") { } this.drawTitle = title != ""; outherWindow = new Rectangle(startPoint1, startPoint2); innerWindow = new Rectangle(new Point(startPoint1.X + dialogEdge, startPoint1.Y + dialogEdge), new Point(startPoint2.X - dialogEdge, startPoint2.Y - dialogEdge)); titleRect = new Rectangle(new Point((int)(Lcd.Width / 2 - titleSize / 2), (int)(startPoint1.Y - (font.maxHeight / 2))), new Point((int)(Lcd.Width / 2 + titleSize / 2), (int)(startPoint1.Y + (font.maxHeight / 2)))); if (titleRect.P1.Y < 0) { this.titleSize = Font.SmallFont.TextSize(this.title).X + (int)f.maxWidth; titleRect = new Rectangle(new Point((int)(Lcd.Width / 2 - titleSize / 2), (int)(startPoint1.Y - (Font.SmallFont.maxHeight / 2))), new Point((int)(Lcd.Width / 2 + titleSize / 2), (int)(startPoint1.Y + (Font.SmallFont.maxHeight / 2)))); useSmallTitle = true; } int top = innerWindow.P1.Y + (int)(f.maxHeight / 2) + topOffset; int middel = innerWindow.P1.Y + ((innerWindow.P2.Y - innerWindow.P1.Y) / 2) - (int)(f.maxHeight) / 2; int count = 0; while (middel > top) { middel = middel - (int)f.maxHeight; count++; } int numberOfLines = count * 2 + 1; Point start1 = new Point(innerWindow.P1.X, topOffset + innerWindow.P1.Y + ((innerWindow.P2.Y - innerWindow.P1.Y) / 2) - (int)f.maxHeight / 2 - count * ((int)f.maxHeight)); Point start2 = new Point(innerWindow.P2.X, start1.Y + (int)f.maxHeight); lines = new List <Rectangle>(); for (int i = 0; i < numberOfLines; i++) { lines.Add(new Rectangle(new Point(start1.X, start1.Y + (i * (int)f.maxHeight)), new Point(start2.X, start2.Y + (i * (int)f.maxHeight)))); } bottomLineCenter = new Point(innerWindow.P1.X + ((innerWindow.P2.X - innerWindow.P1.X) / 2), outherWindow.P2.Y - dialogEdge / 2); OnShow += delegate { Lcd.SaveScreen(); }; OnExit += delegate { Lcd.LoadScreen(); cancelSource.Cancel(); }; }