/// <summary> /// Sets values for the chart and draws them. /// </summary> /// <param name="graphics"> /// Graphics object used for drawing. /// </param> protected void DoDraw(Graphics graphics) { if (m_values != null && m_values.Length > 0) { graphics.SmoothingMode = SmoothingMode.AntiAlias; float width = ClientSize.Width - m_leftMargin - m_rightMargin; float height = ClientSize.Height - m_topMargin - m_bottomMargin; // if the width or height if <=0 an exception would be thrown -> exit method.. if (width <= 0 || height <= 0) { return; } if (m_pieChart != null) { m_pieChart.Dispose(); } if (m_colors != null && m_colors.Length > 0) { m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_values, m_colors, m_sliceRelativeHeight, m_texts); } else { m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_values, m_sliceRelativeHeight, m_texts); } m_pieChart.FitToBoundingRectangle = m_fitChart; m_pieChart.InitialAngle = m_initialAngle; // if(m_pieChart.HighlightedIndex>=0) // m_relativeSliceDisplacements[m_pieChart.HighlightedIndex]-=1; // if(m_highlightedIndex>=0) // m_relativeSliceDisplacements[m_highlightedIndex]+=1; m_pieChart.SliceRelativeDisplacements = m_relativeSliceDisplacements; m_pieChart.EdgeColorType = m_edgeColorType; m_pieChart.EdgeLineWidth = m_edgeLineWidth; m_pieChart.ShadowStyle = m_shadowStyle; m_pieChart.HighlightedIndex = m_highlightedIndex; m_pieChart.Draw(graphics); m_pieChart.Font = this.Font; m_pieChart.ForeColor = this.ForeColor; m_pieChart.PlaceTexts(graphics); } }
private void m_buttonPrint_Click(object sender, System.EventArgs e) { m_printDialog = new PrintDialog(); PrintDocument pd = new PrintDocument(); m_printDialog.Document = pd; if (m_printDialog.ShowDialog(this) == DialogResult.OK) { pd.PrinterSettings = m_printDialog.PrinterSettings; PieChart3D pieChart = new PieChart3D(100, 100, 400, 300, Values, (float)numericUpDownPieHeight.Value); pieChart.Colors = Colors; pieChart.SliceRelativeDisplacements = Displacements; pieChart.InitialAngle = (float)numericUpDownAngle.Value; pieChart.Texts = Texts; pieChart.Font = new Font("Arial", 10F); pieChart.ForeColor = SystemColors.WindowText; PrintChart pc = new PrintChart(pieChart); pc.DoPrint(pd); } }
/// <summary> /// Sets values for the chart and draws them. /// </summary> /// <param name="graphics"> /// Graphics object used for drawing. /// </param> protected void DoDraw(Graphics graphics) { if (m_values != null && m_values.Length > 0) { graphics.SmoothingMode = SmoothingMode.AntiAlias; float width = ClientSize.Width - m_leftMargin - m_rightMargin; float height = ClientSize.Height - m_topMargin - m_bottomMargin; // if the width or height if <=0 an exception would be thrown -> exit method.. if (width <= 0 || height <= 0) return; if (m_pieChart != null) m_pieChart.Dispose(); if (m_colors != null && m_colors.Length > 0) m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_values, m_colors, m_sliceRelativeHeight); else m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_values, m_sliceRelativeHeight); m_pieChart.FitToBoundingRectangle = m_fitChart; m_pieChart.InitialAngle = m_initialAngle; m_pieChart.SliceRelativeDisplacements = m_relativeSliceDisplacements; m_pieChart.EdgeColorType = m_edgeColorType; m_pieChart.EdgeLineWidth = m_edgeLineWidth; m_pieChart.ShadowStyle = m_shadowStyle; m_pieChart.HighlightedIndex = m_highlightedIndex; m_pieChart.Draw(graphics); } }
public PrintChart(PieChart3D pieChart) { m_pieChart = pieChart; }