1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using Antmicro.Renode.UserInterface; 8 using TermSharp; 9 using TermSharp.Rows; 10 using Xwt; 11 using Xwt.Drawing; 12 13 namespace Antmicro.Renode.UI 14 { 15 public class LogoRow : MonospaceTextRow 16 { LogoRow()17 public LogoRow() : base("") 18 { 19 image = Image.FromResource("logo.png"); 20 } 21 PrepareForDrawing(ILayoutParameters parameters)22 public override double PrepareForDrawing(ILayoutParameters parameters) 23 { 24 var baseResult = base.PrepareForDrawing(parameters); 25 #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator 26 // MonoDevelop complains about comparing double to a const int, 27 // but we detect uninitialized case here, so it's ok. 28 if(LineHeight == 0) // UI has not been initalized yet 29 #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator 30 { 31 return baseResult; 32 } 33 targetImageHeight = PreferedHeightInLines * LineHeight; 34 ShellProvider.NumberOfDummyLines = PreferedHeightInLines; 35 return baseResult; 36 } 37 Draw(Context ctx, Rectangle selectedArea, SelectionDirection selectionDirection, TermSharp.SelectionMode selectionMode)38 public override void Draw(Context ctx, Rectangle selectedArea, SelectionDirection selectionDirection, TermSharp.SelectionMode selectionMode) 39 { 40 var scale = targetImageHeight / image.Height; 41 ctx.Scale(scale, scale); 42 ctx.DrawImage(image, new Point()); 43 ctx.Translate(0, -targetImageHeight); 44 base.Draw(ctx, selectedArea, selectionDirection, selectionMode); 45 } 46 47 private double targetImageHeight; 48 private readonly Image image; 49 private const int PreferedHeightInLines = 3; 50 } 51 } 52