override public 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);
 }
 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);
 }
Example #3
0
 public static void RenderCompoundShapes(Canvas canvas, FontInfo fontInfo) {
     canvas.DrawProgressBar(
         70, 140, 
         75, 12,
         Canvas.RoundedCornerStyle.None,
         Canvas.RoundedCornerStyle.None, 
         BasicColor.Black,
         (BasicColor)GrayScaleValues.Gray_128,
         (BasicColor)GrayScaleValues.Gray_30,
         BasicColor.Green,
         78);
     canvas.DrawString(5, 144, BasicColor.Black, fontInfo, "Progress");
     canvas.DrawString(155, 144, BasicColor.Black, fontInfo, "78%");
     canvas.DrawRectangleFilled(0, 275, 239, 319, (BasicColor)GrayScaleValues.Gray_80);
     canvas.DrawButton(
         20, 285, 
         200, 25, 
         fontInfo, 
         7,
         BasicColor.Black,
         BasicColor.Green,
         BasicColor.Black,
         "Click For Text Entry"
         );
 }
Example #4
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;
 }
Example #5
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");
 virtual public 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;
     }
 }
Example #6
0
 virtual 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) {
     // 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);
     }
 }