Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.Utils.Menu
Imports DevExpress.Utils
Namespace DevExpress.XtraCharts.Demos.Modules
Partial Public Class ChartDemoPie
Inherits DevExpress.XtraCharts.Demos.Modules.ChartDemoBase2D
Private WithEvents chartControl_Renamed As DevExpress.XtraCharts.ChartControl
Private WithEvents checkEditValueAsPercent As DevExpress.XtraEditors.CheckEdit
Protected Overrides ReadOnly Property ToolTipEnabled() As DefaultBoolean
Get
Return DefaultBoolean.True
End Get
End Property
Public Overrides ReadOnly Property ChartControl() As ChartControl
Get
Return chartControl_Renamed
End Get
End Property
Public Sub New()
InitializeComponent()
InitExplodeModeComboBox()
cbLabelPosition.EditValue = "Radial"
End Sub
Protected Overrides Sub InitControls()
MyBase.InitControls()
ShowLabels = True
For Each series As Series In chartControl_Renamed.Series
series.ToolTipPointPattern = "{A}: {V:0.0}M km2"
Next series
End Sub
Private Sub InitExplodeModeComboBox()
If ChartControl.Series.Count > 0 Then
cbExplodeMode.Properties.Items.AddRange(PieExplodingHelper.CreateModeList(ChartControl.Series(0).Points, True))
End If
cbExplodeMode.SelectedIndex = 0
End Sub
Private Sub checkEditValueAsPercent_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles checkEditValueAsPercent.CheckedChanged
If ChartControl.Series.Count = 0 Then
Return
End If
Dim options As PiePointOptions = TryCast(Me.chartControl_Renamed.Series(0).Label.PointOptions, PiePointOptions)
If Not options Is Nothing Then
options.PercentOptions.ValueAsPercent = Me.checkEditValueAsPercent.Checked
If Me.checkEditValueAsPercent.Checked Then
SetNumericOptions(Me.chartControl_Renamed.Series(0), NumericFormat.Percent, 0)
Else
SetNumericOptions(Me.chartControl_Renamed.Series(0), NumericFormat.FixedPoint, 1)
End If
End If
End Sub
Private Sub cbLabelPosition_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbLabelPosition.SelectedIndexChanged
If ChartControl.Series.Count = 0 Then
Return
End If
Dim label As PieSeriesLabel = TryCast(Me.chartControl_Renamed.Series(0).Label, PieSeriesLabel)
If Not label Is Nothing Then
label.Position = CType(cbLabelPosition.SelectedIndex, PieSeriesLabelPosition)
If label.Position = PieSeriesLabelPosition.Outside Or label.Position = PieSeriesLabelPosition.TwoColumns Then
label.TextColor = Color.Empty
Else
label.TextColor = Color.Black
End If
label.Antialiasing = label.Position = PieSeriesLabelPosition.Radial Or label.Position = PieSeriesLabelPosition.Tangent
End If
End Sub
Private Sub cbExplodeMode_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbExplodeMode.SelectedIndexChanged
If ChartControl.Series.Count = 0 Then
Return
End If
Dim view As PieSeriesView = TryCast(Me.chartControl_Renamed.Series(0).View, PieSeriesView)
If Not view Is Nothing Then
Dim mode As String = CStr(cbExplodeMode.SelectedItem)
PieExplodingHelper.ApplyMode(view, mode)
End If
End Sub
Private Sub chartControl_PieSeriesPointExploded(ByVal sender As Object, ByVal e As PieSeriesPointExplodedEventArgs) Handles chartControl_Renamed.PieSeriesPointExploded
If e.Dragged Then
cbExplodeMode.SelectedItem = PieExplodingHelper.Custom
End If
End Sub
Public Overrides Sub UpdateControls()
MyBase.UpdateControls()
If ChartControl.Series.Count = 0 Then
Return
End If
Dim label As PieSeriesLabel = TryCast(Me.chartControl_Renamed.Series(0).Label, PieSeriesLabel)
If Not label Is Nothing Then
cbLabelPosition.SelectedIndex = CInt(Fix(label.Position))
If TypeOf Me.chartControl_Renamed.Series(0).Label.PointOptions Is PiePointOptions Then
Me.checkEditValueAsPercent.Checked = (CType(Me.chartControl_Renamed.Series(0).Label.PointOptions, PiePointOptions)).PercentOptions.ValueAsPercent
End If
Me.cbLabelPosition.Enabled = ShowLabels
Me.labelPosition.Enabled = ShowLabels
End If
End Sub
End Class
End Namespace