AB4D Forum

Full Version: Adding Image into TextBlockVisual3D
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Need some help inserting an image into a TextBlockVisual3D, is it possible?

thanks

Madaxe

Code:
private void DisplayPartSticker()
       {
           this._TextBlockVisual = new TextBlockVisual3D();
           this._TextBlockVisual.Position = new Point3D(-40 ,0 ,0);
           this._TextBlockVisual.PositionType = PositionTypes.TopRight;
           this._TextBlockVisual.Size = new Size(160, 120);
           this._TextBlockVisual.TextDirection = new Vector3D(1 ,0 ,0);
           this._TextBlockVisual.UpDirection = new Vector3D(0, 1, 0);
           this._TextBlockVisual.Background = Brushes.LightGray;
           this._TextBlockVisual.Foreground = Brushes.Black;
           this._TextBlockVisual.BorderBrush = Brushes.Gray;
           this._TextBlockVisual.BorderThickness = new Thickness(1);

           ScaleTransform3D ScaleTransform3D = new ScaleTransform3D();
           ScaleTransform3D.ScaleX = 5;
           ScaleTransform3D.ScaleY = 5;
           ScaleTransform3D.ScaleZ = 5;
           this._TextBlockVisual.Transform = ScaleTransform3D;

           this._TextBlockVisual.Inlines.Clear();

           // When using Inlines you can show different parts of the text with different settings.
           // TextBlockVisual.Inlines property gets access to the Inlines property of the TextBlock.
           Image LekoLabsimage = new Image();
           LekoLabsimage.Width = 50;
           LekoLabsimage.Height = 50;
           LekoLabsimage.VerticalAlignment = VerticalAlignment.Top;
           LekoLabsimage.HorizontalAlignment = HorizontalAlignment.Left;
           LekoLabsimage.Source = new BitmapImage(new Uri("./Resources/LekoLabs.png", UriKind.RelativeOrAbsolute));            

           this._TextBlockVisual.Inlines.Add(LekoLabsimage);

           // It is important to call Refresh method after setting Inlines.
           // This will measure the size of used TextBlock and update used elements and models.
           this._TextBlockVisual.Refresh();

           MainViewport.Children.Add(this._TextBlockVisual);
       }