From a6c832b744afcb26b2ba1e3a318f90ce61354138 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 5 Apr 2026 17:40:51 +0800 Subject: [PATCH] Replaces the 120-TextBlock Grid (one per pixel) with a 7-TextBlock StackPanel using Run inlines for coloring. This eliminates ~113 unnecessary composition visual nodes from the banner icon. --- MinecraftClient/Tui/MccBannerPanelBuilder.cs | 54 +++++++++----------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/MinecraftClient/Tui/MccBannerPanelBuilder.cs b/MinecraftClient/Tui/MccBannerPanelBuilder.cs index db1bc0b1..c00050fc 100644 --- a/MinecraftClient/Tui/MccBannerPanelBuilder.cs +++ b/MinecraftClient/Tui/MccBannerPanelBuilder.cs @@ -123,50 +123,44 @@ namespace MinecraftClient.Tui int cols = Pixels.GetLength(1); int textRows = Pixels.GetLength(0) / 2; - var pixelGrid = new Grid(); - for (int c = 0; c < cols; c++) - pixelGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Auto)); - for (int r = 0; r < textRows; r++) - pixelGrid.RowDefinitions.Add(new RowDefinition(1, GridUnitType.Auto)); + var panel = new StackPanel + { + Orientation = Orientation.Vertical, + Margin = new Thickness(0), + }; for (int row = 0; row < textRows; row++) { + var line = new TextBlock { Padding = new Thickness(0), Margin = new Thickness(0) }; + for (int col = 0; col < cols; col++) { var topColor = Pixels[row * 2, col]; var bottomColor = Pixels[row * 2 + 1, col]; - var cell = new TextBlock + if (row == 1 && col == 1) + { + line.Inlines!.Add(new Run(" \uff1e_") + { + Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)), + Background = new SolidColorBrush(S), + }); + col += 4; + topColor = Pixels[row * 2, col]; + bottomColor = Pixels[row * 2 + 1, col]; + } + + line.Inlines!.Add(new Run("\u2580") { - Text = "\u2580", Foreground = new SolidColorBrush(topColor), Background = new SolidColorBrush(bottomColor), - Padding = new Thickness(0), - Margin = new Thickness(0), - }; - - Grid.SetRow(cell, row); - Grid.SetColumn(cell, col); - pixelGrid.Children.Add(cell); + }); } + + panel.Children.Add(line); } - var prompt = new TextBlock - { - Text = " >_", - Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)), - Background = new SolidColorBrush(S), - Padding = new Thickness(0), - Margin = new Thickness(0), - HorizontalAlignment = HorizontalAlignment.Left, - VerticalAlignment = VerticalAlignment.Top, - }; - Grid.SetRow(prompt, 1); - Grid.SetColumn(prompt, 1); - Grid.SetColumnSpan(prompt, 4); - pixelGrid.Children.Add(prompt); - - return pixelGrid; + return panel; } #endregion