From 85cd9fd411a5e9b5f20a0e2d3058119369701713 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 13 Jul 2021 21:59:52 -0700 Subject: [PATCH] Add DrawSquares to BlockMap --- Aaru.Gui/Controls/BlockMap.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Aaru.Gui/Controls/BlockMap.cs b/Aaru.Gui/Controls/BlockMap.cs index 80abe0b16..fd616d69e 100644 --- a/Aaru.Gui/Controls/BlockMap.cs +++ b/Aaru.Gui/Controls/BlockMap.cs @@ -438,6 +438,28 @@ namespace Aaru.Gui.Controls } } + void DrawSquares(Color[] colors, int borderWidth, int sideLength) + { + using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null); + using var ctx = new DrawingContext(ctxi, false); + + int squareWidth = (sideLength - (2 * borderWidth)) / colors.Length; + int squareHeight = squareWidth; + int x = 0; + int y = 0; + + foreach(Color color in colors) + { + ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareHeight)); + x += squareWidth + (2 * borderWidth); + if(x >= sideLength) + { + x = 0; + y += squareHeight + (2 * borderWidth); + } + } + } + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { if(Width < 1 ||