Exemplo n.º 1
0
 public override void DrawButton(
     int x, int y,
     int width, int height,
     FontInfo fontInfo,
     int fontHeight,
     BasicColor borderColor,
     BasicColor fillColor,
     BasicColor fontColor,
     string text,
     Canvas.RoundedCornerStyle cornerStyle = RoundedCornerStyle.All)
 {
     BasicTypeSerializer.Put(Context,(byte)Command.DrawButton);
     BasicTypeSerializer.Put(Context,(ushort)x);
     BasicTypeSerializer.Put(Context,(ushort)y);
     BasicTypeSerializer.Put(Context,(ushort)width);
     BasicTypeSerializer.Put(Context,(ushort)height);
     BasicTypeSerializer.Put(Context,fontInfo.ID);
     BasicTypeSerializer.Put(Context,(ushort)fontHeight);
     BasicTypeSerializer.Put(Context,(ushort)borderColor);
     BasicTypeSerializer.Put(Context,(ushort)fillColor);
     BasicTypeSerializer.Put(Context,(ushort)fontColor);
     BasicTypeSerializer.Put(Context,text, true);
     BasicTypeSerializer.Put(Context,(ushort)cornerStyle);
 }
Exemplo n.º 2
0
 override public void DrawButton(
     int x, int y,
     int width, int height,
     FontInfo fontInfo,
     int fontHeight,
     BasicColor borderColor,
     BasicColor fillColor,
     BasicColor fontColor,
     string text,
     Canvas.RoundedCornerStyle cornerStyle = RoundedCornerStyle.All)
 {
     BasicTypeSerializer.Put(Context, (byte)Command.DrawButton);
     BasicTypeSerializer.Put(Context, (ushort)x);
     BasicTypeSerializer.Put(Context, (ushort)y);
     BasicTypeSerializer.Put(Context, (ushort)width);
     BasicTypeSerializer.Put(Context, (ushort)height);
     BasicTypeSerializer.Put(Context, fontInfo.ID);
     BasicTypeSerializer.Put(Context, (ushort)fontHeight);
     BasicTypeSerializer.Put(Context, (ushort)borderColor);
     BasicTypeSerializer.Put(Context, (ushort)fillColor);
     BasicTypeSerializer.Put(Context, (ushort)fontColor);
     BasicTypeSerializer.Put(Context, text, true);
     BasicTypeSerializer.Put(Context, (ushort)cornerStyle);
 }
Exemplo n.º 3
0
 public int GetStringWidth(FontInfo fontInfo, string text)
 {
     var width = 0;
     var startChar = fontInfo.StartChar;
     foreach (var characterToOutput in text) {
         FontCharInfo fontCharInfo = fontInfo.GetFontCharInfo(characterToOutput);
         width += fontCharInfo.WidthBits + 1;
     }
     return width;
 }
Exemplo n.º 4
0
 //  Draws a string using the supplied font
 // x: Starting x co-ordinate
 // y: Starting y co-ordinate
 // color: Color to use when rendering the font
 // fontInfo: FontInfo reference to use when drawing the string
 // str: The string to render
 // Example
 //  DrawString(0, 90,  BasicColor.BLACK, bitstreamVeraSansMono9ptFontInfo, "Vera Mono 9 (30 chars wide)");
 //  DrawString(0, 105, BasicColor.BLACK, bitstreamVeraSansMono9ptFontInfo, "123456789012345678901234567890");
 public virtual void DrawString(int x, int y, BasicColor color, FontInfo fontInfo, string text)
 {
     // set current x, y to that of requested
     var currentX = x;
     // Send individual characters
     foreach (var characterToOutput in text) {
         // We need to manually calculate width in pages since this is screwy with variable width fonts
         // var heightPages = charWidth % 8 ? charWidth / 8 : charWidth / 8 + 1;
         FontCharInfo fontCharInfo = fontInfo.GetFontCharInfo(characterToOutput);
         DrawCharBitmap(currentX, y, color, fontInfo.Data, fontCharInfo.Offset, fontCharInfo.WidthBits, fontInfo.Height);
         // next char X
         currentX += fontCharInfo.WidthBits + 1;
     }
 }
Exemplo n.º 5
0
 public virtual void DrawButton(int x, int y, int width, int height, FontInfo fontInfo, int fontHeight, BasicColor borderColor, BasicColor fillColor, BasicColor fontColor, string text, Canvas.RoundedCornerStyle cornerStyle = RoundedCornerStyle.All)
 {
     // Border
     DrawRectangleRounded(x, y, x + width, y + height, borderColor, 5, cornerStyle);
     // Fill
     DrawRectangleRounded(x + 2, y + 2, x + width - 2, y + height - 2, fillColor, 5, cornerStyle);
     // Render text
     if (text.Length != 0) {
         var textWidth = GetStringWidth(fontInfo, text);
         var xStart = x + (width / 2) - (textWidth / 2);
         var yStart = y + (height / 2) - (fontHeight / 2) + 1;
         DrawString(xStart, yStart, fontColor, fontInfo, text);
     }
 }
Exemplo n.º 6
0
 public override void DrawString(int x, int y, BasicColor color, FontInfo fontInfo, string text)
 {
     BasicTypeSerializer.Put(Context,(byte)Command.DrawString);
     BasicTypeSerializer.Put(Context,(ushort)x);
     BasicTypeSerializer.Put(Context,(ushort)y);
     BasicTypeSerializer.Put(Context,(ushort)color);
     BasicTypeSerializer.Put(Context,fontInfo.ID);
     BasicTypeSerializer.Put(Context,text, true);
 }