コード例 #1
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);
        }
コード例 #2
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;
         }
     }
 }