/// <summary> /// Updates the MessageBox message and title. /// </summary> /// <param name="message">Message</param> /// <param name="title">Title</param> public void Update(string message, string title) { _msgBox.Message = message; _msgBox.Title = title; // Determine the number of lines. int width = _msgBox.Width - 20; Geom.Size size = FontManager.GetSize(_msgBox.MessageFont, message); int numLines = (int)System.Math.Ceiling((double)size.Width / width); // Set the Height based on the message size. int realHeight = _msgBox.TitlebarHeight + 10 + (numLines * _msgBox.MessageFont.Height) + 15 + 32; if (realHeight != _msgBox.Height) { _msgBox.Height = realHeight; } _msgBox.X = (Glide.LCD.Width - _msgBox.Width) / 2; _msgBox.Y = (Glide.LCD.Height - _msgBox.Height) / 2; int buttonY = _msgBox.Height - 32 - 10; for (int i = 0; i < _msgBox.NumChildren; i++) { if (_msgBox[i] is Button) { _msgBox[i].Y = buttonY; } } if (IsOpen) { _msgBox.Invalidate(); } }
public static void Start(IPlatform platform) { Platform = platform; LCD = new Size { Width = Platform.ScreenWidth, Height = Platform.ScreenHeight }; // Are we in the emulator? // if (SystemInfo.SystemID.SKU == 3) IsEmulator = true; //else // IsEmulator = false; FitToScreen = false; Keyboard = DefaultKeyboard(); MessageBoxManager = new MessageBoxManager(); // Show loading Bitmap loading = LoadBitmap("loading"); Screen.DrawImage((LCD.Width - loading.Width) / 2, (LCD.Height - loading.Height) / 2, loading, 0, 0, loading.Width, loading.Height); Screen.Flush(); }
/// <summary> /// Renders the KeyboardText on it's parent container's graphics. /// </summary> public override void Render() { if (Parent == null) return; int x = Parent.X + X; int y = Parent.Y + Y; Parent.Graphics.DrawRectangle(0, 0, x, y, Width, Height, 0, 0, Colors.Black, 0, 0, Colors.Black, 0, 0, Alpha); int i; int line = 0; string word; Size size = new Size(); string newline = String.Empty; string str; if (IsPassword) { str = String.Empty; for (i = 0; i < Text.Length; i++) { if (i < Text.Length - 1) str += '*'; else str += Text[i]; } } else { str = Text; } string[] words = str.Split(' '); for (i = 0; i < words.Length; i++) { if (line * _font.Height >= Height) break; word = words[i]; size = FontManager.GetSize(_font, newline + ((newline != "") ? " " : String.Empty) + word); if (size.Width <= Width) { newline += ((newline != "") ? " " : String.Empty) + word; } else { Parent.Graphics.DrawText(newline, _font, _color, x, y + (line * _font.Height)); newline = String.Empty; i--; line++; } } if (newline != String.Empty) Parent.Graphics.DrawText(newline, _font, _color, x, y + (line * _font.Height)); // Draw the caret Parent.Graphics.DrawLine( Colors.Gray, 2, x + size.Width + 4, y + (line * _font.Height), x + size.Width + 4, y + (line * _font.Height) + _font.Height); }