/// <summary> /// Sets values for the chart and draws them. /// </summary> /// <param name="graphics">Graphics object used for drawing.</param> private void DoDraw(Graphics graphics) { if (m_drawValues == null || m_drawValues.Length <= 0) { return; } 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; } PieChart?.Dispose(); if (m_drawColors != null && m_drawColors.Length > 0) { PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_drawColors, m_sliceRelativeHeight, m_drawTexts); } else { PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_sliceRelativeHeight, m_drawTexts); } PieChart.FitToBoundingRectangle(m_fitChart); PieChart.InitialAngle(m_initialAngle); PieChart.SliceRelativeDisplacements(m_drawRelativeSliceDisplacements); PieChart.ColorTypeOfEdge(m_edgeColorType); PieChart.EdgeLineWidth(m_edgeLineWidth); PieChart.StyleOfShadow(m_shadowStyle); PieChart.HighlightedIndex(m_highlightedIndex); PieChart.Draw(graphics); PieChart.Font(Font); PieChart.ForeColor(ForeColor); PieChart.PlaceTexts(graphics); }
/// <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_drawValues != null && m_drawValues.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_drawColors != null && m_drawColors.Length > 0) { m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_drawColors, m_sliceRelativeHeight, m_drawTexts); } else { m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_sliceRelativeHeight, m_drawTexts); } m_pieChart.FitToBoundingRectangle = m_fitChart; m_pieChart.InitialAngle = m_initialAngle; m_pieChart.SliceRelativeDisplacements = m_drawRelativeSliceDisplacements; 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); } }
/// <summary> /// When the user double click the control, we allow him to change the clicked group's color /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skillPieChartControl_DoubleClick(object sender, EventArgs e) { // Retrieve the clicked segment MouseEventArgs ev = (MouseEventArgs)e; PieChart3D pieChart3D = skillPieChartControl.PieChart; int index = pieChart3D.FindPieSliceUnderPoint(new PointF(ev.X, ev.Y)); // If none clicked, we return. Otherwise we open the color picker. if (index == -1) { return; } if (m_colorDialog.ShowDialog() != DialogResult.OK) { return; } // The user picked a new color, we update our colors list. if (sortBySizeCheck.Checked) { int realIndex = skillPieChartControl.GetIndex(index); Color[] colors = skillPieChartControl.Colors.ToArray(); colors[realIndex] = Color.FromArgb(Alpha, m_colorDialog.Color); skillPieChartControl.Colors = colors; } else { Color[] colors = skillPieChartControl.Colors.ToArray(); colors[index] = Color.FromArgb(Alpha, m_colorDialog.Color); skillPieChartControl.Colors = colors; } // Forces an update of the control skillPieChartControl.OrderSlices(sortBySizeCheck.Checked); }
/// <summary> /// Sets values for the chart and draws them. /// </summary> /// <param name="graphics">Graphics object used for drawing.</param> private void DoDraw(Graphics graphics) { if (m_drawValues == null || m_drawValues.Length <= 0) return; 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; PieChart?.Dispose(); if (m_drawColors != null && m_drawColors.Length > 0) { PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_drawColors, m_sliceRelativeHeight, m_drawTexts); } else { PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_sliceRelativeHeight, m_drawTexts); } PieChart.FitToBoundingRectangle(m_fitChart); PieChart.InitialAngle(m_initialAngle); PieChart.SliceRelativeDisplacements(m_drawRelativeSliceDisplacements); PieChart.ColorTypeOfEdge(m_edgeColorType); PieChart.EdgeLineWidth(m_edgeLineWidth); PieChart.StyleOfShadow(m_shadowStyle); PieChart.HighlightedIndex(m_highlightedIndex); PieChart.Draw(graphics); PieChart.Font(Font); PieChart.ForeColor(ForeColor); PieChart.PlaceTexts(graphics); }
/// <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_drawValues != null && m_drawValues.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_drawColors != null && m_drawColors.Length > 0) m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_drawColors, m_sliceRelativeHeight, m_drawTexts); else m_pieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_sliceRelativeHeight, m_drawTexts); m_pieChart.FitToBoundingRectangle = m_fitChart; m_pieChart.InitialAngle = m_initialAngle; m_pieChart.SliceRelativeDisplacements = m_drawRelativeSliceDisplacements; 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); } }