Exemplo n.º 1
0
        private void CalcRects(PaintArgs p, PercentItemCollection items)
        {
            int height = p.Graphics.MeasureString("0", this.Font).Height;
            int width  = p.Graphics.MeasureString("0", this.Font, true).Width;

            this.m_MarginPixels         = (int)((double)p.Graphics.MeasureString("0", this.Font, true).Width *this.Margin);
            this.m_RowHeightPixels      = height;
            this.m_RowSpacingPixels     = (int)((double)height * this.RowSpacing);
            this.m_RowTotalHeightPixels = this.m_RowHeightPixels + this.m_RowSpacingPixels;
            int num  = (int)(this.TitleMargin * (double)width);
            int num2 = (int)(this.ColumnPercent.Margin * (double)width);
            int num3 = (int)(this.ColumnValue.Margin * (double)width);

            this.m_TotalHeight = this.m_RowHeightPixels * items.Count + this.m_RowSpacingPixels * (items.Count - 1);
            int width2         = 15;
            int requiredWidth  = ((IPercentLegendColumn)this.ColumnValue).GetRequiredWidth(p, this.Font, items, true);
            int requiredWidth2 = ((IPercentLegendColumn)this.ColumnPercent).GetRequiredWidth(p, this.Font, items, false);
            int num4           = 0;

            foreach (PercentItem item in items)
            {
                num4 = Math.Max(p.Graphics.MeasureString(item.Title, this.Font, true).Width, num4);
            }
            this.m_RectColorBar = new Rectangle(this.m_MarginPixels, 0, width2, height);
            this.m_RectTitle    = new Rectangle(this.m_RectColorBar.Right + num, 0, num4, height);
            this.m_RectValue    = new Rectangle(this.m_RectTitle.Right + num3, 0, requiredWidth - num3, height);
            this.m_RectPercent  = new Rectangle(this.m_RectValue.Right + num2, 0, requiredWidth2 - num2, height);
        }
Exemplo n.º 2
0
 private Size GetRequiredSize(PaintArgs p, PercentItemCollection items)
 {
     if (!this.Visible)
     {
         return(Size.Empty);
     }
     this.CalcRects(p, items);
     return(new Size(this.m_RectPercent.Right, this.m_TotalHeight));
 }
Exemplo n.º 3
0
        private int GetRequiredWidth(PaintArgs p, Font font, PercentItemCollection items, bool isValue)
        {
            if (!this.Visible)
            {
                return(0);
            }
            int num  = (int)((double)p.Graphics.MeasureString("0", font, true).Width *this.WidthMin);
            int num2 = (int)((double)p.Graphics.MeasureString("0", font, true).Width *this.Margin);

            foreach (PercentItem item in items)
            {
                string text  = (!isValue) ? this.Format.GetText(items.GetItemPercent(item) * 100.0) : this.Format.GetText(item.Value);
                int    width = p.Graphics.MeasureString(text, font, true).Width;
                if (width > num)
                {
                    num = width;
                }
            }
            return(num + num2);
        }
Exemplo n.º 4
0
 private void Draw(PaintArgs p, PercentItemCollection items, Rectangle r)
 {
     if (this.Visible)
     {
         this.CalcRects(p, items);
         int              num   = r.Top + (r.Height - this.m_TotalHeight) / 2;
         Brush            brush = p.Graphics.Brush(this.ForeColor);
         DrawStringFormat genericTypographic = DrawStringFormat.GenericTypographic;
         genericTypographic.Alignment = StringAlignment.Near;
         DrawStringFormat genericTypographic2 = DrawStringFormat.GenericTypographic;
         genericTypographic2.Alignment = StringAlignment.Far;
         DrawStringFormat genericTypographic3 = DrawStringFormat.GenericTypographic;
         genericTypographic3.Alignment = StringAlignment.Far;
         this.m_RectColorBar.X         = r.Left + this.m_RectColorBar.Left;
         this.m_RectTitle.X            = r.Left + this.m_RectTitle.Left;
         this.m_RectValue.X            = r.Left + this.m_RectValue.Left;
         this.m_RectPercent.X          = r.Left + this.m_RectPercent.Left;
         foreach (PercentItem item in items)
         {
             this.m_RectColorBar.Y = num;
             this.m_RectTitle.Y    = num;
             this.m_RectValue.Y    = num;
             this.m_RectPercent.Y  = num;
             string text  = this.ColumnValue.Format.GetText(item.Value);
             string text2 = this.ColumnPercent.Format.GetText(items.GetItemPercent(item) * 100.0);
             p.Graphics.FillRectangle(new SolidBrush(item.Color), this.m_RectColorBar);
             p.Graphics.DrawString(item.Title, this.Font, brush, this.m_RectTitle, genericTypographic);
             if (this.ColumnValue.Visible)
             {
                 p.Graphics.DrawString(text, this.Font, brush, this.m_RectValue, genericTypographic2);
             }
             if (this.ColumnPercent.Visible)
             {
                 p.Graphics.DrawString(text2, this.Font, brush, this.m_RectPercent, genericTypographic3);
             }
             num += this.m_RowTotalHeightPixels;
         }
     }
 }
Exemplo n.º 5
0
 void IPercentLegend.Draw(PaintArgs p, PercentItemCollection items, Rectangle r)
 {
     this.Draw(p, items, r);
 }
Exemplo n.º 6
0
 Size IPercentLegend.GetRequiredSize(PaintArgs p, PercentItemCollection items)
 {
     return(this.GetRequiredSize(p, items));
 }
Exemplo n.º 7
0
 int IPercentLegendColumn.GetRequiredWidth(PaintArgs p, Font font, PercentItemCollection items, bool isValue)
 {
     return(this.GetRequiredWidth(p, font, items, isValue));
 }