<?xml version="1.0" encoding="utf-8"?>
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:c1c="clr-namespace:C1.WPF.C1Chart;assembly=C1.WPF.C1Chart.4" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="ChartSamples.Gallery" d:DesignWidth="529.333" d:DesignHeight="296">
    <UserControl.Resources>
        <Style TargetType="{x:Type c1c:C1Chart}">
            <Setter Property="Foreground" Value="#FFF0F8FE" />
            <Setter Property="Background" Value="#4C000F14" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="Margin" Value="0 10" />
        </Style>
        <DataTemplate x:Key="lbl">
            <Border>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="30" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="Series: " />
                    <TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Series}" HorizontalAlignment="Right"/>

                    <TextBlock Grid.Row="1" Text="Index: " />
                    <TextBlock Grid.Row="1" Grid.Column="1" FontWeight="Bold" Text="{Binding PointIndex}" HorizontalAlignment="Right"/>

                    <TextBlock Grid.Row="2" Text="Value: " />
                    <TextBlock Grid.Column="1" Grid.Row="2" FontWeight="Bold" Text="{Binding Value}" HorizontalAlignment="Right" />
                </Grid>
            </Border>
        </DataTemplate>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="chartTypes">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="c1c:ChartType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="chartPalettes">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="c1c:ColorGeneration" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <Style x:Key="sstyle" TargetType="{x:Type c1c:PlotElement}">
            <Setter Property="OpacityMask">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" SpreadMethod="Reflect">
                        <LinearGradientBrush.RelativeTransform>
                            <TransformGroup>
                                <TranslateTransform />
                                <RotateTransform />
                            </TransformGroup>
                        </LinearGradientBrush.RelativeTransform>
                        <GradientStop Color="#ff000000" Offset="0" />
                        <GradientStop Color="#ff000000" Offset="0.25" />
                        <GradientStop Color="#ff000000" Offset="0.5" />
                        <GradientStop Color="#ff000000" Offset="0.75" />
                        <GradientStop Color="#ff000000" Offset="1" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="StrokeThickness" Value="1" />
            <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TransformGroup>
                        <ScaleTransform ScaleX="0" ScaleY="0.05" />
                    </TransformGroup>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX" To="1" Duration="0:0:0.4" />
                            <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY" To="1" BeginTime="0:0:0.4" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <!--<Trigger Property="IsMouseOver" Value="true">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="OpacityMask.RelativeTransform.Children[0].X" From="0" To="1" Duration="0:0:2" RepeatBehavior="Forever" />
                                <DoubleAnimation Storyboard.TargetProperty="OpacityMask.RelativeTransform.Children[1].Angle" From="0" To="360" Duration="0:0:6" RepeatBehavior="Forever" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[0].Color" To="#b0000000" Duration="0:0:1" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[2].Color" To="#b0000000" Duration="0:0:1" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[4].Color" To="#b0000000" Duration="0:0:1" />
                                <DoubleAnimation Storyboard.TargetProperty="StrokeThickness" To="3" Duration="0:0:1" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="OpacityMask.RelativeTransform.Children[0].X" To="1" Duration="0:0:2" />
                                <DoubleAnimation Storyboard.TargetProperty="OpacityMask.RelativeTransform.Children[1].Angle" To="0" Duration="0:0:2" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[0].Color" To="#ff000000" Duration="0:0:1" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[2].Color" To="#ff000000" Duration="0:0:1" />
                                <ColorAnimation Storyboard.TargetProperty="OpacityMask.GradientStops[4].Color" To="#ff000000" Duration="0:0:1" />
                                <DoubleAnimation Storyboard.TargetProperty="StrokeThickness" Duration="0:0:1" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>-->
            </Style.Triggers>
        </Style>
        <Storyboard x:Key="anim3D">
            <DoubleAnimation Storyboard.TargetProperty="Transform.Children[0].ScaleX" From="0" To="1" Duration="0:0:0.4" />
            <DoubleAnimation Storyboard.TargetProperty="Transform.Children[0].ScaleY" From="0" To="1" Duration="0:0:0.4" />
            <DoubleAnimation Storyboard.TargetProperty="Transform.Children[0].ScaleZ" BeginTime="0:0:0.4" From="0.05" To="1" Duration="0:0:0.4" />
        </Storyboard>
        <Transform3DGroup x:Key="transform3D" x:Name="t3d">
            <ScaleTransform3D ScaleX="0.3" ScaleY="0.3" ScaleZ="1" />
        </Transform3DGroup>

        <Style x:Key="sstyle3d" TargetType="{x:Type c1c:FrameworkElement3D}">
            <Setter Property="Transform">
                <Setter.Value>
                    <Transform3DGroup>
                        <ScaleTransform3D ScaleX="0" ScaleY="0" ScaleZ="0.05" />
                    </Transform3DGroup>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="Transform" Value="{x:Null}">
                    <Trigger.ExitActions>
                        <BeginStoryboard Storyboard="{StaticResource anim3D}" />
                    </Trigger.ExitActions>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="true">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="Transform.Children[0].ScaleZ" From="1" To="1.25" BeginTime="0:0:0" Duration="0:0:0.5" DecelerationRatio="0.5" RepeatBehavior="Forever" AutoReverse="True" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetProperty="Transform.Children[0].ScaleZ" To="1" BeginTime="0:0:0" Duration="0:0:0.5" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
            <TextBlock Text="Chart Type: " VerticalAlignment="Center"/>
            <ComboBox x:Name="gallery"
                ItemsSource="{Binding Source={StaticResource chartTypes}}"
                SelectedIndex="0"
                SelectionChanged="gallery_SelectionChanged"
                Width="200"/>

            <Label VerticalAlignment="Center" Content="Palette:" />
            <ComboBox x:Name="palettes" SelectedIndex="0" IsEditable="False" Margin="5,0" Width="120" ToolTip="Change Palette" ItemsSource="{Binding Source={StaticResource chartPalettes}}" SelectionChanged="palettes_SelectionChanged"/>
        </StackPanel>


        <Border Grid.Row="1">
            <c1c:C1Chart x:Name="chart" ChartType="{Binding SelectedValue, ElementName=gallery}" Margin="10,0,0,0" Palette="Module">
                <!-- data -->
                <c1c:C1Chart.Data>
                    <c1c:ChartData >
                        <c1c:DataSeries Label="S1" Values="1,2,3,4,5" 
                            SymbolStyle="{StaticResource sstyle}"
                            ConnectionStyle="{StaticResource sstyle}"
                            PointTooltipTemplate="{StaticResource lbl}"/>
                        <c1c:DataSeries Label="S2" Values="1,4,9,4,1" 
                            SymbolStyle="{StaticResource sstyle}"
                            ConnectionStyle="{StaticResource sstyle}"
                            PointTooltipTemplate="{StaticResource lbl}"/>
                    </c1c:ChartData>
                </c1c:C1Chart.Data>
                <!-- view -->
                <c1c:C1Chart.View>
                    <c1c:ChartView>
                        <!--<c1c:ChartView.Layers>
                            <c1c:ChartPanel>
                                <c1c:ChartPanelObject Attach="DataXY"  Action="MouseMove" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="30" Height="25" DataPoint="0,0">
                                    <Border Background="Yellow">
                                        <TextBlock Text="{Binding DataPoint.Y}" />
                                    </Border>
                                </c1c:ChartPanelObject>
                            </c1c:ChartPanel>
                        </c1c:ChartView.Layers>-->
                    </c1c:ChartView>
                </c1c:C1Chart.View>
                <c1c:Legend />
            </c1c:C1Chart>
        </Border>
    </Grid>
</UserControl>