Merge pull request #638 from mnadareski/draw-squares

Add DrawSquares to BlockMap
This commit is contained in:
2021-07-29 00:47:32 +01:00
committed by GitHub

View File

@@ -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 ||