<UserControl
    x:Class="StockChart.ucToolbar"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:StockChart"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c1="using:C1.Xaml"
    mc:Ignorable="d"
    d:DesignHeight="150"
    d:DesignWidth="1280">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Themes/Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <local:Boolean2VisibilityConverter2 x:Key="Boolean2VisibilityConverter2" />
            <local:Boolean2VisibilityConverter  x:Key="Boolean2VisibilityConverter" />
            <local:SeriesVisibility2BooleanConverter x:Key="SeriesVisibility2BooleanConverter" />
            <local:Color2BrushConverter x:Key="Color2BrushConverter" />
            <local:IsComparisonModeToDisplayModeConverter x:Key="IsComparisonModeToDisplayModeConverter" />
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid Background="#222222">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Border Grid.Row="0" x:Name="topContainer" BorderThickness="0,0,0,1" BorderBrush="#333333" Padding="10">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <local:ucAutoComplateComandTextBox FontSize="12" Width="240" Placeholder="Add comparison symbol" ItemsSource="{Binding SymbolNames}"
                                                   Command="{Binding AddCommand}" Text="{Binding AddCommandParamter, Mode=TwoWay}">
                    <local:ucAutoComplateComandTextBox.ButtonContent>
                        <Path Data="M15,6h-5V1c0-0.5-0.5-1-1-1H7C6.4,0,6,0.5,6,1v5H1C0.4,6,0,6.5,0,7v2c0,0.5,0.4,1,1,1h5v5c0,0.5,0.4,1,1,1h2  c0.5,0,1-0.5,1-1v-5h5c0.5,0,1-0.5,1-1V7C16,6.5,15.5,6,15,6z" Fill="White" Width="16" Height="16" Stretch="Uniform" />
                    </local:ucAutoComplateComandTextBox.ButtonContent>
                </local:ucAutoComplateComandTextBox>

                <Grid Grid.Column="1">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <local:ucButtonGroup x:Name="ucButtonGroup" Width="350" FontSize="12" HorizontalAlignment="Left" SelectedIndex="{Binding RangeSelectIndex, Mode=TwoWay}" />
                        <TextBlock Margin="10, 0, 0, 0" Width="190" FontSize="14" Text="{Binding DateRangeText}" TextAlignment="Center" VerticalAlignment="Center" Foreground="#666666" />
                        <Button x:Name="btnReset" FontSize="14" Margin="10, 0, 0, 0" Width="60" Style="{StaticResource BlueButton}" Content="Reset" Command="{Binding ResetCommand}" />
                    </StackPanel>
                </Grid>

                <StackPanel Grid.Column="2" Orientation="Horizontal">
                    <ToggleButton x:Name="toggleShowVolume" Width="40"  IsChecked="{Binding IsShowVolume, Mode=TwoWay}" Style="{StaticResource DarkToggleButton}">
                        <Path Data="M3,16H1c-0.6,0-1-0.4-1-1V9c0-0.6,0.4-1,1-1h2c0.5,0,1,0.4,1,1v6C4,15.6,3.5,16,3,16z M9,16H7c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1h2c0.6,0,1,0.4,1,1v14C10,15.6,9.6,16,9,16z M15,16h-2c-0.6,0-1-0.4-1-1V5c0-0.6,0.4-1,1-1h2c0.6,0,1,0.4,1,1v10C16,15.6,15.6,16,15,16z" Fill="White" Width="16" Height="16" Stretch="Uniform" />
                    </ToggleButton>
                    <ComboBox x:Name="cmbChartType" Margin="10, 0, 0, 0" FontSize="12"
                              BorderThickness="0"
                              DisplayMemberPath="Key"
                              SelectedValuePath="Value"
                                VerticalContentAlignment="Center"
                              ItemsSource="{Binding ChartTypes}" SelectedValue="{Binding ChartType, Mode=TwoWay}"
                              Visibility="{Binding IsComparisonMode, Converter={StaticResource Boolean2VisibilityConverter2}}" Style="{StaticResource DarkComboBoxStyle}"/>
                    <ComboBox x:Name="cmbExport" Margin="10, 0, 0, 0" FontSize="12"
                              BorderThickness="0" ItemsSource="{Binding ExportTypes}" Style="{StaticResource DarkExportComboBoxStyle}" DisplayMemberPath="Key" DropDownClosed="cmbExport_DropDownClosed" >
                    </ComboBox>
                </StackPanel>
            </Grid>
        </Border>

        <Border Grid.Row="1" x:Name="centerContainer" BorderThickness="0,0,0,1" BorderBrush="#333333" Padding="10">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal">
                    <CheckBox x:Name="chkShowMovingAverage" Foreground="#808080" FontSize="12" BorderThickness="0" BorderBrush="White" Content="Moving Average" IsChecked="{Binding IsShowMovingAverage, Mode=TwoWay}" Style="{StaticResource DarkCheckBox}" />
                    <ComboBox x:Name="cmbMovingAverageType" BorderThickness="0" Margin="10, 0, 0, 0" FontSize="12" 
                              DisplayMemberPath="Key"
                              SelectedValuePath="Value"
                                VerticalContentAlignment="Center"
                              ItemsSource="{Binding MovingAverageTypes}" SelectedValue="{Binding MovingAverageType, Mode=TwoWay}" Visibility="{Binding IsChecked, Converter={StaticResource Boolean2VisibilityConverter}, ElementName=chkShowMovingAverage}" Style="{StaticResource DarkComboBoxStyle}" />
                    <c1:C1NumericBox Margin="10, 0, 0, 0" BorderThickness="0" FontSize="12" MinWidth="40" VerticalContentAlignment="Center" Value="{Binding MovingAveragePeriod, Mode=TwoWay}" Visibility="{Binding IsChecked, Converter={StaticResource Boolean2VisibilityConverter}, ElementName=chkShowMovingAverage}" Minimum="2" Foreground="White" Background="#424242"  />

                </StackPanel>

                <StackPanel Grid.Column="2" Orientation="Horizontal">
                    <CheckBox x:Name="chkLineMarker" Foreground="#808080" FontSize="12" BorderThickness="0" Content="Line Marker" IsChecked="{Binding IsShowLineMarker, Mode=TwoWay}" Style="{StaticResource DarkCheckBox}" />
                    <CheckBox x:Name="chkNews" Foreground="#808080" BorderThickness="0" FontSize="12" Margin="10, 0, 0, 0" Content="News" IsChecked="{Binding IsShowNews, Mode=TwoWay}"
                      Visibility="{Binding IsComparisonMode, Converter={StaticResource Boolean2VisibilityConverter2}}" Style="{StaticResource DarkCheckBox}" />
                </StackPanel>
            </Grid>
        </Border>

        <Border Grid.Row="2" x:Name="bottomContainer" Padding="10">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <ItemsControl x:Name="itemsControl" ItemsSource ="{Binding SymbolCollection}" Width="Auto" Grid.ColumnSpan="2" Margin="0,0,491,0" >
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Margin="0" VerticalAlignment="Center" VerticalContentAlignment="Center" FontSize="13" FontWeight="Bold" Content="{Binding Code}" Foreground="{Binding Color, Converter={StaticResource Color2BrushConverter}}" IsChecked="{Binding Visibility, Mode=TwoWay, Converter={StaticResource SeriesVisibility2BooleanConverter}}" Style="{StaticResource DarkCheckBox}" />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <local:ComparisonQuotesLabel Grid.Column="2" Width="Auto" FontSize="12" QuotesInfo="{Binding ComparisonQuoteInfo}" DisplayMode="{Binding IsComparisonMode, Converter={StaticResource IsComparisonModeToDisplayModeConverter}}" VerticalContentAlignment="Center" VerticalAlignment="Stretch" />

            </Grid>
        </Border> 

    </Grid>
</UserControl>
