예제 #1
0
파일: Legend.cs 프로젝트: qingqibing/aa
        private Size SizeItem(int offset, ILegendItem item, Graphics g)
        {
            if (item == null)
            {
                return(new Size(0, 0));
            }
            int width  = offset + 30 + (int)g.MeasureString(item.LegendText, Font).Width;
            int height = ItemHeight;

            if (item.LegendSymbolMode == SymbolMode.Symbol)
            {
                Size s = item.GetLegendSymbolSize();
                if (s.Height > ItemHeight)
                {
                    height = s.Height;
                }
            }

            if (item.IsExpanded)
            {
                if (item.LegendItems != null)
                {
                    foreach (ILegendItem child in item.LegendItems)
                    {
                        Size cs = SizeItem(offset + _indentation, child, g);
                        height += cs.Height;
                        if (cs.Width > width)
                        {
                            width = cs.Width;
                        }
                    }
                }
            }
            return(new Size(width, height));
        }
예제 #2
0
        /// <summary>
        /// Draw the symbol for a particular item.
        /// </summary>
        /// <param name="g">Graphics object used for drawing.</param>
        /// <param name="topLeft">TopLeft position where the symbol should be drawn.</param>
        /// <param name="itemBox">LegendBox of the item, the symbol should be added to.</param>
        private void DrawSymbol(Graphics g, ref PointF topLeft, LegendBox itemBox)
        {
            ILegendItem item = itemBox.Item;

            // Align symbols so that their right side is about 20 pixels left
            // of the top-left X, but allow up to 128x128 sized symbols
            Size s = item.GetLegendSymbolSize();
            int  h = s.Height;

            if (h < 1)
            {
                h = 1;
            }
            if (h > 128)
            {
                h = 128;
            }
            int w = s.Width;

            if (w < 1)
            {
                w = 1;
            }
            if (w > 128)
            {
                w = 128;
            }

            int tH = ItemHeight;
            int x  = (int)topLeft.X + tH - w;
            int y  = (int)topLeft.Y;

            if (tH > h)
            {
                y += (tH - h) / 2;
            }
            Rectangle box = new Rectangle(x, y, w, h);

            itemBox.SymbolBox = box;
            item.LegendSymbolPainted(g, box);
            topLeft.X += tH + 6;
        }
예제 #3
0
 private Size SizeItem(int offset, ILegendItem item, Graphics g)
 {
     if (item == null) return new Size(0, 0);
     int width = offset + 30 + (int)g.MeasureString(item.LegendText, Font).Width;
     int height = ItemHeight;
     if(item.LegendSymbolMode == SymbolModes.Symbol)
     {
         Size s = item.GetLegendSymbolSize();
         if (s.Height > ItemHeight) height = s.Height;
     }
    
     if (item.IsExpanded)
     {
         if (item.LegendItems != null)
         {
             foreach (ILegendItem child in item.LegendItems)
             {
                 Size cs = SizeItem(offset + _indentation, child, g);
                 height += cs.Height;
                 if (cs.Width > width) width = cs.Width;
             }
         }
     }
     return new Size(width, height);
 }