public void Draw (Font f, Rectangle r, bool color) { string showTextString; int totalWidth = r.P2.X - r.P1.X; int subjectWidth = (int)(f.TextSize (subject + " ").X); int textValueWidth = totalWidth - subjectWidth; Rectangle textRect = new Rectangle (new Point (r.P1.X + subjectWidth, r.P1.Y), r.P2); Rectangle subjectRect = new Rectangle (r.P1, new Point (r.P2.X - textValueWidth, r.P2.Y)); if ((int)(f.TextSize (Text).X) < textValueWidth) { showTextString = Text; if (hide) { showTextString = new string ('*', showTextString.Length); } } else { showTextString = ""; for (int i = 0; i < Text.Length; i++) { if (f.TextSize (showTextString + this.Text [i] + "...").X < textValueWidth) { showTextString = showTextString + Text [i]; } else { break; } } if (hide) { showTextString = new string ('*', showTextString.Length); } else { showTextString = showTextString + "..."; } } Lcd.Instance.WriteTextBox (f, subjectRect,subject + " ", color); Lcd.Instance.WriteTextBox(f,textRect,showTextString,color,Lcd.Alignment.Right); }
public Dialog (Font f, string title, int width = 160, 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; 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)))); 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.Instance.SaveScreen();}; OnExit += delegate {Lcd.Instance.LoadScreen();}; }
public void Draw(Font f, Rectangle r, bool color) { int xCheckBoxSize =(int) f.maxWidth; Rectangle outer = new Rectangle(new Point(Lcd.Width - xCheckBoxSize + edgeSize, r.P1.Y + edgeSize), new Point(r.P2.X - edgeSize,r.P2.Y - edgeSize)); Rectangle innter = new Rectangle(new Point(Lcd.Width - xCheckBoxSize + lineSize+edgeSize, r.P1.Y+lineSize + edgeSize), new Point(r.P2.X - lineSize - edgeSize,r.P2.Y - lineSize - edgeSize)); Point fontPoint = f.TextSize("v"); Point checkPoint = new Point(Lcd.Width - xCheckBoxSize +(int) fontPoint.X-edgeSize, r.P1.Y); Lcd.Instance.WriteTextBox(f, r, text, color); Lcd.Instance.DrawBox(outer,color); Lcd.Instance.DrawBox(innter,!color); if(Checked) Lcd.Instance.WriteText(f,checkPoint,"v", color); }
public override void OnDrawTitle(Font f, Rectangle r, bool color) { font = f; rect = r; int arrowWidth = (int)f.maxWidth / 4; string valueAsString = " " + Value.ToString () + " "; Point p = f.TextSize (valueAsString); Rectangle numericRect = new Rectangle ( new Point( Lcd.Width - p.X, r.P1.Y),r.P2); Rectangle textRect = new Rectangle (new Point (r.P1.X, r.P1.Y), new Point (r.P2.X - (p.X), r.P2.Y)); Rectangle leftArrowRect = new Rectangle(new Point(numericRect.P1.X, numericRect.P1.Y+arrowEdge), new Point(numericRect.P1.X+ arrowWidth, numericRect.P2.Y-arrowEdge)); Rectangle rightArrowRect = new Rectangle( new Point(numericRect.P2.X-(arrowWidth + rightArrowOffset), numericRect.P1.Y+arrowEdge) , new Point(numericRect.P2.X-rightArrowOffset,numericRect.P2.Y-arrowEdge)); Lcd.WriteTextBox (f, textRect, text, color, Lcd.Alignment.Left); Lcd.WriteTextBox (f, numericRect, valueAsString, color, Lcd.Alignment.Right); Lcd.DrawArrow(leftArrowRect, Lcd.ArrowOrientation.Left, color); Lcd.DrawArrow(rightArrowRect, Lcd.ArrowOrientation.Right, color); }