Пример #1
0
            private void DrawLegend(Graphics graph)
            {
                Font         font         = null;
                SolidBrush   solidBrush   = null;
                StringFormat stringFormat = null;
                Pen          pen          = null;

                try
                {
                    font                   = new Font(this._fontFamily, 9f);
                    solidBrush             = new SolidBrush(this._fontColor);
                    stringFormat           = new StringFormat();
                    pen                    = new Pen(this._fontColor);
                    stringFormat.Alignment = StringAlignment.Near;
                    float num     = this._xOrigin + this._graphWidth + 6f;
                    float yOrigin = this._yOrigin;
                    float num2    = num + 5f;
                    float x       = num2 + 10f + 5f;
                    float num3    = 0f;
                    int   num4    = 0;
                    for (int i = 0; i < base.DataPoints.Count; i++)
                    {
                        CustomChart.ChartItem chartItem = base.DataPoints[i];
                        string s = chartItem.Description + "(" + chartItem.Label + ")";
                        num3 += (float)font.Height + 5f;
                        float num5 = yOrigin + 5f + (float)(i - num4) * ((float)font.Height + 5f);
                        graph.DrawString(s, font, solidBrush, x, num5, stringFormat);
                        graph.FillRectangle(new SolidBrush(base.DataPoints[i].ItemColor), num2, num5 + 3f, 10f, 10f);
                    }
                    graph.DrawRectangle(pen, num, yOrigin, this._legendWidth, num3 + 5f);
                }
                finally
                {
                    if (font != null)
                    {
                        font.Dispose();
                    }
                    if (solidBrush != null)
                    {
                        solidBrush.Dispose();
                    }
                    if (stringFormat != null)
                    {
                        stringFormat.Dispose();
                    }
                    if (pen != null)
                    {
                        pen.Dispose();
                    }
                }
            }
Пример #2
0
            void DrawLegend(Graphics graph)
            {
                Font         font   = null;
                SolidBrush   brush  = null;
                StringFormat format = null;
                Pen          pen    = null;

                try
                {
                    font             = new Font(_fontFamily, 9f);
                    brush            = new SolidBrush(_fontColor);
                    format           = new StringFormat();
                    pen              = new Pen(_fontColor);
                    format.Alignment = StringAlignment.Near;
                    float x    = (_xOrigin + _graphWidth) + 6f;
                    float y    = _yOrigin;
                    float num3 = x + 5f;
                    float num4 = (num3 + 10f) + 5f;
                    float num5 = 0f;
                    int   num6 = 0;
                    for (int i = 0; i < base.DataPoints.Count; i++)
                    {
                        CustomChart.ChartItem item = base.DataPoints[i];
                        string s = item.Description + "(" + item.Label + ")";
                        num5 += font.Height + 5f;
                        float num8 = (y + 5f) + ((i - num6) * (font.Height + 5f));
                        graph.DrawString(s, font, brush, num4, num8, format);
                        graph.FillRectangle(new SolidBrush(base.DataPoints[i].ItemColor), num3, num8 + 3f, 10f, 10f);
                    }
                    graph.DrawRectangle(pen, x, y, _legendWidth, num5 + 5f);
                }
                finally
                {
                    if (font != null)
                    {
                        font.Dispose();
                    }
                    if (brush != null)
                    {
                        brush.Dispose();
                    }
                    if (format != null)
                    {
                        format.Dispose();
                    }
                    if (pen != null)
                    {
                        pen.Dispose();
                    }
                }
            }
Пример #3
0
            public override Bitmap Draw()
            {
                int          width    = _perimeter;
                Rectangle    rect     = new Rectangle(0, 0, width, width - 1);
                Bitmap       image    = new Bitmap(width + _legendWidth, width);
                Graphics     graphics = null;
                StringFormat format   = null;
                SolidBrush   brush    = null;

                try
                {
                    graphics = Graphics.FromImage(image);
                    format   = new StringFormat();
                    graphics.FillRectangle(new SolidBrush(_backgroundColor), 0, 0, width + _legendWidth, width);
                    format.Alignment = StringAlignment.Far;
                    for (int i = 0; i < _chartItems.Count; i++)
                    {
                        CustomChart.ChartItem item = (CustomChart.ChartItem)_chartItems[i];
                        using ((SolidBrush)(brush = null))
                        {
                            brush = new SolidBrush(item.ItemColor);
                            graphics.FillPie(brush, rect, item.StartPos, item.SweepSize);
                            graphics.FillRectangle(brush, width + 0x7d, (i * _legendFontHeight) + 15, 10, 10);
                            graphics.DrawString(item.Label, new Font(_legendFontStyle, _legendFontSize), new SolidBrush(Color.Black), (float)((width + 0x7d) + 20), (float)((i * _legendFontHeight) + 13));
                            graphics.DrawString(item.Value.ToString("C"), new Font(_legendFontStyle, _legendFontSize), new SolidBrush(Color.Black), (float)((width + 0x7d) + 200), (float)((i * _legendFontHeight) + 13), format);
                        }
                    }
                    graphics.DrawEllipse(new Pen(_borderColor, 2f), rect);
                    graphics.DrawRectangle(new Pen(_borderColor, 1f), (width + 0x7d) - 10, 10, 220, (_chartItems.Count * _legendFontHeight) + 0x19);
                    graphics.DrawString("Total", new Font(_legendFontStyle, _legendFontSize, FontStyle.Bold), new SolidBrush(Color.Black), (float)((width + 0x7d) + 30), (float)((_chartItems.Count + 1) * _legendFontHeight), format);
                    graphics.DrawString(_total.ToString("C"), new Font(_legendFontStyle, _legendFontSize, FontStyle.Bold), new SolidBrush(Color.Black), (float)((width + 0x7d) + 200), (float)((_chartItems.Count + 1) * _legendFontHeight), format);
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
                finally
                {
                    if (format != null)
                    {
                        format.Dispose();
                    }
                    if (graphics != null)
                    {
                        graphics.Dispose();
                    }
                }
                return(image);
            }
Пример #4
0
            public override Bitmap Draw()
            {
                int          perimeter    = this._perimeter;
                Rectangle    rect         = new Rectangle(0, 0, perimeter, perimeter - 1);
                Bitmap       bitmap       = new Bitmap(perimeter + this._legendWidth, perimeter);
                Graphics     graphics     = null;
                StringFormat stringFormat = null;

                try
                {
                    graphics     = Graphics.FromImage(bitmap);
                    stringFormat = new StringFormat();
                    graphics.FillRectangle(new SolidBrush(this._backgroundColor), 0, 0, perimeter + this._legendWidth, perimeter);
                    stringFormat.Alignment = StringAlignment.Far;
                    for (int i = 0; i < this._chartItems.Count; i++)
                    {
                        CustomChart.ChartItem chartItem = (CustomChart.ChartItem) this._chartItems[i];
                        using (null)
                        {
                            SolidBrush brush = new SolidBrush(chartItem.ItemColor);
                            graphics.FillPie(brush, rect, chartItem.StartPos, chartItem.SweepSize);
                            graphics.FillRectangle(brush, perimeter + 125, i * this._legendFontHeight + 15, 10, 10);
                            graphics.DrawString(chartItem.Label, new Font(this._legendFontStyle, this._legendFontSize), new SolidBrush(Color.Black), (float)(perimeter + 125 + 20), (float)(i * this._legendFontHeight + 13));
                            graphics.DrawString(chartItem.Value.ToString("C"), new Font(this._legendFontStyle, this._legendFontSize), new SolidBrush(Color.Black), (float)(perimeter + 125 + 200), (float)(i * this._legendFontHeight + 13), stringFormat);
                        }
                    }
                    graphics.DrawEllipse(new Pen(this._borderColor, 2f), rect);
                    graphics.DrawRectangle(new Pen(this._borderColor, 1f), perimeter + 125 - 10, 10, 220, this._chartItems.Count * this._legendFontHeight + 25);
                    graphics.DrawString("Total", new Font(this._legendFontStyle, this._legendFontSize, FontStyle.Bold), new SolidBrush(Color.Black), (float)(perimeter + 125 + 30), (float)((this._chartItems.Count + 1) * this._legendFontHeight), stringFormat);
                    graphics.DrawString(this._total.ToString("C"), new Font(this._legendFontStyle, this._legendFontSize, FontStyle.Bold), new SolidBrush(Color.Black), (float)(perimeter + 125 + 200), (float)((this._chartItems.Count + 1) * this._legendFontHeight), stringFormat);
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                }
                finally
                {
                    if (stringFormat != null)
                    {
                        stringFormat.Dispose();
                    }
                    if (graphics != null)
                    {
                        graphics.Dispose();
                    }
                }
                return(bitmap);
            }
Пример #5
0
 public void Remove(CustomChart.ChartItem value)
 {
     base.List.Remove(value);
 }
Пример #6
0
 public int IndexOf(CustomChart.ChartItem value)
 {
     return(base.List.IndexOf(value));
 }
Пример #7
0
 public bool Contains(CustomChart.ChartItem value)
 {
     return(base.List.Contains(value));
 }
Пример #8
0
 public int Add(CustomChart.ChartItem value)
 {
     return(base.List.Add(value));
 }