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);
		}
예제 #2
0
			public void Reset ()
			{
				lines = (int)(Lcd.Height/f.maxHeight);				
				lineHeigth = (float)Lcd.Height/lines;
				lineSize = new Rectangle(new Point(0,0), new Point((int)Lcd.Width, (int)f.maxHeight));

			}
예제 #3
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);
		}
예제 #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();};	
		}
예제 #5
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);
			}
		}	
		public CharacterDialog(string title) : base(Font.MediumFont, title, Lcd.Width, Lcd.Height-22) 
        {
			characterInnerBox = new Point(characterSize, characterSize); 
			characterOutherBox = new Point(characterInnerBox.X + 2* characterEdge, characterInnerBox.Y + 2* characterEdge);
			alfabetSet = new ICharacterSet[]{new SmallLetters(), new BigLetters()};
			symboleSet = new ICharacterSet[]{new NumbersAndSymbols(), new NumbersAndSymbols2()};
			selectedSet = alfabetSet[selectedSetIndex];
			setTypeString = symboleSetString;
            resultRect = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - (int)Font.MediumFont.maxHeight -1 ), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -1));
            resultRectSmall = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - (int)Font.SmallFont.maxHeight -1 ), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -1));
            lineRect = new Rectangle(new Point(innerWindow.P1.X+characterEdge, innerWindow.P2.Y - 2*((int)Font.SmallFont.maxHeight -1 )), new Point(innerWindow.P2.X-characterEdge, innerWindow.P2.Y -((int)Font.SmallFont.maxHeight -1 )));
            resultString = "";
        }
예제 #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);
        }
예제 #8
0
파일: Menu.cs 프로젝트: RoninWest/monoev3
		private void RedrawMenu ()
		{
			Lcd.Instance.Clear ();
			Rectangle currentPos = new Rectangle (new Point (0, 0), itemSize);
			Rectangle arrowRect = new Rectangle (new Point (Lcd.Width / 2 - arrowWidth / 2, Lcd.Height - arrowHeight), new Point (Lcd.Width / 2 + arrowWidth / 2, Lcd.Height-1));

			Lcd.Instance.WriteTextBox (font, currentPos, title, true, Lcd.Alignment.Center);
			int i = 0;
			while (i != itemsOnScreen) {
				if (i + scrollPos >= menuItems.Length)
					break;
				menuItems [i + scrollPos].Draw (font, currentPos + itemHeight * (i + 1), i != cursorPos);
				i++;
			}
			Lcd.Instance.DrawArrow (arrowRect, Lcd.ArrowOrientation.Down, scrollPos + itemsOnScreen < menuItems.Length);
			Lcd.Instance.Update();
		}
예제 #9
0
		public InfoDialog(string message, string title = "Information"):base(Font.MediumFont,title)
		{
			stringList = Text2List (message, 0);
			UpdateNumberOfPages ();
			if (numberOfPages > 1) {
				stringList = Text2List (message, scrollBarWidth + scrollBarOffSet);
				UpdateNumberOfPages ();
				scrollBar = new Rectangle (new Point (this.innerWindow.P2.X - scrollBarWidth - scrollBarOffSet, this.innerWindow.P1.Y + scrollBarOffSet), new Point (this.innerWindow.P2.X - scrollBarOffSet, this.innerWindow.P2.Y - scrollBarOffSet));
				for (int i = 0; i < lines.Count; i++)
				{
					Point p1 = lines [i].P1;
					Point p2 = lines [i].P2;
					lines.RemoveAt (i);
					lines.Insert(i, new Rectangle( p1, new Point(p2.X - (scrollBarWidth + scrollBarOffSet),p2.Y ))); 
				}
				indexHeight = (scrollBar.P2.Y - scrollBar.P1.Y) / numberOfPages;
			} 
		}
        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);
        }
예제 #11
0
 public ProgressAnimation(Rectangle rect)
 {
     IsRunning = false;
     thread = new System.Threading.Thread (AnimationThread);
     int width = rect.P2.X - rect.P1.X;
     int numberOfRects = (width - rectSpace) / (rectWidth + rectSpace);
     int height = rect.P2.Y - rect.P1.Y;
     int totalWidthUsed = numberOfRects * (rectWidth + rectSpace);
     int startOffset = (width - totalWidthUsed)/2;
     Point animationPoint2 = new Point(rectWidth, height);
     Point spacePoint = new Point(rectSpace, 0);
     Point animationPoint = new Point(rectWidth,0);
     Point start = new Point(rect.P1.X + rectSpace + startOffset, rect.P1.Y);
     for (int i = 0; i < numberOfRects; i++)
     {
         rects.Add( new Rectangle(start, start + animationPoint2) );
         start = start +  spacePoint + animationPoint;
     }
     resetEvent = new ManualResetEvent(false);
 }
예제 #12
0
        public static void Main(string[] args)
        {
            new Motor(MotorPort.OutA).Off();

            Lcd.Instance.ShowPicture(MonoPicture.Picture);
            Font f = Font.MediumFont;
            Point offset = new Point(0,25);
            Point p = new Point(10, Lcd.Height-75);
            Point boxSize = new Point(100, 24);
            Rectangle box = new Rectangle(p, p+boxSize);

            ButtonEvents buts = new ButtonEvents();
            int val = 7;
            buts.EnterPressed += () =>
            {
                Lcd.Instance.Clear();
                Lcd.Instance.WriteTextBox(f, box + offset*0, "Value = " + val.ToString(), true);
                Lcd.Instance.WriteTextBox(f, box + offset*1, "Hello World!!", false);
                Lcd.Instance.WriteTextBox(f, box + offset*2, "Hello World!!", true);
                Lcd.Instance.Update ();
                val++;
            };
            buts.UpPressed += () =>
            {
                Lcd.Instance.Clear();
                Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width-monoLogo.Width)/2,10));
                Lcd.Instance.Update();
            };
            buts.DownPressed += () =>
            {
                Lcd.Instance.TakeScreenShot();
                Lcd.Instance.Clear();
                Lcd.Instance.WriteTextBox(f, box + offset*1, "Screen Shot", true);
                Lcd.Instance.Update();
            };
            buts.EscapePressed += () => stopped.Set();
            stopped.WaitOne();
            Lcd.Instance.WriteTextBox(f, box + offset*0, "Done!", true);
            Lcd.Instance.Update();
        }
예제 #13
0
		public static void Main (string[] args)
		{
			Bitmap monoLogo = Bitmap.FromResouce(Assembly.GetExecutingAssembly(), "monologo.bitmap");
			EventWaitHandle stopped = new ManualResetEvent(false);
			Lcd.ShowPicture(MonoPicture.Picture);
			Font f = Font.MediumFont;
			Point offset = new Point(0,25);
			Point p = new Point(10, Lcd.Height-75);
			Point boxSize = new Point(100, 24);
			Rectangle box = new Rectangle(p, p+boxSize);
			using (ButtonEvents buts = new ButtonEvents ()) 
			{
				int val = 7;
				buts.EnterPressed += () => { 
					Lcd.Clear ();
					Lcd.WriteTextBox (f, box + offset * 0, "Value = " + val.ToString (), true);
					Lcd.WriteTextBox (f, box + offset * 1, "Hello EV3!!", false);
					Lcd.WriteTextBox (f, box + offset * 2, "Hello World!!", true);	
					Lcd.Update (); 				
					val++;
				};
				buts.UpPressed += () => { 
					Lcd.Clear ();
					Lcd.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 10));	
					Lcd.Update ();	
				};
				buts.DownPressed += () => { 
					Lcd.TakeScreenShot ();
					Lcd.Clear ();
					Lcd.WriteTextBox (f, box + offset * 1, "Screen Shot", true);	
					Lcd.Update ();		
				};
				buts.EscapePressed += () => stopped.Set ();
				stopped.WaitOne ();
			}
			Lcd.WriteTextBox(f, box + offset*0, "Done!", true);
			Lcd.Update();
		}
예제 #14
0
		public static void Main (string[] args)
		{
			ManualResetEvent terminateProgram = new ManualResetEvent (false);
			string fbToken = "CAACpSl1Qm3cBAHAMyZAY...";//This is not valied
			var fb = new FacebookClient(fbToken);
			Font f = Font.MediumFont;
			Point offset = new Point(0,25);
			Point p = new Point(10, Lcd.Height-75);
			Point boxSize = new Point(100, 24);
			Rectangle box = new Rectangle(p, p+boxSize);
			var colorSensor = new EV3ColorSensor (SensorPort.In1);
			ButtonEvents buts = new ButtonEvents ();
			LcdConsole.WriteLine("Use color on port1");
			LcdConsole.WriteLine("Enter post value");
			LcdConsole.WriteLine("Esc. terminate");
			buts.EscapePressed += () => { 
				terminateProgram.Set();
			};
			
			buts.EnterPressed += () => { 
				Color color = colorSensor.ReadColor();
				Lcd.Clear();
				Lcd.WriteTextBox(f, box + offset*0, "Color: " + color, true);
				Lcd.WriteTextBox(f, box + offset*1, "Send to Facebook" + color, true);
				Lcd.Update();
				colorSensor.ReadColor();
				var me = fb.Get("monobrick.dk") as JsonObject;
				var uid = me["id"];
		    	string url = string.Format("{0}/{1}", uid, "feed");
		    	var argList = new Dictionary<string, object>();
		    	argList["message"] = "A program running MonoBrick Firmware was aked to read the color sensor. Color read: " + colorSensor.ReadColor().ToString();
		    	fb.Post(url, argList);
			};
			terminateProgram.WaitOne (); 
		    		
		}
예제 #15
0
파일: Lcd.cs 프로젝트: tudor-olariu/monoev3
 public static void WriteTextBox(Font f, Rectangle r, string text, bool color, Lcd.Alignment aln)
 {
   Instance.WriteTextBox(f,r,text,color,aln);
 }
예제 #16
0
파일: Lcd.cs 프로젝트: tudor-olariu/monoev3
 public static void WriteTextBox(Font f, Rectangle r, string text, bool color)
 {
   Instance.WriteTextBox(f,r,text,color);
 }
예제 #17
0
파일: Lcd.cs 프로젝트: tudor-olariu/monoev3
 public static void DrawArrow(Rectangle r, Lcd.ArrowOrientation orientation, bool color)
 {
   Instance.DrawArrow(r,orientation,color);
 }
예제 #18
0
        protected override void OnDrawContent()
        {
            bool rightArrowSelected = false;
            bool leftArrowSelected = false;
            bool deleteSelected = false;
            bool okSelected = false;
            bool spaceSelected = false;
            bool changeSelected = false;
            bool charactersSelected = false;
            int characterIndex = 0;
            Point start;
            Rectangle outherRect;
            Rectangle innerRect;
            int line;
            for (line = 0; line < 2; line++) {
                start = new Point (innerWindow.P1.X, innerWindow.P1.Y + (int)font.maxHeight / 2 - yPrintOffset + line * characterOutherBox.Y);
                outherRect = new Rectangle (start, start + characterOutherBox);
                for (int character = 0; character < maxNumberOfHorizontalCharacters; character++) {
                    bool selected = (selectedLine == line && selectedIndex == character);
                    if (selected) {
                        selection = Selection.Character;
                        charactersSelected = true;
                        selectedCharacter = selectedSet.Characters [characterIndex].ToString ();
                    }
                    Lcd.Instance.DrawBox (outherRect, true);
                    innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
                    Lcd.Instance.DrawBox (innerRect, selected);
                    Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset, innerRect.P1.Y - characterOffset), selectedSet.Characters [characterIndex].ToString (), !selected);
                    outherRect = outherRect + new Point (characterOutherBox.X, 0) + characterSpace;
                    characterIndex++;
                }
            }
            if (selectedLine == line && selectedIndex < lineThreeCharacterIndexStart) {
                if (selectedIndex == 0) {
                    selection = Selection.LeftArrow;
                    leftArrowSelected = true;
                } else {
                    selection = Selection.RightArrow;
                    rightArrowSelected = true;
                }
            }
            start = new Point (innerWindow.P1.X, innerWindow.P1.Y + (int)font.maxHeight / 2 - yPrintOffset + line * characterOutherBox.Y);

            outherRect = new Rectangle (start, start + characterOutherBox);
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, leftArrowSelected);
            innerRect = new Rectangle (new Point (outherRect.P1.X + 3 * characterEdge, outherRect.P1.Y + 3 * characterEdge), new Point (outherRect.P2.X - 3 * characterEdge, outherRect.P2.Y - 3 * characterEdge));
            Lcd.Instance.DrawArrow (innerRect, Lcd.ArrowOrientation.Left, !leftArrowSelected);

            outherRect = outherRect + new Point (characterOutherBox.X, 0) + characterSpace;
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, rightArrowSelected);
            innerRect = new Rectangle (new Point (outherRect.P1.X + 3 * characterEdge, outherRect.P1.Y + 3 * characterEdge), new Point (outherRect.P2.X - 3 * characterEdge, outherRect.P2.Y - 3 * characterEdge));
            Lcd.Instance.DrawArrow (innerRect, Lcd.ArrowOrientation.Right, !rightArrowSelected);

            for (int character = 0; character < maxNumberOfButtomCharacters; character++) {
                bool selected = false;
                if (selectedLine == line) {
                    if (selectedIndex >= lineThreeCharacterIndexStart && selectedIndex < lineThreeCharacterIndexEnd && (selectedIndex - lineThreeCharacterIndexStart) == character) {
                        selected = true;
                        selection = Selection.Character;
                        charactersSelected = true;
                        selectedCharacter = selectedSet.Characters [characterIndex].ToString ();
                    }
                }
                outherRect = outherRect + new Point (characterOutherBox.X, 0) + characterSpace;
                Lcd.Instance.DrawBox (outherRect, true);
                innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
                Lcd.Instance.DrawBox (innerRect, selected);
                Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset, innerRect.P1.Y - characterOffset), selectedSet.Characters [characterIndex].ToString (), !selected);
                characterIndex++;
            }

            if (selectedLine == line && selectedIndex >= lineThreeCharacterIndexEnd) {
                selection = Selection.Delete;
                deleteSelected = true;
            }

            outherRect = new Rectangle (new Point (outherRect.P1.X, outherRect.P1.Y), new Point (outherRect.P2.X + characterOutherBox.X + characterSpace.X, outherRect.P2.Y)) + new Point (characterOutherBox.X, 0) + new Point (characterSpace.X, characterSpace.Y);
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, deleteSelected);
            Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset + 1, innerRect.P1.Y - characterOffset + 1), "Del", !deleteSelected);

            line++;

            if (selectedLine == line && selectedIndex >= lineFourSpaceEnd) {
                selection = Selection.Ok;
                okSelected = true;
            }
            if (selectedLine == line && selectedIndex < lineFourSpaceStart) {
                selection = Selection.Change;
                changeSelected = true;
            }

            if (selectedLine == line && selectedIndex >= lineFourSpaceStart && selectedIndex < lineFourSpaceEnd) {
                selection = Selection.Space;
                spaceSelected = true;
            }

            start = new Point (innerWindow.P1.X, innerWindow.P1.Y + (int)font.maxHeight / 2 - yPrintOffset + line * characterOutherBox.Y);

            outherRect = new Rectangle (new Point (start.X, start.Y), new Point (start.X + 2 * characterOutherBox.X + characterSpace.X, start.Y + characterOutherBox.Y));
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, changeSelected);
            Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset - 3, innerRect.P1.Y - characterOffset), setTypeString, !changeSelected);

            outherRect = new Rectangle (new Point (start.X + 2 * characterSpace.X + 2 * characterOutherBox.X, start.Y), new Point (start.X + 2 * characterSpace.X + 2 * characterOutherBox.X + 6 * characterOutherBox.X + 5 * characterSpace.X, start.Y + characterOutherBox.Y));
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, spaceSelected);
            Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset + 3, innerRect.P1.Y - characterOffset + 1), "  SPACE", !spaceSelected);

            outherRect = new Rectangle (new Point (outherRect.P2.X + characterSpace.X, outherRect.P1.Y), new Point (outherRect.P2.X + 2 * characterSpace.X + 2 * characterOutherBox.X, outherRect.P2.Y));
            Lcd.Instance.DrawBox (outherRect, true);
            innerRect = new Rectangle (new Point (outherRect.P1.X + characterEdge, outherRect.P1.Y + characterEdge), new Point (outherRect.P2.X - characterEdge, outherRect.P2.Y - characterEdge));
            Lcd.Instance.DrawBox (innerRect, okSelected);
            Lcd.Instance.WriteText (Font.MediumFont, new Point (innerRect.P1.X + characterOffset + 2, innerRect.P1.Y - characterOffset + 1), "OK", !okSelected);

            int xUnderLine = innerWindow.P1.X + characterEdge + resultFont.TextSize (resultString).X;
            int yUnderLine = innerWindow.P2.Y - 1;

            if (charactersSelected) {
                if (!useSmallFont) {
                    Lcd.Instance.WriteTextBox (resultFont, resultRect, resultString + selectedCharacter, true, Lcd.Alignment.Left);
                    Lcd.Instance.DrawHLine (new Point (xUnderLine, yUnderLine), resultFont.TextSize(selectedCharacter).X, true);
                }
                else {
                    Lcd.Instance.WriteTextBox (resultFont, resultRectSmall, resultString + selectedCharacter, true, Lcd.Alignment.Left);
                    Lcd.Instance.DrawHLine (new Point (xUnderLine, yUnderLine), resultFont.TextSize(selectedCharacter).X, true);
                    if (showLine) {
                        Lcd.Instance.WriteTextBox (resultFont, lineRect,inputLines[inputLines.Count-1], true, Lcd.Alignment.Left);
                    }
                }
            } else {
                if (!useSmallFont) {
                    Lcd.Instance.WriteTextBox (resultFont, resultRect, resultString + " ", true, Lcd.Alignment.Left);
                    Lcd.Instance.DrawHLine (new Point (xUnderLine, yUnderLine), resultFont.TextSize(selectedCharacter).X, true);

                }
                else {
                    Lcd.Instance.WriteTextBox (resultFont, resultRectSmall, resultString + " ", true, Lcd.Alignment.Left);
                    Lcd.Instance.DrawHLine (new Point (xUnderLine, yUnderLine), resultFont.TextSize(selectedCharacter).X, true);
                    if (showLine) {
                        Lcd.Instance.WriteTextBox (resultFont, lineRect, inputLines[inputLines.Count-1], true, Lcd.Alignment.Left);
                    }
                }

            }
        }
예제 #19
0
		protected void DrawRightButton (string text, bool color, int textSize)
		{
			if (textSize == 0) 
			{
				textSize = font.TextSize(text).X;	
			}
			textSize+= buttonTextOffset;
			Point right1 = bottomLineCenter + new Point(boxMiddleOffset,(int)-font.maxHeight/2);
			Point right2 = bottomLineCenter + new Point(boxMiddleOffset + (int)textSize,(int)font.maxHeight/2);
			Point rightOuter1 = right1 + new Point(-buttonEdge,-buttonEdge);
			Point rightOuter2 = right2 + new Point(buttonEdge,buttonEdge);
			
			
			Rectangle rightRect = new Rectangle(right1, right2);
			Rectangle rightOuterRect = new Rectangle(rightOuter1, rightOuter2);
			
			Lcd.DrawRectangle(rightOuterRect, true, true);
			
			Lcd.WriteTextBox(font, rightRect, text, color, Lcd.Alignment.Center);
		
		}
예제 #20
0
		protected void DrawCenterButton (string text, bool color, int textSize)
		{
			if (textSize == 0) 
			{
				textSize = font.TextSize(text).X;	
			}
			textSize+= buttonTextOffset;
			Point buttonP1 = bottomLineCenter + new Point((int)-textSize/2,(int)-font.maxHeight/2);
			Point buttonP2 = bottomLineCenter + new Point((int)textSize/2,(int)font.maxHeight/2);
			
			Point buttonP1Outer = buttonP1 + new Point(-buttonEdge,-buttonEdge);
			Point buttonp2Outer = buttonP2 + new Point(buttonEdge,buttonEdge);
			
			Rectangle buttonRect = new Rectangle(buttonP1, buttonP2);
			Rectangle buttonRectEdge = new Rectangle(buttonP1Outer, buttonp2Outer);
			
			Lcd.DrawRectangle(buttonRectEdge,true, true);
			Lcd.WriteTextBox(font,buttonRect,text, color, Lcd.Alignment.Center);		
		}
예제 #21
0
파일: Lcd.cs 프로젝트: RoninWest/monoev3
 public void DrawBox(Rectangle r, bool setOrClear)
 {
     int length = r.P2.X - r.P1.X;
     for (int y = r.P1.Y; y <= r.P2.Y; ++y)
         DrawHLine(new Point(r.P1.X, y), length, setOrClear);
 }
예제 #22
0
		private void DrawItemList ()
		{
			if (!isItemSizeCalculated) {
				CalculateItemSize ();
				isItemSizeCalculated = true;
			}
			Lcd.Clear ();
			Rectangle currentPos = new Rectangle (new Point (0, 0), itemSize);
			Rectangle arrowRect = new Rectangle (new Point (Lcd.Width / 2 - arrowWidth / 2, Lcd.Height - arrowHeight), new Point (Lcd.Width / 2 + arrowWidth / 2, Lcd.Height - 1));

			Lcd.WriteTextBox (font, currentPos, title, true, Lcd.Alignment.Center);
			int i = 0;
			while (i != itemsOnScreen) {
				if (i + scrollPos >= items.Count)
					break;
				items [i + scrollPos].OnDrawTitle (font, currentPos + itemHeight * (i + 1), i != cursorPos);
				i++;
			}
			Lcd.DrawArrow (arrowRect, Lcd.ArrowOrientation.Down, scrollPos + itemsOnScreen < items.Count);
			Lcd.Update ();
		}
예제 #23
0
		public void DrawRectangle (Rectangle r, bool color, bool fill)
		{
			if (fill) 
			{
				int length = r.P2.X - r.P1.X;
				for (int y = r.P1.Y; y <= r.P2.Y; ++y)
					DrawHLine(new Point(r.P1.X, y), length, color);
			} 
			else 
			{
				int length = r.P2.X - r.P1.X;
				int height = r.P2.Y - r.P1.Y;

				DrawHLine (new Point (r.P1.X, r.P1.Y), length, color);
				DrawHLine (new Point (r.P1.X, r.P2.Y), length, color);

				DrawVLine (new Point (r.P1.X, r.P1.Y + 1), height - 2, color);
				DrawVLine (new Point (r.P2.X, r.P1.Y + 1), height - 2, color);
			}
		}
예제 #24
0
		private void DrawScrollBar()
		{
			Lcd.DrawRectangle (scrollBar, false, true);
			Lcd.DrawRectangle (scrollBar, true, false);
			Rectangle indexRec = new Rectangle (new Point(scrollBar.P1.X + (scrollBarWidth - scrollIndexWith)/2, scrollBar.P1.Y + pagePos * indexHeight), new Point(scrollBar.P2.X - (scrollBarWidth - scrollIndexWith)/2, scrollBar.P1.Y + pagePos * indexHeight + indexHeight ) );
			Lcd.DrawRectangle (indexRec, true, true);
		}
예제 #25
0
파일: Lcd.cs 프로젝트: RoninWest/monoev3
        public void DrawArrow(Rectangle r, ArrowOrientation orientation, bool color)
        {
            int height = r.P2.Y - r.P1.Y;
            int width = r.P2.X - r.P1.X;
            float inc = 0;
            if (orientation == ArrowOrientation.Left || orientation == ArrowOrientation.Right)
            {
                inc = (((float)height) / 2.0f) / ((float)width);
            }
            else
            {
                inc = (((float)width) / 2.0f) / ((float)height);
            }
            if (orientation == ArrowOrientation.Left) {
                for (int i = 0; i < width; i++) {
                    SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height/2), color);
                    int points = (int)(inc*(float)i)+1;
                    for (int j = 0; j < points; j++) {
                        SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 +j), color);
                        SetPixel ((int)(r.P1.X + i), (int)(r.P1.Y + height / 2 -j), color);
                    }
                }
            }
            if (orientation == ArrowOrientation.Right) {
                for (int i = 0; i < width; i++) {
                    SetPixel ((int)(r.P2.X - i), (int)(r.P1.Y + height/2), color);
                    int points = (int)(inc*(float)i)+1;
                    for (int j = 0; j < points; j++) {
                        SetPixel ((int)(r.P2.X -i), (int)(r.P1.Y + height / 2 +j), color);
                        SetPixel ((int)(r.P2.X -i), (int)(r.P1.Y + height / 2 -j), color);
                    }
                }
            }
            if (orientation == ArrowOrientation.Up) {
                for (int i = 0; i < height; i++) {

                    SetPixel ((int)(r.P1.X + width/2), (int)(r.P1.Y + i), color);
                    int points = (int)(inc*(float)i)+1;
                    for (int j = 0; j < points; j++) {
                        SetPixel ((int)(r.P1.X + width/2+j), (int)(r.P1.Y + i), color);
                        SetPixel ((int)(r.P1.X + width/2-j), (int)(r.P1.Y + i), color);
                    }
                }
            }
            if (orientation == ArrowOrientation.Down) {
                for (int i = 0; i < height; i++) {

                    SetPixel ((int)(r.P1.X + width/2), (int)(r.P2.Y -i), color);
                    int points = (int)(inc*(float)i)+1;
                    for (int j = 0; j < points; j++) {
                        SetPixel ((int)(r.P1.X + width/2+j), (int)(r.P2.Y - i), color);
                        SetPixel ((int)(r.P1.X + width/2-j), (int)(r.P2.Y - i), color);
                    }
                }
            }
        }
예제 #26
0
파일: Main.cs 프로젝트: RoninWest/monoev3
        static bool ShowProgramOptions(string programFolder)
        {
            string fileName = "";
            try {
                fileName = Directory.EnumerateFiles (programFolder, "*.exe").First ();
            } catch {
                var info = new InfoDialog (programFolder + "is not executable", true, "Program");
                info.Show ();
                Directory.Delete (programFolder, true);
                updateProgramList = true;
                return true;
            }

            var dialog = new SelectDialog<string> (new string[] {
                "Run Program",
                "Debug Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);
            dialog.Show ();
            if (!dialog.EscPressed) {
                Action programAction = null;
                switch (dialog.GetSelectionIndex ()) {
                case 0:
                    Lcd.Instance.Clear ();
                    Lcd.Instance.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update ();
                    programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.Normal);
                    break;
                case 1:
                    programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.Debug);
                    break;
                case 2:
                    if (!AOTHelper.IsFileCompiled (fileName)) {
                        if (AOTCompileAndShowDialog (programFolder)) {
                            programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.AOT);
                        }
                    } else {
                        programAction = () => RunAndWaitForProgram (fileName, ExecutionMode.AOT);
                    }
                    break;
                case 3:

                    if (AOTHelper.IsFileCompiled (fileName)) {
                        var questionDialog = new QuestionDialog ("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show ()) {
                            AOTCompileAndShowDialog (programFolder);
                        }
                    } else {
                        AOTCompileAndShowDialog (programFolder);
                    }
                    break;
                case 4:
                    var question = new QuestionDialog ("Are you sure?", "Delete");
                    if (question.Show ()) {
                        var step = new StepContainer (() => {
                            Directory.Delete (programFolder, true);
                            return true;
                        }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog ("Program", step);
                        progressDialog.Show ();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine ("Done running application");
                }
                return updateProgramList;
            }
            return false;
        }
예제 #27
0
파일: Lcd.cs 프로젝트: RoninWest/monoev3
 public void WriteTextBox(Font f, Rectangle r, string text, bool color)
 {
     WriteTextBox(f, r, text, color, Alignment.Left);
 }
예제 #28
0
파일: Lcd.cs 프로젝트: tudor-olariu/monoev3
 public static void DrawRectangle(Rectangle r, bool color, bool fill)
 {
   Instance.DrawRectangle(r,color,fill);
 }
예제 #29
0
파일: Lcd.cs 프로젝트: RoninWest/monoev3
 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);
 }
예제 #30
0
파일: Main.cs 프로젝트: RoninWest/monoev3
        public static void Main(string[] args)
        {
            Lcd.Instance.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5));
            Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2));

            Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Initializing...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update ();
            WiFiDevice.TurnOff ();
            if (!Directory.Exists (ProgramPathSdCard))
                Directory.CreateDirectory (ProgramPathSdCard);

            // JIT work-around remove when JIT problem is fixed
            System.Threading.Thread.Sleep (10);
            Console.WriteLine ("JIT workaround - please remove!!!");
            Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Checking WiFi...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update ();
            //WiFiDevice.IsLinkUp ();
            Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Starting Mono Runtime...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update ();
            string monoVersion = "Unknown";
            Type type = Type.GetType ("Mono.Runtime");
            if (type != null) {
                MethodInfo displayName = type.GetMethod ("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                    monoVersion = (string)displayName.Invoke (null, null);
                Console.WriteLine ("Mono Version" + monoVersion);
            }
            string monoCLR = System.Reflection.Assembly.GetExecutingAssembly ().ImageRuntimeVersion;
            // JIT work-around end but look for more below

            //Load settings
            Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Loading settings...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update ();
            settings = settings.Load();
            if (settings != null) {
                Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Applying settings...", true, Lcd.Alignment.Center);
                Lcd.Instance.Update ();
                settings.Save();// JIT work-around
              			WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                if (settings.WiFiSettings.ConnectAtStartUp) {
                    Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Connecting to WiFi...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update ();
                    if (WiFiDevice.TurnOn (60000)) {
                        WiFiDevice.GetIpAddress ();// JIT work-around
              				if (settings.GeneralSettings.CheckForSwUpdatesAtStartUp)
              				{
                            ShowUpdatesDialogs ();
                        }
                        else
                        {
                            var dialog = new InfoDialog ("Connected Successfully " + WiFiDevice.GetIpAddress (), true);
                            dialog.Show ();
                        }
                    }
                    else
                    {
                        var dialog = new InfoDialog ("Failed to connect to WiFI Network", true);
                        dialog.Show ();
                    }
                }
            }
            else
            {
                var dialog = new InfoDialog ("Failed to load settings", true);
                dialog.Show ();
              			settings = new FirmwareSettings();
            }

            //Keep showing the menu even if user press esc
            while(true)
            {
                ShowMainMenu();
            }
        }