<Page
    x:Class="FinancialChartExplorer.Overlays"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FinancialChartExplorer"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Finance="using:C1.Xaml.Chart.Finance"
    xmlns:Chart="using:C1.Xaml.Chart"
    xmlns:Xaml="using:C1.Xaml"
    DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="20 0">
            <Button Content="&#xE700;" Background="{x:Null}" BorderThickness="0" FontSize="25" FontFamily="{ThemeResource SymbolThemeFontFamily}" Click="OnSplitterButtonClick"/>
            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=OverlaysSettings}" VerticalAlignment="Center" />
        </StackPanel>
        <SplitView x:Name="splitter" DisplayMode="Overlay" Grid.Row="1">
            <SplitView.Pane>
                <StackPanel Grid.Row="1" Margin="0 10">
                    <StackPanel.Resources>
                        <Style TargetType="Xaml:C1NumericBox">
                            <Setter Property="Width" Value="200"/>
                            <Setter Property="Margin" Value="10 0 20 0"/>
                        </Style>
                    </StackPanel.Resources>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=OverlayCaption}" Margin="10 0"/>
                        <ComboBox x:Name="cbOverlays" ItemsSource="{Binding OverlayTypes}" Width="150" SelectionChanged="cbOverlays_SelectionChanged"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" x:Name="spBollingerOptions" Margin="0 10">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=PeriodCaption}" Margin="20 0 0 0"/>
                            <Xaml:C1NumericBox x:Name="cbPeriod" Value="20" Minimum="2" Maximum="86" ValueChanged="cbPeriod_ValueChanged"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0 10">
                            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=MultiplierCaptin}"/>
                            <Xaml:C1NumericBox x:Name="cbMultiplier" Value="2" Minimum="1" Maximum="100" ValueChanged="cbMultiplier_ValueChanged"/>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" x:Name="spEnvelopesOptions" Visibility="Collapsed" Margin="0 10">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=PeriodCaption}" Margin="20 0 0 0"/>
                            <Xaml:C1NumericBox x:Name="cbEnvelopesPeriod" Value="20" Minimum="2" Maximum="86" ValueChanged="cbEnvelopesPeriod_ValueChanged"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0 10">
                            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=SizeCaption}" Margin="25 0 10 0"/>
                            <Xaml:C1NumericBox x:Name="cbSize" Value="0.03" Minimum="0" Maximum="1" Format="P" ValueChanged="cbSize_ValueChanged"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Source={StaticResource FinancialChartExplorerLocalization}, Path=TypeCaption}" Margin="25 0 10 0"/>
                            <ComboBox x:Name="cbTypes" ItemsSource="{Binding Types}" Width="120" SelectionChanged="cbTypes_SelectionChanged"/>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </SplitView.Pane>
            <SplitView.Content>
                <Finance:C1FinancialChart
                    x:Name="overlayChart"
                    FontSize="12"
                    LegendPosition="Bottom"
                    ItemsSource="{Binding Data}"
                    PointerMoved="overlayChart_PointerMoved"
                    PointerPressed="overlayChart_PointerPressed"
                    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
                    ChartType="Candlestick"
                    BindingX="Date">
                    <Finance:FinancialSeries Binding="High,Low,Open,Close" SeriesName="Box" SymbolSize="5"/>
                    <Finance:BollingerBands x:Name="bollinger" Period="20" Binding="High,Low,Close" SeriesName="Bolligner Bands"/>
                    <Finance:Envelopes x:Name="envelopes" Period="20" Size="0.03" Binding="High,Low,Close" SeriesName="Envelopes"/>
                    <Finance:C1FinancialChart.AxisX>
                        <Chart:Axis LabelAngle="45" MajorUnit="3"/>
                    </Finance:C1FinancialChart.AxisX>
                </Finance:C1FinancialChart>
            </SplitView.Content>
        </SplitView>
    </Grid>
</Page>
