예제 #1
0
        public void DrawSprites(SpriteRenderer sprite, ICamera camera, Vector2 screenSize)
        {
            if (_debugText == null)
            {
                _debugText = new TextBlockRenderer(sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 16f);
            }

            if (IsColliderVisible)
            {
                _colliderLines.DrawLabels(this, camera, screenSize);
            }

            if (AreWheelsContoursVisible)
            {
                _wheelsLines.DrawLabels(this, camera, screenSize);
            }

            if (IsFuelTankVisible)
            {
                _fuelTankLines.DrawLabels(this, camera, screenSize);
            }

            if (AreFlamesVisible)
            {
                _flamesLines.DrawLabels(this, camera, screenSize);
            }

            if (AreWingsVisible)
            {
                _wingsLines.DrawLabels(this, camera, screenSize);
            }
        }
예제 #2
0
        protected virtual void DrawSpritesInner()
        {
            if (!VisibleUi)
            {
                return;
            }

            if (_textBlock == null)
            {
                _textBlock = new TextBlockRenderer(Sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 20f);
            }

            if (TrianglesCount == 0)
            {
                _textBlock.DrawString("Nothing found",
                                      new RectangleF(0, 0, Width, Height), TextAlignment.VerticalCenter | TextAlignment.HorizontalCenter, 20f,
                                      new Color4(1.0f, 1.0f, 1.0f), CoordinateType.Absolute);
            }
            else
            {
                _textBlock.DrawString($"Triangles: {TrianglesCount}\nZoom: {Zoom:F3}×\nResult image most likely will be different size",
                                      new RectangleF(8, 8, Width - 16, Height - 16), TextAlignment.Bottom | TextAlignment.Left, 12f,
                                      new Color4(1.0f, 1.0f, 1.0f), CoordinateType.Absolute);
            }
        }
예제 #3
0
        protected override void ResizeInner()
        {
            base.ResizeInner();

            if (_textBlock != null)
            {
                return;
            }
            _textBlock = new TextBlockRenderer(Sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 24f);
        }
예제 #4
0
 public TextBlockView(TextBlock textBlock, SectionView parentSection) : base(textBlock)
 {
     this.ParentSection = parentSection;
     AbsoluteBound      = new Rectangle(parentSection.AbsoluteDrawingStartPoint.X + textBlock.Location.X,
                                        parentSection.AbsoluteDrawingStartPoint.Y + textBlock.Location.Y, textBlock.Width, textBlock.Height);
     TextBlockRenderer = new TextBlockRenderer()
     {
         DesignMode = true
     };
 }
예제 #5
0
        public void Render(D2D.RenderTarget renderTarget, FrameworkElement rootElement, FrameworkElement fe)
        {
            var textBlock = fe as TextBlock;

            if (textBlock != null)
            {
                TextBlockRenderer.Render(this, renderTarget, rootElement, textBlock);
                return;
            }

            var rectangle = fe as Rectangle;

            if (rectangle != null)
            {
                RectangleRenderer.Render(this, renderTarget, rootElement, rectangle);
                return;
            }

            var border = fe as Border;

            if (border != null)
            {
                BorderRenderer.Render(this, renderTarget, rootElement, border);
                return;
            }

            var ellipse = fe as Ellipse;

            if (ellipse != null)
            {
                EllipseRenderer.Render(this, renderTarget, rootElement, ellipse);
                return;
            }

            var line = fe as Line;

            if (line != null)
            {
                LineRenderer.Render(this, renderTarget, rootElement, line);
                return;
            }

            var path = fe as Path;

            if (path != null)
            {
                PathRenderer.Render(this, renderTarget, rootElement, path);
                return;
            }

            FrameworkElementRenderer.Render(this, renderTarget, rootElement, fe);
        }
예제 #6
0
 /// <summary>
 /// Initialisiert den Sprite-Renderer zum Rendern von Bitmap Fonts.
 /// </summary>
 void InitSpriteRenderer()
 {
     if (spriteRenderer != null)
     {
         throw new InvalidOperationException("Die spriteRenderer Instanz wurde " +
                                             "bereits initialisiert.");
     }
     spriteRenderer = new SpriteRenderer(control.Device, 512);
     font           = new TextBlockRenderer(spriteRenderer, "Arial", FontWeight.Normal,
                                            SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 14);
     // Virtuelle Auflösung von 640x480 zum Positionieren von Text benutzen.
     spriteRenderer.ScreenSize = new SpriteTextRenderer.STRVector(640.0f, 480.0f);
 }
예제 #7
0
        public bool RegisterFont(string name, float fontSize, string fontFace = "Arial", FontWeight fontWeight = FontWeight.Normal, FontStyle fontStyle = FontStyle.Normal, FontStretch fontStretch = FontStretch.Normal) {
            if (_fonts.ContainsKey(name)) {
                Console.WriteLine("Duplicate font name: " + name);
                return false;
            }
            try {
                _fonts[name] = new TextBlockRenderer(_sprite, fontFace, fontWeight, fontStyle, fontStretch, fontSize);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                return false;
            }

            return true;
        }
예제 #8
0
        public void Initialize()
        {
            _spriteRenderer    = new SpriteRenderer();
            _textBlockRenderer = new TextBlockRenderer(_spriteRenderer, "Arial", SlimDX.DirectWrite.FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, SlimDX.DirectWrite.FontStretch.Normal, 16);

            RenderResourceShapes shapesResource = new RenderResourceShapes();

            shapesResource.LoadModels();
            Resources.Add(shapesResource.Name, shapesResource);

            renderThread      = new Thread(new ThreadStart(Render));
            renderThread.Name = "RenderThread";
            renderThread.Start();
        }
예제 #9
0
        public bool RegisterFont(string name, float fontSize, string fontFace = "Arial", FontWeight fontWeight = FontWeight.Normal, FontStyle fontStyle = FontStyle.Normal, FontStretch fontStretch = FontStretch.Normal)
        {
            if (_fonts.ContainsKey(name))
            {
                Console.WriteLine("Duplicate font name: " + name);
                return(false);
            }
            try {
                _fonts[name] = new TextBlockRenderer(_sprite, fontFace, fontWeight, fontStyle, fontStretch, fontSize);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
예제 #10
0
        public void BreakOffControlAtMostAtHeight_WithHeightInText_FirstControlAlwaysLowerOrEqualThanHeight()
        {
            TextBlockRenderer tbr = new TextBlockRenderer();

            using (Cairo.PdfSurface pdf = new Cairo.PdfSurface(System.IO.Path.Combine(System.Environment.CurrentDirectory, "monoreports_tmp_test.pdf"), 600, 800)) {
                var cr = new  Cairo.Context(pdf);

                TextBlock tb = new TextBlock();
                tb.Text     = loremIpsum;
                tb.Location = new Point(10, 50);
                tb.Width    = 89;
                tb.Height   = 40;

                Control[] tab = null;



                tab = tbr.BreakOffControlAtMostAtHeight(cr, tb, 120);

                Assert.LessOrEqual(tab[0].Height, 120);


                tab = tbr.BreakOffControlAtMostAtHeight(cr, tb, 330);

                Assert.LessOrEqual(tab[0].Height, 330);

                //chhamge padding

                tb.Padding = new Thickness(4, 22, 8, 8);

                tab = tbr.BreakOffControlAtMostAtHeight(cr, tb, 20);



                Assert.LessOrEqual(tab[0].Height, 20);

                tab = tbr.BreakOffControlAtMostAtHeight(cr, tb, 47);

                Assert.LessOrEqual(tab[0].Height, 47);

                pdf.Finish();
            }
        }
        public void TestRenderText()
        {
            var game = new DX11Game();

            game.InitDirectX();

            var Sprite = new SpriteRenderer(game.Device);

            Sprite.ScreenSize = new SlimDX.Vector2(800, 600);


            var myTextBlockRenderer = new TextBlockRenderer(Sprite, "Arial", FontWeight.Bold, FontStyle.Normal, FontStretch.Normal, 12);



            game.GameLoopEvent += delegate
            {
                myTextBlockRenderer.DrawString("Hello Wizard", new SlimDX.Vector2(20, 20),
                                               new SlimDX.Color4(1, 1, 1));
                Sprite.Flush();
            };
        }
예제 #12
0
 public override void Render(Context c)
 {
     TextBlockRenderer.Render(c, textBlock);
     AbsoluteBound = new Rectangle(ParentSection.AbsoluteDrawingStartPoint.X + textBlock.Location.X,
                                   ParentSection.AbsoluteDrawingStartPoint.Y + textBlock.Location.Y, textBlock.Width, textBlock.Height);
 }
예제 #13
0
 public FontCache(SpriteRenderer sprite)
 {
     _sprite  = sprite;
     _default = new TextBlockRenderer(sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 12);
 }
예제 #14
0
        void DrawBmp(SwapChain swapChain, Texture2D texture)
        {
            SpriteRenderer sprite = new SpriteRenderer(texture.Device);

            //            var srv = new ShaderResourceView(texture.Device,
            //                                             Texture2D.FromFile(texture.Device, "S:\\Downloads\font.jpg"));

            //            sprite.Draw(srv, new Vector2(30, 30), new Vector2(50, 50), CoordinateType.Absolute);

            var myTextBlockRenderer = new TextBlockRenderer(sprite, "Arial", FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 12);
            myTextBlockRenderer.DrawString("Example Text", Vector2.Zero, Color.White);

            sprite.Flush();
        }
예제 #15
0
        public async Task Render(D2D.RenderTarget renderTarget, FrameworkElement rootElement, FrameworkElement fe)
        {
            var textBlock = fe as TextBlock;

            if (textBlock != null)
            {
                await TextBlockRenderer.Render(this, renderTarget, rootElement, textBlock);

                return;
            }

            var rectangle = fe as Jupiter.Shapes.Rectangle;

            if (rectangle != null)
            {
                await RectangleRenderer.Render(this, renderTarget, rootElement, rectangle);

                return;
            }

            var border = fe as Border;

            if (border != null)
            {
                await BorderRenderer.Render(this, renderTarget, rootElement, border);

                return;
            }

            var image = fe as Image;

            if (image != null)
            {
                await ImageRenderer.Render(this, renderTarget, rootElement, image);

                return;
            }

            var ellipse = fe as Ellipse;

            if (ellipse != null)
            {
#pragma warning disable 4014
                EllipseRenderer.Render(this, renderTarget, rootElement, ellipse);
#pragma warning restore 4014
                return;
            }

            var line = fe as Line;

            if (line != null)
            {
                await LineRenderer.Render(this, renderTarget, rootElement, line);

                return;
            }

            var path = fe as Jupiter.Shapes.Path;

            if (path != null)
            {
                await PathRenderer.Render(this, renderTarget, rootElement, path);

                return;
            }

            await FrameworkElementRenderer.Render(this, renderTarget, rootElement, fe);
        }
예제 #16
0
        protected override void DrawSpritesInner()
        {
            if (!VisibleUi)
            {
                return;
            }

            if (_textBlock == null)
            {
                _textBlock = new TextBlockRenderer(Sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 24f);
            }

            _textBlock.DrawString(GetInformationString(),
                                  new Vector2(ActualWidth - 300, 20), 16f, UiColor,
                                  CoordinateType.Absolute);

            if (CarNode == null)
            {
                return;
            }

            var offset = 15;

            if (CarNode.LodsCount > 0)
            {
                var information = CarNode.CurrentLodInformation;
                _textBlock.DrawString(
                    $"LOD #{CarNode.CurrentLod + 1} ({CarNode.LodsCount} in total; shown from {information?.In.ToInvariantString() ?? "?"} to {information?.Out.ToInvariantString() ?? "?"})",
                    new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                    TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                    CoordinateType.Absolute);
                offset += 20;
            }

            var flags = new List <string>(4);

            if (CarNode.HasCockpitLr)
            {
                flags.Add(CarNode.CockpitLrActive ? "LR-cockpit" : "HR-cockpit");
            }

            if (CarNode.HasSeatbeltOn)
            {
                flags.Add(flags.Count > 0 ? ", seatbelt " : "Seatbelt ");
                flags.Add(CarNode.SeatbeltOnActive ? "is on" : "is off");
            }

            if (CarNode.HasBlurredNodes)
            {
                flags.Add(flags.Count > 0 ? ", blurred " : "Blurred ");
                flags.Add(CarNode.BlurredNodesActive ? "objects visible" : "objects hidden");
            }

            if (flags.Count > 0)
            {
                _textBlock.DrawString(flags.JoinToString(),
                                      new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                                      TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                                      CoordinateType.Absolute);
                offset += 20;
            }

            if (CarNode.Skins != null && CarNode.CurrentSkin != null)
            {
                _textBlock.DrawString($"{CarNode.CurrentSkin} ({CarNode.Skins.IndexOf(CarNode.CurrentSkin) + 1}/{CarNode.Skins.Count})",
                                      new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                                      TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                                      CoordinateType.Absolute);
            }
        }
예제 #17
0
 public FontCache(SpriteRenderer sprite) {
     _sprite = sprite;
     _default = new TextBlockRenderer(sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 12);
 }