mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General cleanup and refactor.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Gui.Controls;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
@@ -43,8 +45,6 @@ using Avalonia.Threading;
|
||||
using Avalonia.Visuals.Media.Imaging;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Aaru.Gui.Controls;
|
||||
|
||||
// TODO: Partially fill clusters
|
||||
// TODO: React to size changes
|
||||
// TODO: Optimize block size to viewport
|
||||
@@ -385,10 +385,8 @@ public sealed class BlockMap : ItemsControl
|
||||
{
|
||||
if(e.NewValue != null &&
|
||||
!(e.NewValue is IList<(ulong, double)>))
|
||||
{
|
||||
throw new
|
||||
ArgumentException("Items must be a IList<(ulong, double)> with ulong being the block and double being the time spent reading it, or NaN for an error.");
|
||||
}
|
||||
|
||||
base.ItemsChanged(e);
|
||||
|
||||
@@ -420,13 +418,13 @@ public sealed class BlockMap : ItemsControl
|
||||
|
||||
ulong clustersPerRow = (ulong)Width / BLOCK_SIZE;
|
||||
|
||||
bool allBlocksDrawn = false;
|
||||
var allBlocksDrawn = false;
|
||||
|
||||
for(ulong y = 0; y < Height && !allBlocksDrawn; y += BLOCK_SIZE)
|
||||
{
|
||||
for(ulong x = 0; x < Width; x += BLOCK_SIZE)
|
||||
{
|
||||
ulong currentBlockValue = (y * clustersPerRow / BLOCK_SIZE) + (x / BLOCK_SIZE);
|
||||
ulong currentBlockValue = y * clustersPerRow / BLOCK_SIZE + x / BLOCK_SIZE;
|
||||
|
||||
if(currentBlockValue >= _maxBlocks ||
|
||||
currentBlockValue >= Blocks)
|
||||
@@ -446,20 +444,20 @@ public sealed class BlockMap : ItemsControl
|
||||
using IDrawingContextImpl ctxi = _bitmap.CreateDrawingContext(null);
|
||||
using var ctx = new DrawingContext(ctxi, false);
|
||||
|
||||
int squareWidth = (sideLength - (2 * borderWidth)) / colors.Length;
|
||||
int squareWidth = (sideLength - 2 * borderWidth) / colors.Length;
|
||||
int squareHeight = squareWidth;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
foreach(Color color in colors)
|
||||
{
|
||||
ctx.FillRectangle(new SolidColorBrush(color), new Rect(x, y, squareWidth, squareHeight));
|
||||
x += squareWidth + (2 * borderWidth);
|
||||
x += squareWidth + 2 * borderWidth;
|
||||
|
||||
if(x >= sideLength)
|
||||
{
|
||||
x = 0;
|
||||
y += squareHeight + (2 * borderWidth);
|
||||
y += squareHeight + 2 * borderWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user