Ejemplo n.º 1
0
		public ItemList (string title, Font font, bool reloadListOnFocus, string emptyListInfo)
		{
			this.title = title;
			this.font = font;
			this.reloadOnFocus = reloadListOnFocus;
			emptyListListInfoDialog = new ItemWithDialog<InfoDialog>(new InfoDialog(emptyListInfo));
		}
Ejemplo n.º 2
0
		public void OnDrawTitle (Font font, Rectangle rectangle, bool selected)
		{
			Lcd.WriteTextBox (font, rectangle, title, selected);
			int arrowWidth = (int)font.maxWidth / 3;
			Rectangle arrowRect = new Rectangle (new Point (rectangle.P2.X - (arrowWidth + arrowOffset), rectangle.P1.Y + arrowEdge), new Point (rectangle.P2.X - arrowOffset, rectangle.P2.Y - arrowEdge));
			Lcd.DrawArrow (arrowRect, Lcd.ArrowOrientation.Right, selected);
		}
		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);
		}
Ejemplo n.º 4
0
		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();};	
		}
Ejemplo n.º 5
0
		public Menu (Font f, string title, IEnumerable<IMenuItem> items)
		{
			this.font = f;
			this.title = title;
			this.menuItems = items.ToArray ();			
			this.itemSize = new Point (Lcd.Width, (int)font.maxHeight);
			this.itemHeight = new Point (0, (int)font.maxHeight);
			this.itemsOnScreen = (int)((Lcd.Height-arrowHeight)/ font.maxHeight - 1); // -1 Because of the title
			cursorPos = 0;
			scrollPos = 0;
		}
Ejemplo n.º 6
0
		public void Draw (Font f, Rectangle r, bool color)
		{
			Lcd.Instance.WriteTextBox (f, r, text, color);
			if (symbole == MenuItemSymbole.LeftArrow || symbole == MenuItemSymbole.RightArrow) {
				int arrowWidth =(int) f.maxWidth/3;
				Rectangle arrowRect = new Rectangle(new Point(r.P2.X -(arrowWidth+arrowOffset), r.P1.Y + arrowEdge), new Point(r.P2.X -arrowOffset, r.P2.Y-arrowEdge));
				if(symbole == MenuItemSymbole.LeftArrow)
					Lcd.Instance.DrawArrow(arrowRect,Lcd.ArrowOrientation.Left, color);
				else
					Lcd.Instance.DrawArrow(arrowRect,Lcd.ArrowOrientation.Right, color);
			}
		}	
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 9
0
 private bool DeleteCharacter()
 {
     if (resultString.Length != 0) {
         resultString = resultString.Substring (0, resultString.Length - 1);
         if (useSmallFont) {
             if (inputLines.Count == 0) {
                 if (Font.MediumFont.TextSize (resultString).X < (resultRect.P2.X - resultRect.P1.X) - characterSize) {
                     useSmallFont = false;
                     resultFont = Font.MediumFont;
                 }
             }
         }
     } else if (useSmallFont && inputLines.Count != 0)
     {
         resultString = inputLines[inputLines.Count-1];
         inputLines.RemoveAt(inputLines.Count-1);
         resultString = resultString.Substring (0, resultString.Length - 1);
         if(inputLines.Count == 0)
             showLine = false;
     }
     return false;
 }
Ejemplo n.º 10
0
 private bool AddCharacter(string characterToAdd)
 {
     resultString = resultString + characterToAdd;
     int charSize;
     if (useSmallFont) {
         charSize = characterSize/2;
     }
     else
     {
         charSize = characterSize;
     }
     bool tooBig = resultFont.TextSize (resultString).X >= (resultRect.P2.X - resultRect.P1.X) - charSize;
         if (tooBig) {//to big
             if (!useSmallFont) {
                 useSmallFont = true;
                 resultFont = Font.SmallFont;
             } else {
                 if (tooBig) {//add using small font
                     showLine = true;
                     inputLines.Add (resultString);
                     resultString = "";
                 }
             }
         }
     return false;
 }
Ejemplo n.º 11
0
		public ItemList (string title, Font font, bool reloadListOnFocus = true) : this(title, font, reloadListOnFocus, null) 
		{
		
		}
Ejemplo n.º 12
0
 public static void WriteTextBox(Font f, Rectangle r, string text, bool color, Lcd.Alignment aln)
 {
   Instance.WriteTextBox(f,r,text,color,aln);
 }
Ejemplo n.º 13
0
 public void WriteText(Font f, Point p, string text, bool color)
 {
     foreach(char c in text)
     {
         CharStreamer cs = f.getChar(c);
         if (p.X+cs.width > Lcd.Width)
             break;
         DrawBitmap(cs, p, cs.width, cs.height, color);
         p.X += (int)cs.width;
     }
 }
Ejemplo n.º 14
0
 public int TextWidth(Font f, string text)
 {
     int width = 0;
     foreach(char c in text)
     {
         CharStreamer cs = f.getChar(c);
         width += (int)cs.width;
     }
     return width;
 }
Ejemplo n.º 15
0
 public static void WriteText(Font f, Point p, string text, bool color)
 {
   Instance.WriteText(f,p,text, color);
 }
Ejemplo n.º 16
0
 public static void WriteTextBox(Font f, Rectangle r, string text, bool color)
 {
   Instance.WriteTextBox(f,r,text,color);
 }
Ejemplo n.º 17
0
 public void WriteTextBox(Font f, Rectangle r, string text, bool color)
 {
     WriteTextBox(f, r, text, color, Alignment.Left);
 }
Ejemplo n.º 18
0
 public static int TextWidth(Font f, string text)
 {
   return Instance.TextWidth(f, text);
 }
Ejemplo n.º 19
0
 public void WriteTextBox(Font f, Rectangle r, string text, bool color, Alignment aln)
 {
     DrawBox(r, !color); // Clear background
     int xpos = 0;
     if (aln == Alignment.Left)
     {
     }
     else if (aln == 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);
 }