public void Draw(ColorCartridge c, PointF topLeft, SizeF size) { int colorIndex = c.CurrentCount == 0 ? -1 : c.ColorIndex; if (size.Height > 16 && size.Width > 16) { // Draw frame of cartridge DrawRect(new Bgr(Color.Black), topLeft, size); size = new SizeF(size.Width - 8, size.Height - 8); topLeft = new PointF(topLeft.X + 4, topLeft.Y + 4); } if (colorIndex == -1) { // Empty cardridge DrawCross(new Bgr(Color.White), topLeft, size); } else { Color color = ColorTable.Color(colorIndex); DrawRect(new Bgr(color), topLeft, size); } }
public void Draw(Pallet pallet, PointF topLeft) { DrawRect(new Bgr(FrameColor), topLeft, pallet.Size); for (int r = 0; r < pallet.BlocksColors.Rows(); ++r) { for (int c = 0; c < pallet.BlocksColors.Cols(); ++c) { PointF p = new PointF( pallet.BlockTopLeft(r, c).X + topLeft.X, pallet.BlockTopLeft(r, c).Y + topLeft.Y ); int colorIndex = pallet.BlocksColors[r, c]; if (colorIndex < 0) { DrawCross(new Bgr(Color.Black), p, new SizeF(pallet.BlockSize, pallet.BlockSize)); } else { DrawRect(new Bgr(ColorTable.Color(colorIndex)), p, new SizeF(pallet.BlockSize, pallet.BlockSize)); } } } }