예제 #1
0
        protected void CalculateAndDrawRectangles(Graphics oGraphics, RectangleF oTreemapRectangle, Nodes oNodes, Node oParentNode)
        {
            Debug.Assert(oGraphics != null);
            Debug.Assert(oNodes != null);
            this.AssertValid();
            Brush brush = new SolidBrush(this.m_oBackColor);

            oGraphics.FillRectangle(brush, oTreemapRectangle);
            brush.Dispose();
            ILayoutEngine oLayoutEngine = this.CreateLayoutEngine();

            this.CalculateRectangles(oNodes, oTreemapRectangle, oParentNode, this.GetTopLevelTopPaddingPx(oGraphics), this.m_iPaddingPx, this.m_iPenWidthPx, oLayoutEngine);
            ColorGradientMapper colorGradientMapper  = null;
            ColorGradientMapper colorGradientMapper2 = null;

            if (this.m_eNodeColorAlgorithm == NodeColorAlgorithm.UseColorMetric)
            {
                colorGradientMapper = new ColorGradientMapper();
                Debug.Assert(this.m_fMaxColorMetric > 0f);
                colorGradientMapper.Initialize(oGraphics, 0f, this.m_fMaxColorMetric, Color.White, this.m_oMaxColor, this.m_iDiscretePositiveColors, true);
                colorGradientMapper2 = new ColorGradientMapper();
                Debug.Assert(this.m_fMinColorMetric < 0f);
                colorGradientMapper2.Initialize(oGraphics, 0f, -this.m_fMinColorMetric, Color.White, this.m_oMinColor, this.m_iDiscreteNegativeColors, true);
            }
            PenCache penCache = new PenCache();

            penCache.Initialize(this.m_oBorderColor);
            this.DrawRectangles(oNodes, 0, oGraphics, colorGradientMapper2, colorGradientMapper, penCache);
            if (colorGradientMapper2 != null)
            {
                colorGradientMapper2.Dispose();
            }
            if (colorGradientMapper != null)
            {
                colorGradientMapper.Dispose();
            }
            penCache.Dispose();
        }
예제 #2
0
        protected void DrawRectangles(Nodes oNodes, int iNodeLevel, Graphics oGraphics, ColorGradientMapper oNegativeColorGradientMapper, ColorGradientMapper oPositiveColorGradientMapper, PenCache oPenCache)
        {
            Debug.Assert(oNodes != null);
            Debug.Assert(iNodeLevel >= 0);
            Debug.Assert(oGraphics != null);
            Debug.Assert(this.m_eNodeColorAlgorithm != NodeColorAlgorithm.UseColorMetric || oNegativeColorGradientMapper != null);
            Debug.Assert(this.m_eNodeColorAlgorithm != NodeColorAlgorithm.UseColorMetric || oPositiveColorGradientMapper != null);
            Debug.Assert(oPenCache != null);
            foreach (Node current in oNodes)
            {
                if (!current.Rectangle.IsEmpty)
                {
                    Pen   pen   = oPenCache.GetPen(current.PenWidthPx);
                    Brush brush = null;
                    bool  flag  = false;
                    switch (this.m_eNodeColorAlgorithm)
                    {
                    case NodeColorAlgorithm.UseColorMetric:
                    {
                        Debug.Assert(oNegativeColorGradientMapper != null);
                        Debug.Assert(oPositiveColorGradientMapper != null);
                        float colorMetric = current.ColorMetric;
                        if (colorMetric <= 0f)
                        {
                            brush = oNegativeColorGradientMapper.ColorMetricToBrush(-colorMetric);
                        }
                        else
                        {
                            brush = oPositiveColorGradientMapper.ColorMetricToBrush(colorMetric);
                        }
                        break;
                    }

                    case NodeColorAlgorithm.UseAbsoluteColor:
                    {
                        brush = new SolidBrush(current.AbsoluteColor);
                        flag  = true;
                        break;
                    }

                    default:
                    {
                        Debug.Assert(false);
                        break;
                    }
                    }
                    Debug.Assert(brush != null);
                    Rectangle rectangleToDraw = current.RectangleToDraw;
                    oGraphics.FillRectangle(brush, rectangleToDraw);
                    oGraphics.DrawRectangle(pen, rectangleToDraw);
                    if (flag)
                    {
                        brush.Dispose();
                        brush = null;
                    }
                    this.DrawRectangles(current.Nodes, iNodeLevel + 1, oGraphics, oNegativeColorGradientMapper, oPositiveColorGradientMapper, oPenCache);
                }
            }
        }