private void canvas_Paint(object sender, PaintEventArgs e)
{
Graphics graphics = e.Graphics;
int cellSizeZoomed = (int)Math.Round(kCellSize * mZoom);
int maxCols = Math.Min(mMaxNetWorth, kMaxRows);
int maxRows = Math.Min(mItemCount, kMaxRows);
int canvasWidth = maxCols * (cellSizeZoomed + 1);
int canvasHeightLimit = maxRows * (cellSizeZoomed + 1);
int canvasHeight = (maxRows * (cellSizeZoomed + 1)) + kBottomOffset;
canvas.Width = canvasWidth;
canvas.Height = canvasHeight;
for (int i = 0; i < maxCols; ++i)
{
if (mZoom > 0.25f || (mZoom == 0.25f && ((i + 1) % 10) == 0))
{
string colName = "" + (i + 1);
Point position = new Point(i * cellSizeZoomed, canvasHeight - kStringOffset);
graphics.DrawString(colName, SystemFonts.DefaultFont, Brushes.Black, position);
}
else
{
}
List<JsonFileData> list;
if (mNetWorthValues.TryGetValue(i + 1, out list))
{
int count = Math.Min(maxRows, list.Count);
for (int j = 0; j < count; j++)
{
JsonFileData data = list[j];
string imageFile = FindImageForFile(data);
if (string.IsNullOrEmpty(imageFile))
{
Console.WriteLine("file " + data.FileName + " has no icon!");
}
else
{
Image thumbnail = ThumbnailCache.GetThumbnail(imageFile);
int ylocation = canvasHeight - ((j + 1) * cellSizeZoomed) - maxRows - kBottomOffset - 1;
Rectangle location = new Rectangle(i * cellSizeZoomed, ylocation, cellSizeZoomed, cellSizeZoomed);
graphics.DrawImage(thumbnail, location);
if (data.RecommendedMaxNetWorth > 0)
{
int cost = i + 1;
bool shouldWarn = false;
JToken sellable = data.Json.SelectToken("entity_data.stonehearth:net_worth.shop_info.sellable");
if (sellable != null && sellable.ToString() == "False")
{
shouldWarn = true;
}
if (cost < data.RecommendedMinNetWorth * kMinRecommendedMultiplier)
{
shouldWarn = true;
}
if (cost > ((data.RecommendedMaxNetWorth * kMaxRecommendedMultiplier) + 1))
{
shouldWarn = true;
}
if (shouldWarn)
{
Pen semiRed = new Pen(Color.FromArgb(100, Color.Red));
graphics.FillRectangle(semiRed.Brush, location);
}
}
}
}
}
}
for (int i = 0; i < canvasWidth; i += cellSizeZoomed)
{
graphics.DrawLine(System.Drawing.Pens.Black, new Point(i, 0), new Point(i, canvasHeightLimit));
}
for (int j = 0; j < canvasHeightLimit; j += cellSizeZoomed)
{
graphics.DrawLine(System.Drawing.Pens.Black, new Point(0, j), new Point(canvasWidth, j));
}
}