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(); } } }
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); }
public void Remove(CustomChart.ChartItem value) { base.List.Remove(value); }
public int IndexOf(CustomChart.ChartItem value) { return(base.List.IndexOf(value)); }
public bool Contains(CustomChart.ChartItem value) { return(base.List.Contains(value)); }
public int Add(CustomChart.ChartItem value) { return(base.List.Add(value)); }