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 = RampedColourByBoxNumber(ColorForCell(aCell), aMetaData.CellBoxCount, aCell.Address, aAddress);

            // Draw actual cell
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);
            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }
        }
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // We paint the cell a different shade of red, depending on it's length. The larger the heap cell,
            // then the more intense the colour. Shorter length cells are de-emphasised.
            aMetaData.CellBoxColor = RampedColourByIntensityRange(KBiggestCellColour, aCell.Length,
                                                                  iCellLengthSmallest, iCellLengthLongest);

            // Draw actual cell
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);

            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }
        }
        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. This
            // makes oldest cells very light and youngest cells very dark. We really want
            // it the other way around...
            aMetaData.CellBoxColor = CellColour(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);
            }
        }
Beispiel #4
0
        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 void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);
            aGraphics.DrawRectangle(Pens.Black, boxRect.Rectangle);

            // If we're drawing the header, we can decorate the header with an
            // additional line.
            HeapCell.TRegion region = aCell.RegionForAddress(aAddress);
            if (region == HeapCell.TRegion.EHeader)
            {
                Point linePosStart = boxRect.TopLeft;
                linePosStart.X += KHeaderBoxLineCornerOffset;
                Point linePosEnd = boxRect.TopLeft;
                linePosEnd.Y += KHeaderBoxLineCornerOffset;
                //
                aGraphics.DrawLine(Pens.Black, linePosStart, linePosEnd);
            }
        }
Beispiel #6
0
        public void PaintContent(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            // Get the cell colour to use and also the region associated with
            // the cell address.
            HeapCell.TRegion region;
            aMetaData.CellBoxColor = RampedCellFillColourByRegion(aCell, aMetaData.CellBoxCount, aAddress, out region);

            // Draw actual cell
            SymRect boxRect = new SymRect(aPosition, aBoxSize);

            boxRect.HalfOffset(aPaddingSize);

            using (SolidBrush brush = new SolidBrush(aMetaData.CellBoxColor))
            {
                aGraphics.FillRectangle(brush, boxRect.Rectangle);
            }
            using (Pen borderPen = new Pen(Color.Black))
            {
                aGraphics.DrawRectangle(borderPen, boxRect.Rectangle);
            }
        }
        public void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize)
        {
            SymRect rect = new SymRect(aPosition, aBoxSize + aPaddingSize);

            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);
            }
        }
        public void PaintSelectionBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize, THeapSelectionBorderType aType)
        {
            float   width;
            Color   color = GetBorderProperties(aType, out width);
            SymRect rect  = new SymRect(aPosition, aBoxSize + aPaddingSize);

            if (aMetaData.Borders[THeapCellBorderType.ELeft])     // Draw left-hand outline
            {
                PaintCellBorder(aGraphics, aMetaData, rect.TopLeft, rect.BottomLeft, aAddress, aCell, width, color, THeapCellBorderType.ELeft);
            }
            if (aMetaData.Borders[THeapCellBorderType.ETop])       // Draw top-side outline
            {
                PaintCellBorder(aGraphics, aMetaData, rect.TopLeft, rect.TopRight, aAddress, aCell, width, color, THeapCellBorderType.ETop);
            }
            if (aMetaData.Borders[THeapCellBorderType.ERight])       // Draw right-hand outline
            {
                PaintCellBorder(aGraphics, aMetaData, rect.TopRight, rect.BottomRight, aAddress, aCell, width, color, THeapCellBorderType.ERight);
            }
            if (aMetaData.Borders[THeapCellBorderType.EBottom])       // Draw bottom-side outline
            {
                PaintCellBorder(aGraphics, aMetaData, rect.BottomLeft, rect.BottomRight, aAddress, aCell, width, color, THeapCellBorderType.EBottom);
            }
        }
Beispiel #9
0
        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);
                        }
                    }
                }
            }
        }
        protected void PaintBoxedText(string aText, Graphics aGraphics, Color aTextColor, SymRect aRectangle)
        {
            using (StringFormat stringFormat = new StringFormat())
            {
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Center;

                for (float fontSize = KSymbolFontSizeInitial; fontSize >= KSymbolFontSizeMinimum; fontSize -= KSymbolFontSizeDecrement)
                {
                    using (System.Drawing.Font font = new Font(KSymbolFontName, fontSize, FontStyle.Bold))
                    {
                        SizeF renderSizeF = aGraphics.MeasureString(aText, font, aRectangle.Width, stringFormat);
                        Size  renderSize  = new Size((int)renderSizeF.Width, (int)renderSizeF.Height);
                        //
                        if (renderSize.Width <= aRectangle.Width && renderSize.Height <= aRectangle.Height)
                        {
                            using (SolidBrush brush = new SolidBrush(aTextColor))
                            {
                                aGraphics.DrawString(aText, font, brush, aRectangle.Rectangle, stringFormat);
                                break;
                            }
                        }
                    }
                }
            }
        }
        protected void PaintBoxedText(string aText, Graphics aGraphics, Color aTextColor)
        {
            SymRect rectangle = new SymRect(iLargestRectangleCalculator.Rectangle);

            PaintBoxedText(aText, aGraphics, aTextColor, rectangle);
        }
        protected void PaintBoxedTextWithLuminanceHandling(string aText, Graphics aGraphics, Color aBackgroundBaselineColour, SymRect aRectangle)
        {
            Color textCol = Color.Black;

            if (aBackgroundBaselineColour.GetBrightness() < 0.4)
            {
                textCol = Color.White;
            }
            //
            PaintBoxedText(aText, aGraphics, textCol, aRectangle);
        }
        protected void PaintBoxedTextWithLuminanceHandling(string aText, Graphics aGraphics, Color aBackgroundBaselineColour)
        {
            SymRect rectangle = new SymRect(iLargestRectangleCalculator.Rectangle);

            PaintBoxedTextWithLuminanceHandling(aText, aGraphics, aBackgroundBaselineColour, rectangle);
        }
Beispiel #14
0
        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);
            }
        }
Beispiel #15
0
 protected virtual void PaintBorders(HeapCellBorderInfo aBorders, Graphics aGraphics, SymRect aRect, Pen aPen)
 {
     if (aBorders[THeapCellBorderType.ELeft])
     {
         aGraphics.DrawLine(aPen, aRect.TopLeft, aRect.BottomLeft);
     }
     if (aBorders[THeapCellBorderType.ERight])
     {
         aGraphics.DrawLine(aPen, aRect.TopRight, aRect.BottomRight);
     }
     if (aBorders[THeapCellBorderType.ETop])
     {
         aGraphics.DrawLine(aPen, aRect.TopLeft, aRect.TopRight);
     }
     if (aBorders[THeapCellBorderType.EBottom])
     {
         aGraphics.DrawLine(aPen, aRect.BottomLeft, aRect.BottomRight);
     }
 }