<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="ChartSamples.Financial" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1c="clr-namespace:C1.WPF.C1Chart;assembly=C1.WPF.C1Chart.4" xmlns:local="clr-namespace:ChartSamples">
    <UserControl.Resources>
    	<Style TargetType="c1c:C1Chart">
	    	<Setter Property="Foreground" Value="#666666" />
			<Setter Property="CustomPalette">
				<Setter.Value>
					<ResourceDictionary>
						<SolidColorBrush x:Key="0" Color="#16ABA9" />
						<SolidColorBrush x:Key="1" Color="#EB7A2A" />
						<SolidColorBrush x:Key="2" Color="#F2CA04" />
						<SolidColorBrush x:Key="3" Color="#DC5B20" />
						<SolidColorBrush x:Key="4" Color="#8EBC00" />
						<SolidColorBrush x:Key="5" Color="#25A0DA" />
						<SolidColorBrush x:Key="6" Color="#25A0DA" />
						<SolidColorBrush x:Key="7" Color="#309B46" />
						<SolidColorBrush x:Key="8" Color="#24C6D2" />
						<SolidColorBrush x:Key="9" Color="#8A8065" />
					</ResourceDictionary>
				</Setter.Value>
			</Setter>	       	
        </Style>
        <Style x:Key="sstyle" TargetType="{x:Type Shape}">
            <Setter Property="StrokeThickness" Value="3" />
            <Setter Property="RenderTransformOrigin" Value="0.5,1" />
            <Setter Property="RenderTransform">
                <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="0" />
                </Setter.Value>
            </Setter>
        </Style>
        
        <DataTemplate x:Key="area">
        <c1c:Area Style="{StaticResource sstyle}" Loaded="Bar_Loaded">
        </c1c:Area>
        </DataTemplate>

        <DataTemplate x:Key="emptyDot">
            <c1c:DotSymbol Fill="Transparent" Stroke="Transparent" Size="15,15">
                <FrameworkElement.ToolTip>
                    <ToolTip>
                        <Border>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Border Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="DarkGray" CornerRadius="3" Padding="3">
                                    <TextBlock FontWeight="Bold" Foreground="DarkRed" Text="{Binding Path=[XValues],Converter={x:Static local:TimeConverter.Default}}" />
                            </Border>
                                <TextBlock Grid.Row="1" Text="Volume" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=[Values]}" HorizontalAlignment="Right" />
                        </Grid>
                        </Border>
                    </ToolTip>
                </FrameworkElement.ToolTip>
            </c1c:DotSymbol>
        </DataTemplate>

        <DataTemplate x:Key="bar">
            <c1c:Bar Style="{StaticResource sstyle}" Loaded="Bar_Loaded">
                <FrameworkElement.ToolTip>
                    <ToolTip>
                        <Border>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Border Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="DarkGray" CornerRadius="3" Padding="3">
                                    <TextBlock FontWeight="Bold" Foreground="DarkRed" Text="{Binding Path=[XValues],Converter={x:Static local:TimeConverter.Default}}" />
                            </Border>
                                <TextBlock Grid.Row="1" Text="Volume" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=[Values]}" HorizontalAlignment="Right" />
                        </Grid>
                        </Border>
                    </ToolTip>
                </FrameworkElement.ToolTip>
            </c1c:Bar>
        </DataTemplate>

        <DataTemplate x:Key="hloc">
            <c1c:HLOC StrokeThickness="2" Style="{StaticResource sstyle}" Loaded="Bar_Loaded">
                <FrameworkElement.ToolTip>
                    <ToolTip>
                        <Border>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Border Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="DarkGray" CornerRadius="3" Padding="3">
                              <TextBlock FontWeight="Bold" Foreground="DarkRed" Text="{Binding Path=[XValues],Converter={x:Static local:TimeConverter.Default}}" />
                            </Border>
                            <TextBlock Grid.Row="1" Text="High" />
                            <TextBlock Grid.Row="2" Text="Low" />
                            <TextBlock Grid.Row="3" Text="Open" />
                            <TextBlock Grid.Row="4" Text="Close" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=[HighValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=[LowValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Path=[OpenValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Path=[CloseValues]}" HorizontalAlignment="Right" />
                        </Grid>
                            </Border>
                    </ToolTip>
                </FrameworkElement.ToolTip>
            </c1c:HLOC>
        </DataTemplate>
        
      <DataTemplate x:Key="candle">
            <c1c:HLOC Appearance="Candle" Style="{StaticResource sstyle}" Loaded="Bar_Loaded">
                <FrameworkElement.ToolTip>
                    <ToolTip>
                        <Border>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Border Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="DarkGray" CornerRadius="3" Padding="3">
                                    <TextBlock FontWeight="Bold" Foreground="DarkRed" Text="{Binding Path=[XValues],Converter={x:Static local:TimeConverter.Default}}" />
                            </Border>
                                <TextBlock Grid.Row="1" Text="High" />
                            <TextBlock Grid.Row="2" Text="Low" />
                            <TextBlock Grid.Row="3" Text="Open" />
                            <TextBlock Grid.Row="4" Text="Close" />
                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=[HighValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=[LowValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Path=[OpenValues]}" HorizontalAlignment="Right" />
                            <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Path=[CloseValues]}" HorizontalAlignment="Right" />
                        </Grid>
                        </Border>
                    </ToolTip>
                </FrameworkElement.ToolTip>
            </c1c:HLOC>
        </DataTemplate>

    </UserControl.Resources>
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
      </Grid.RowDefinitions>
      <Border Grid.Row="0">
        <StackPanel Margin="0 0 0 10" Orientation="Horizontal">
          <Button Content="NewData" Click="NewData" Width="120" Margin="0,0,10,0" Padding="0,0,5,0" Height="22" />
          <Label Content="Price:" VerticalAlignment="Center" Padding="0,0,5,0" Margin="5,0,0,0" />
          <ComboBox Name="Price" Width="120" Margin="0,0,10,0" Padding="5,0" Height="22" VerticalContentAlignment="Center" SelectedIndex="0">
            <ListBoxItem Content="Standard" Tag="{StaticResource hloc}" IsSelected="True" />
            <ListBoxItem Content="Candle" Tag="{StaticResource candle}" />
          </ComboBox>
          <Label Content="Volume:" VerticalAlignment="Center" Padding="0,0,5,0" Margin="5,0,0,0" />
                <ComboBox Name="Vol" Width="120" Margin="0" Padding="5,0" Height="22" VerticalContentAlignment="Center" SelectedIndex="0">
            <ListBoxItem Content="Bar" Tag="{x:Null}" DataContext="{StaticResource bar}" IsSelected="True" />
            <ListBoxItem Content="Area" Tag="{StaticResource area}" DataContext="{StaticResource emptyDot}" />
          </ComboBox>
        </StackPanel>
      </Border>
      <Border Grid.Row="1">
        <c1c:C1Chart Name="chart">
        	 <!--Theme="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=c1c:C1Chart, ResourceId=MediaPlayer}}"-->
          <!-- data -->
          <c1c:C1Chart.Data>
          <c1c:ChartData>
            <c1c:HighLowOpenCloseSeries Label="S1" Symbol="{Binding ElementName=Price, Path=SelectedItem.Tag}" />
            <c1c:XYDataSeries AxisY="Y2" Label="S2" Symbol="{Binding ElementName=Vol, Path=SelectedItem.DataContext}" Connection="{Binding ElementName=Vol, Path=SelectedItem.Tag}" />
          </c1c:ChartData>
        </c1c:C1Chart.Data>
        <!-- view -->
          <c1c:C1Chart.View>
          <c1c:ChartView>
            <c1c:ChartView.AxisX>
              <c1c:Axis IsTime="true" AnnoFormat="d" />
            </c1c:ChartView.AxisX>
            <c1c:ChartView.AxisY>
              <c1c:Axis Min="400">
                <c1c:Axis.Title>
                  <TextBlock Text="Price" />
                </c1c:Axis.Title>
              </c1c:Axis>
            </c1c:ChartView.AxisY>
            <c1c:Axis Position="Far" Name="Y2" AxisType="Y" Min="0" Max="1000">
              <c1c:Axis.Title>
                <TextBlock Text="Volume" />
              </c1c:Axis.Title>
            </c1c:Axis>
          </c1c:ChartView>
        </c1c:C1Chart.View>
        </c1c:C1Chart>
        </Border>
    </Grid>
</UserControl>