public void PaintBottomCenter(string text, Font font, bool inverse = false) { int x, y = 0; Color color = inverse ? Color.Black : Color.White; FindCenter(text, font, out x, out y); bitmap.DrawText(text, font, color, x, bitmap.Height - font.Height); }
/// <summary> /// Constructs a Button with the specified caption, font, and size. /// </summary> /// <param name="caption"></param> /// <param name="font"></param> /// <param name="width"></param> /// <param name="height"></param> public Button(string caption, Font font, int width, int height) { _width = width; _height = height; _caption = caption; _font = font; }
public CalibrationWindow(Font font, string txt) { Height = SystemMetrics.ScreenHeight; Width = SystemMetrics.ScreenWidth; Visibility = Visibility.Visible; //Buttons.Focus(this); pen = new Pen(ColorUtility.ColorFromRGB(255, 0, 0), 1); Text text = new Text(); text.Font = font; text.ForeColor = Colors.Blue; text.TextContent = txt; text.TextWrap = true; text.SetMargin(0, 0, 0, SystemMetrics.ScreenHeight / 2); text.TextAlignment = TextAlignment.Center; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Child = text; CalibrationManager.PrepareCalibrationPoints(); CalibrationManager.StartCalibration(); idx = 0; Invalidate(); }
public UpDownComboBox(Font font, int width) { Width = width; Orientation = Orientation.Horizontal; HorizontalAlignment = HorizontalAlignment.Stretch; btnDown = new Button(font, " < ", null, Colors.White); btnDown.ShowBorder = true; btnDown.HorizontalAlignment = HorizontalAlignment.Left; btnDown.Clicked += new EventHandler(btnDown_Clicked); Children.Add(btnDown); text = new Text(font, ""); text.ForeColor = Color.White; text.HorizontalAlignment = HorizontalAlignment.Stretch; text.VerticalAlignment = VerticalAlignment.Center; text.TextAlignment = TextAlignment.Center; text.TextWrap = false; Children.Add(text); btnUp = new Button(font, " > ", null, Colors.White); btnUp.ShowBorder = true; btnUp.HorizontalAlignment = HorizontalAlignment.Right; btnUp.Clicked += new EventHandler(btnUp_Clicked); Children.Add(btnUp); }
public FileBrowserItem(string label, Font font) { this.font = font; Width = SystemMetrics.ScreenWidth; Height = 30; iconOffset = (Height - iconSize) / 2; selectedBrush = new SolidColorBrush(Colors.Blue); fileName = label; fileType = String.Empty; filePath = String.Empty; Text text = new Text(font, label); text.ForeColor = Color.White; text.Height = font.Height; text.Width = Width; text.VerticalAlignment = VerticalAlignment.Top; int top = (Height - font.Height) / 2; text.SetMargin(Height + iconOffset, top, 0, 0); Child = text; UpdateIcon(); }
public ButtonControl(string name, int width, int height) { Width = width; Height = height; _name = name; _font = Resources.GetFont(Resources.FontResources.small); }
public void RenderFace(Device device) { if (_device == null) _device = device; if (font == null) font = _device.NinaBFont; min = 0; AnimateIt(); }
public void PaintCentered(string text, Font Font, Color Color, int y) { int x, y1 = 0; FindCenter(text, Font, out x, out y1); bitmap.DrawText(text, Font, Color, x, y); }
public HighlightableTextListBoxItem(Font font, string content) : base() { // create and remember a text element from the given font and text content this.text = new Text(font, content); this.text.SetMargin(2); // set the margin for the text this.Child = this.text; // add as child content }
public void initialiser() { // Init LCD & Police m_lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight); m_police = Resources.GetFont(Resources.FontResources.small); m_xEcran = 0; m_yEcran = 0; }
public TextButton(string Text, int X, int Y, int Width, int Height) : base(X, Y, Width, Height) { _font = null; _text = Text; _textColor = StyleManager.CurrentStyle.ButtonEnabledTextColor; _useStyleColor = true; }
/// <summary> /// Creates new UniverseView for specified GameUniverse /// </summary> /// <param name="gameUniverse">GameUniverse to visualize</param> public UniverseView(GameUniverse gameUniverse) { this.gameUniverse = gameUniverse; // initialize display buffer _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight); fontNinaB = Resources.GetFont(Resources.FontResources.small); }
public void PaintCentered(string text, Font Font, bool inverse = false) { int x, y = 0; Color color = inverse ? Color.Black : Color.White; FindCenter(text, Font, out x, out y); bitmap.DrawText(text, Font, color, x, y); }
public void set_text(string text, Font font, Color font_colour, int margin=5) { Text text_element = new Text(font, text); text_element.Width = Width; text_element.ForeColor = font_colour; text_element.SetMargin(margin); this.Child = text_element; }
/// <summary> /// Find the center of the screen, for the given text and font /// </summary> /// <param name="text"></param> /// <param name="font"></param> /// <returns></returns> public Point FindCenter(string text, Font font) { var size = MeasureString(text, font); var center = AGENT.Center; var centerText = size/2 - 2; var X = center.X - centerText; var Y = center.Y - (font.Height/2); return new Point(X, Y); }
public Label(string Text, int X, int Y, int Width, int Height) : base(X, Y, Width, Height) { _font = null; _text = Text; _textColor = StyleManager.CurrentStyle.LabelEnabledColor; _useStyleColor = true; _autoHeight = false; }
public void FindCenter(string text, Font Font, out int x, out int y) { int size = MeasureString(text, Font); int center = bitmap.Height / 2; int centerText = size / 2 - 2; x = center - centerText; y = center - (Font.Height / 2); }
/// <summary> /// Draw text in a vertical and horizontal position /// When "align" is "Center" then "margin" is ignored. /// Also when "vAlign" is "Middle" then "vMargin" is ignored. /// </summary> /// <param name="screen"></param> /// <param name="color"></param> /// <param name="font"></param> /// <param name="inString"></param> /// <param name="align"></param> /// <param name="margin"></param> /// <param name="vAlign"></param> /// <param name="vMargin"></param> public void DrawAlignedText(Bitmap screen, Color color, Font font, string inString, HAlign align, int margin, VAlign vAlign, int vMargin) { Point p = new Point(); var stringWidth = MeasureString(inString, font); var stringHeight = 0; var textAreaLength = 0; switch (align) { case HAlign.Left: p.X = margin + 1; break; case HAlign.Center: textAreaLength = screen.Width - (margin * 2); p.X = margin + ((textAreaLength - stringWidth) / 2); break; case HAlign.Right: textAreaLength = screen.Width - margin; p.X = textAreaLength - stringWidth; break; } stringHeight = font.Height; switch (vAlign) { case VAlign.Top: p.Y = vMargin + 1; break; case VAlign.Middle: p.Y= (screen.Height / 2) - (stringHeight / 2); break; case VAlign.Bottom: p.Y = screen.Height - stringHeight - vMargin; break; } screen.DrawText(inString, font, color, p.X, p.Y); }
internal Desktop(int width, int height, GraphicsManager gm) : base(0, 0, width, height) { this.gm = gm; Name = "Desktop"; Background = new SolidColorBrush(Color.Black); font = Resources.GetFont(Resources.FontResources.CourierNew_10); }
public MainWindow() { fontRegular = Resources.GetFont(Resources.FontResources.Regular); fontCourierNew10 = Resources.GetFont(Resources.FontResources.CourierNew_10); fontTitle = Resources.GetFont(Resources.FontResources.SegoeUI_BoldItalian_32); SuspendLayout(); Demo(); ResumeLayout(); }
/// <summary> /// Measure the width that a set of text will take for a given font /// </summary> /// <param name="text"></param> /// <param name="font"></param> /// <returns></returns> public int MeasureString(string text, Font font) { if (text == null || text.Trim() == "") return 0; int size = 0; for (int i = 0; i < text.Length; i++) { size += font.CharWidth(text[i]); } return size; }
//private Thread _thread; public OledDisplayDriver(OledDisplay oledDisplay, Font fontTitle, Font fontBody, Font fontStatus) { _oledDisplay = oledDisplay; _fontTitle = fontTitle; _fontBody = fontBody; _fontStatus = fontStatus; //_thread = new Thread(DriverLoop); //_thread.Start(); }
private static int alignRight(string text, Font textFont) { int increaseLabelWidth = 0; char[] increaseCharArray = _incrementLabel.ToCharArray(0, _incrementLabel.Length); for (int letterNo = 0; letterNo < increaseCharArray.Length; letterNo++) { increaseLabelWidth += textFont.CharWidth(increaseCharArray[letterNo]); } return DISPLAY_WIDTH - increaseLabelWidth - DISPLAY_MARGIN; }
public void MakeItRain(Bitmap Display, Font Font, Color Color, int ThreadCount, int PerThreadCount) { _display = Display; _font = Font; _color = Color; for (int d = 0; d <= ThreadCount; d++) { DropMultiple(PerThreadCount); } while(drops>0) Thread.Sleep(100); }
public Display(OledDisplay display) { defaultX = 10; defaultY = 10; defaultWidth = display.Width - 2 * defaultY; defaultHeight = display.Height - 2 * defaultX; myFont = Resources.GetFont(Resources.FontResources.small); screen = display; screen.SimpleGraphics.BackgroundColor = Gadgeteer.Color.White; imageUp = Resources.GetBitmap(Resources.BitmapResources.up); imageLeft = Resources.GetBitmap(Resources.BitmapResources.left); imageRight = Resources.GetBitmap(Resources.BitmapResources.right); }
public DemoManager(int width, int height, RenderRequestEventHandler renderHandler = null) { FontRegular = Resources.GetFont(Resources.FontResources.LucidaSansUnicode_8); FontCourierNew10 = Resources.GetFont(Resources.FontResources.CourierNew_10); FontTitle = Resources.GetFont(Resources.FontResources.SegoeUI_BoldItalian_32); Bar = new ImageBrush(GetBitmap(Resources.BinaryResources.Bar, Bitmap.BitmapImageType.Bmp)); gm = new GraphicsManager(width, height); Desktop = gm.Desktop; if (renderHandler != null) gm.OnRenderRequest += renderHandler; }
static UIManager() { //if (Mainboard.NativeBitmapConverter == null) // Mainboard.NativeBitmapConverter = new Gadgeteer.Mainboard.BitmapConvertBPP(delegate(byte[] bitmapBytes, byte[] pixelBytes, GT.Mainboard.BPP bpp) // { // if (bpp != GT.Mainboard.BPP.BPP16_BGR_BE) // throw new ArgumentOutOfRangeException("bpp", "Only BPP16_BGR_LE supported"); // Util.BitmapConvertBPP(bitmapBytes, pixelBytes, Util.BPP_Type.BPP16_BGR_BE); // }); //display = new DisplayS22(1); // Usage example #1. Passing a Bitmap to the driver. //Bitmap bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.test_24b), Bitmap.BitmapImageType.Bmp); //display.Draw(bitmap); //display.SimpleGraphics.DisplayImage(bitmap, 0, 0); ////display.SimpleGraphics.BackgroundColor = GT.Color.Green; //display.SimpleGraphics.DisplayText("Igor, mi bogati!", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Red, 5, 5); //display.SimpleGraphics.DisplayText("Pivo v studiyu!", Resources.GetFont(Resources.FontResources.small), GT.Color.Red, 5, 25); ////Thread.Sleep(2000); ////display.SimpleGraphics.Clear(); //display.SimpleGraphics.DisplayEllipse(GT.Color.Blue, 120, 160, 30, 20); //Thread.Sleep(2000); //DisplayDemo(display); FontRegular = Resources.GetFont(Resources.FontResources.LucidaSansUnicode_8); FontCourierNew10 = Resources.GetFont(Resources.FontResources.CourierNew_10); FontTitle = Resources.GetFont(Resources.FontResources.SegoeUI_BoldItalian_32); gm = new GraphicsManager(320, 240); //gm = new GraphicsManager(480, 272); //gm = new GraphicsManager(800, 480); Desktop = gm.Desktop; //desktop.SuspendLayout(); ImageBrush brush = new ImageBrush(GetBitmap(Resources.BinaryResources.Background, Bitmap.BitmapImageType.Jpeg)); brush.Stretch = Stretch.Fill; Desktop.Background = brush; DebugPage = new DebugPage(); SplashPage = new SplashPage(); //desktop.ResumeLayout(); }
/// <summary> /// Constructs a Button with the specified caption and font, and /// default size. /// </summary> /// <param name="caption"></param> /// <param name="font"></param> public Button(string caption, Font font) { _caption = caption; _font = font; HorizontalAlignment = HorizontalAlignment.Left; VerticalAlignment = VerticalAlignment.Bottom; int textWidth; int textHeight; _font.ComputeExtent(_caption, out textWidth, out textHeight); _width = textWidth + _textMarginX * 2; _height = textHeight + _textMarginY * 2; }
public Calculator() { font = Resources.GetFont(Resources.FontResources.NinaB); ButtonHelper.Current.OnButtonPress += Current_OnButtonPress; BackgroundColor = Color.White; ForegroundColor = Color.Black; ButtonHeight = font.Height; ButtonWidth = font.CharWidth('8')*2; //each button has a height of 15 //we want to align from the bottom up int leftPadding = 7; Buttons = new ArrayList(); int bottom = Program.AgentSize - ButtonHeight - ButtonBorder*2; int left = leftPadding; int width = ButtonWidth + ButtonBorder; char[] map = new char[] { '0', '.', 'x', '/', '=', '1', '2', '3', '-', '=', '4', '5', '6', '+', '=', '7', '8', '9', 'C', '=' }; for (int i = 0; i <= map.Length - 1; i++) { var newButton = new CalculatorButton() { Point = new Point(left, bottom), Text = map[i].ToString() }; Buttons.Add(newButton); if (SelectedButton == null) { SelectedButton = newButton; newButton.Selected = true; } if (i == 4 || i == 9 || i == 14 || i == 19) { bottom = bottom - ButtonHeight - ButtonBorder*2; left = leftPadding; } else { left = left + (ButtonWidth + ButtonBorder + 4); } } }
public Button(int x, int y, int width, int height, Font font, string text, Color foreColor) : base(x, y, width, height) { Font = font; Text = text; ForeColor = foreColor; backgroundPressed = new SolidColorBrush(ColorUtils.ColorFromRGB(128, 255, 0)); backgroundPressed.Opacity = 170;// 70; backgroundUnpressed = new SolidColorBrush(ColorUtils.ColorFromRGB(0, 0, 0)); backgroundUnpressed.Opacity = 10; border = new Pen(Color.DarkGray, 1); }