private void SendStringToScreen(String text, CharDisplayInfo cdi)
        {

            invoke(() =>
            {
                Image myImage = new Image();

                DrawingVisual dv = new DrawingVisual();
                DrawingContext dc = dv.RenderOpen();

                double x = _cursorX;
                double y = _cursorY;

                if (lastDrawn != Rect.Empty && inInputMode == false)
                {
                    x = lastDrawn.X + lastDrawn.Width;
                }


                FontInfo fi = _regularFont;
                if (cdi.Font == 4)
                {
                    fi = _fixedFont;
                }

                FormattedText ft = buildFormattedText(text, fi, cdi, dc);

                Brush b = Brushes.Transparent;

                if (cdi.ImplementsStyle(ZStyles.REVERSE_STYLE))
                {
                    b = ZColorCheck.ZColorToBrush(cdi.ForegroundColor, ColorType.Foreground);
                }
                else
                {
                    if (_currentInfo.BackgroundColor != bColor)
                    {
                        b = ZColorCheck.ZColorToBrush(cdi.BackgroundColor, ColorType.Background);
                    }
                }
                dc.DrawRectangle(b, null, new Rect(0, 0, ft.WidthIncludingTrailingWhitespace, charHeight));

                dc.DrawText(ft, new Point(0, 0));
                dc.Close();

                RenderTargetBitmap bmp = new RenderTargetBitmap((int)dv.ContentBounds.Width, (int)charHeight, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(dv);

                myImage.Source = bmp;

                mainCanvas.Children.Add(myImage);
                myImage.SetValue(Canvas.TopProperty, y);
                myImage.SetValue(Canvas.LeftProperty, x);

                lastDrawn = new Rect(x, y, (int)dv.ContentBounds.Width, charHeight);

                removeCoveredImages(myImage);
            });
        }
Example #2
0
 private bool IsFixedWidth(CharDisplayInfo Info)
 {
     return (Info.Font == ZFont.FIXED_WIDTH_FONT || Info.ImplementsStyle(ZStyles.FIXED_WIDTH_STYLE));
 }