' The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236



Imports C1.Xaml.Chart

Partial Public NotInheritable Class DrillDown
    Inherits UserControl
    Private _vm As DrillDownViewModel
    Public Sub New()
        Me.InitializeComponent()
        _vm = New DrillDownViewModel()
        Me.DataContext = _vm

        AddHandler Me.Loaded, AddressOf me_Loaded

        AddHandler Me.barChart.Tapped, AddressOf Chart_Tapped

        AddHandler Me.pieChart.Tapped, AddressOf Chart_Tapped
    End Sub

    Function me_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        cbAggregate.SelectedIndex = 0
    End Function

    Private Sub Chart_Tapped(sender As Object, e As TappedRoutedEventArgs)
        Dim flexChart = TryCast(sender, FlexChartBase)
        Dim hitInfo = flexChart.HitTest(e.GetPosition(flexChart))
        If hitInfo IsNot Nothing AndAlso hitInfo.Distance < 2 Then
            _vm.DataLayer.DrillDown(hitInfo.PointIndex)
        End If
    End Sub

    Private adorner As SunburstAdorner
    Private Sub HandleSunburstRendering(sender As Object, e As RenderEventArgs)
        If adorner Is Nothing Then
            adorner = New SunburstAdorner(sunburst)
        End If
    End Sub
End Class
