mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Merge pull request #638 from mnadareski/draw-squares
Add DrawSquares to BlockMap
This commit is contained in:
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user