public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize) { // Get the cell colour that is associated with the cell symbol object type aMetaData.CellBoxColor = ColourForHeapCell(aCell); // Draw actual cell SymRect boxRect = new SymRect(aPosition, aBoxSize); boxRect.HalfOffset(aPaddingSize); using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor)) { aGraphics.FillRectangle(brush, boxRect.Rectangle); } // If first box, we show the number of inwards links to the cell HeapCell.TRegion region = aMetaData.Region; if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0) { boxRect.Inflate(KShrinkSize, KShrinkSize); // Draw the fill Color lightenColor = ColourUtils.LightenMore(aMetaData.CellBoxColor); using (SolidBrush brush = new SolidBrush(lightenColor)) { aGraphics.FillRectangle(brush, boxRect.Rectangle); } lightenColor = ColourUtils.Lighten(lightenColor); using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth)) { aGraphics.DrawRectangle(borderPen, boxRect.Rectangle); } // Draw the count int count = aCell.RelationshipManager.ReferencedBy.Count; if (count == 0) { PaintBoxedText(count.ToString(), aGraphics, Color.Red, boxRect); } else { PaintBoxedTextWithLuminanceHandling(count.ToString(), aGraphics, Color.Black, boxRect); } } }
public static Color RampedColourByBoxNumber(Color aBaseline, int aBoxCount, uint aCellBaseAddress, uint aAddress) { float cellAddressOffset = (float)((aAddress - aCellBaseAddress) / 4); Color dark = ColourUtils.Darken(aBaseline, 0.30f); Color light = ColourUtils.Lighten(aBaseline, 0.30f); // This is the baseline brightness for the colour float brightnessBaseline = light.GetBrightness() - dark.GetBrightness(); // This is how much brightness we can apply to each box. float brightnessPerBox = (brightnessBaseline / aBoxCount); // This is the brightness of the target box float brightnessPercentage = brightnessPerBox * cellAddressOffset; Color ret = ColourUtils.Lighten(aBaseline, brightnessPercentage); return(ret); }
public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize) { // Get the cell colour that is associated with the cell symbol object type aMetaData.CellBoxColor = ColourForHeapCell(aCell); SymRect boxRect = new SymRect(aPosition, aBoxSize); boxRect.HalfOffset(aPaddingSize); // Draw actual cell using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor)) { aGraphics.FillRectangle(brush, boxRect.Rectangle); } HeapCell.TRegion region = aMetaData.Region; if (region == HeapCell.TRegion.EHeader && aMetaData.CellBoxIndex == 0) { // If first box, we show the number of inwards links to the cell boxRect.Inflate(KShrinkSize, KShrinkSize); // Draw the fill Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor); using (SolidBrush brush = new SolidBrush(lightenColor)) { aGraphics.FillRectangle(brush, boxRect.Rectangle); } lightenColor = ColourUtils.Lighten(lightenColor); using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth)) { aGraphics.DrawRectangle(borderPen, boxRect.Rectangle); } // Draw the count PaintBoxedTextWithLuminanceHandling(aCell.RelationshipManager.EmbeddedReferencesTo.Count.ToString(), aGraphics, Color.Black, boxRect); } else { // If we're in the payload section, then get the raw item corresponding to the address we are drawing RawItem rawItem = aMetaData.RawItem; if (rawItem != null && rawItem.Tag != null && rawItem.Tag is HeapLib.Relationships.RelationshipInfo) { RelationshipInfo relInfo = (RelationshipInfo)rawItem.Tag; // Make the box a bit smaller boxRect.Inflate(KShrinkSize, KShrinkSize); // Draw the fill Color lightenColor = ColourUtils.Lighten(aMetaData.CellBoxColor); using (SolidBrush brush = new SolidBrush(lightenColor)) { aGraphics.FillRectangle(brush, boxRect.Rectangle); } lightenColor = ColourUtils.Lighten(lightenColor); using (Pen borderPen = new Pen(lightenColor, KHeaderBoxWidth)) { aGraphics.DrawRectangle(borderPen, boxRect.Rectangle); // If it's a clean reference, then draw a diagonal line to decorate the box reference if (relInfo.IsCleanLink) { Point linePosStart = boxRect.TopLeft; linePosStart.X += KHeaderBoxLineCornerOffset; Point linePosEnd = boxRect.TopLeft; linePosEnd.Y += KHeaderBoxLineCornerOffset; // aGraphics.DrawLine(borderPen, linePosStart, linePosEnd); } } } } }
public void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize) { SymRect rect = new SymRect(aPosition, aBoxSize + aPaddingSize); // Right and bottom get darker borders Color rightAndBottomColour = ColourUtils.Darken(aMetaData.CellBoxColor, 0.15f); using (Pen rightAndBottomPen = new Pen(rightAndBottomColour)) { if (aMetaData.Borders[THeapCellBorderType.ERight]) // Draw right-hand outline { Point start = rect.TopRight; Point end = rect.BottomRight; start.Offset(-1, 0); end.Offset(-1, 0); // aGraphics.DrawLine(rightAndBottomPen, start, end); } if (aMetaData.Borders[THeapCellBorderType.EBottom]) // Draw bottom-side outline { Point start = rect.BottomLeft; Point end = rect.BottomRight; start.Offset(0, -1); end.Offset(0, -1); // aGraphics.DrawLine(rightAndBottomPen, start, end); } } // Left and Top get lighter borders Color leftAndTopColour = ColourUtils.Lighten(aMetaData.CellBoxColor, 0.15f); using (Pen leftAndTopPen = new Pen(leftAndTopColour)) { if (aMetaData.Borders[THeapCellBorderType.ELeft]) // Draw left-hand outline { Point start = rect.TopLeft; Point end = rect.BottomLeft; start.Offset(1, 0); end.Offset(1, 0); // aGraphics.DrawLine(leftAndTopPen, start, end); } if (aMetaData.Borders[THeapCellBorderType.ETop]) // Draw top-side outline { Point start = rect.TopLeft; Point end = rect.TopRight; start.Offset(0, 1); end.Offset(0, 1); // aGraphics.DrawLine(leftAndTopPen, start, end); } } // Now draw black border which will cover any over-spill from above. if (aMetaData.Borders[THeapCellBorderType.ELeft]) // Draw left-hand outline { aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.BottomLeft); } if (aMetaData.Borders[THeapCellBorderType.ERight]) // Draw right-hand outline { aGraphics.DrawLine(Pens.Black, rect.TopRight, rect.BottomRight); } if (aMetaData.Borders[THeapCellBorderType.ETop]) // Draw top-side outline { aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.TopRight); } if (aMetaData.Borders[THeapCellBorderType.EBottom]) // Draw bottom-side outline { aGraphics.DrawLine(Pens.Black, rect.BottomLeft, rect.BottomRight); } }