<Page
    x:Class="StockPortfolio.StockDetailPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:StockPortfolio"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:c1="using:C1.Xaml"
    xmlns:chart="using:C1.Xaml.Chart"
    RequestedTheme="Light"
    >

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="56"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style TargetType="TextBlock">
                <Setter Property="Foreground" Value="#FF5D5D5D"/>
            </Style>
        </Grid.Resources>
        <local:HeaderPage Visibility="{Binding HeaderVisibility,ElementName=pageRoot}"/>
        <Border Grid.Row="1" Background="#FFEDEDED">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal">
                    <Path Height="32" Width="32" Margin="20 0 0 0" VerticalAlignment="Center" Data="M21,20 L27,20 L27,24 L21,24 z M48,13.47 L48,34 C48,36.2091 46.2091,38 44,38 L4,38 C1.79086,38 0,36.2091 0,34 L0,13.47 L0.050926,13.5439 C3.27892,18.0839 10.0333,21.5167 18.266,22.6214 L19,22.7097 L19,25 C19,25.5523 19.4477,26 20,26 L28,26 C28.5523,26 29,25.5523 29,25 L29,22.7097 L29.734,22.6214 C37.9667,21.5167 44.7211,18.0839 47.9491,13.5439 z M17,3 L17,8 L31,8 L31,3 z M16,0 L32,0 C33.1046,0 34,0.895432 34,2 L34,8 L44,8 C46.071,8 47.7745,9.574 47.9793,11.591 L47.9807,11.6093 L47.9518,11.6676 C45.3818,16.643 38.329,20.495 29.5135,21.6458 L29,21.7059 L29,19 C29,18.4477 28.5523,18 28,18 L20,18 C19.4477,18 19,18.4477 19,19 L19,21.7059 L18.4865,21.6458 C9.67095,20.495 2.6182,16.643 0.048165,11.6676 L0.019261,11.6093 L0.020652,11.591 C0.225491,9.574 1.92893,8 4,8 L14,8 L14,2 C14,0.895432 14.8954,0 16,0 z"  Fill="#FFB1356B" Stretch="Uniform"  />
                    <TextBlock x:Name="pageTitle" Text="Stock Detail" VerticalAlignment="Center" Margin="10 0 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="22" Foreground="#FFB1356B"/>
                    <!-- Style="{StaticResource PageHeaderTextStyle}"-->
                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0 0 20 0" VerticalAlignment="Center" >
                    <!--<TextBlock Text="Theme:" Margin="8" Foreground="{ThemeResource ControlExplorerLightForegroundThemeBrush}" VerticalAlignment="Center" FontSize="20"/>-->
                    <!--<ComboBox x:Name="comboThemes" MinWidth="100" SelectionChanged="comboThemes_SelectionChanged" Height="40"/>-->

                </StackPanel>
            </Grid>
        </Border>
        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="200"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid Margin="5" Name="StockGird">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.8*" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="0.8*" />

                </Grid.ColumnDefinitions>
                <Grid Margin="0 0 5 5" Background="#FFF3F3F3" Grid.ColumnSpan="2">
                    <StackPanel Margin="5">
                        <TextBlock Text="StockName" FontSize="18"/>
                        <TextBlock Text="{Binding CurrentStockQuote.StockName}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>
                <Grid Margin="0 0 0 5" Background="#FFF3F3F3" Grid.Row="0" Grid.Column="2">
                    <StackPanel Margin="5">
                        <TextBlock Text="Symbol" FontSize="18"/>
                        <TextBlock Text="{Binding Symbol}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>
                <Grid Margin="0 0 5 5" Background="#FFF3F3F3"  Grid.Row="1" Grid.Column="0">
                    <StackPanel Margin="5">
                        <TextBlock Text="Open" FontSize="18"/>
                        <TextBlock Text="{Binding CurrentStockQuote.Open}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>

                <Grid Margin="0 0 5 5" Background="#FFF3F3F3" Grid.Row="1" Grid.Column="1">
                    <StackPanel Margin="5">
                        <TextBlock Text="Close" FontSize="18"/>
                        <TextBlock Text="{Binding CurrentStockQuote.PreviousClose}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>

                <Grid Margin="0 0 0 5" Background="#FFF3F3F3" Grid.Row="1" Grid.Column="2">
                    <StackPanel Margin="5">
                        <TextBlock Text="High" FontSize="18"/>
                        <TextBlock Text="{Binding CurrentStockQuote.Dayhigh}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>

                <Grid Margin="0 0 5 5" Background="#FFF3F3F3" Grid.Row="2" Grid.Column="0">
                    <StackPanel Margin="5">
                        <TextBlock Text="Low" FontSize="18"/>
                        <TextBlock Text="{Binding CurrentStockQuote.Daylow}" FontSize="14" FontFamily="Segoe WP" FontWeight="Light" Margin="0 -5 0 10"/>
                    </StackPanel>
                </Grid>

                <Grid Margin="0 0 5 5" Background="#FFF3F3F3" Grid.Row="2" Grid.Column="1">
                    <StackPanel Margin="5">
                        <TextBlock Text="Adjusted Close" Grid.Column="6" FontSize="18"/>
                        <TextBlock Text="{Binding AdjClose}" Grid.Column="7" FontSize="14"/>
                    </StackPanel>
                </Grid>

                <Grid Margin="0 0 0 5" Background="#FFF3F3F3" Grid.Row="2" Grid.Column="2">
                    <StackPanel Margin="5">
                        <TextBlock Text="Volume" Grid.Row="1" Grid.Column="6"  FontSize="18"/>
                        <TextBlock Text="{Binding Volume}" Grid.Row="1" Grid.Column="7" FontSize="14"/>
                    </StackPanel>
                </Grid>

            </Grid>
            <!--<Grid >
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    --><!--<ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />--><!--
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Row="0" Grid.Column="0">
                    <TextBlock Text="StockName:" Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding CurrentStockQuote.StockName}"  Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="0" Grid.Column="1">
                    <TextBlock Text="Symbol:"  Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding Symbol}"  Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="0" Grid.Column="2">
                    <TextBlock Text="Open:"  Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding CurrentStockQuote.Open}"  Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="1" Grid.Column="0">
                    <TextBlock Text="Close:"  Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding CurrentStockQuote.PreviousClose}" Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="1" Grid.Column="1">
                    <TextBlock Text="High:"  Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding CurrentStockQuote.Dayhigh}" Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>


                <StackPanel Grid.Row="1" Grid.Column="2">
                    <TextBlock Text="Low:" Grid.Row="1" Grid.Column="4" Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding CurrentStockQuote.Daylow}" Grid.Row="1" Grid.Column="5" Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="2" Grid.Column="0">
                    <TextBlock Text="Adjusted Close:" Grid.Column="6" Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding AdjClose}" Grid.Column="7" Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>

                <StackPanel Grid.Row="2" Grid.Column="1">
                    <TextBlock Text="Volume:" Grid.Row="1" Grid.Column="6" Style="{StaticResource BodyTextBlockStyle}"/>
                    <TextBlock Text="{Binding Volume}" Grid.Row="1" Grid.Column="7" Style="{StaticResource TitleTextBlockStyle}"/>
                </StackPanel>


            </Grid>-->
            <TextBlock x:Name="DateLabel" Text="{Binding ElementName=dot, Path=DataPoint.X, Converter={StaticResource dateFormat}, ConverterParameter=l}"  Grid.Row="1" Margin="5" FontSize="24" VerticalAlignment="Center" Foreground="#FFB1356B"/>
            <chart:C1Chart x:Name="c1Chart1" ChartType="Area" Palette="Standard" Grid.Row="2" Margin="5" FontSize="10" >
                <chart:C1Chart.Data>
                    <!-- XValueBinding="{Binding Date}"-->
                    <chart:ChartData ItemsSource="{Binding HistoricalStock}" ItemNames="{Binding AxisLabels}">
                        <chart:ChartData.Children>
                            <chart:DataSeries ValueBinding="{Binding Close}" Opacity="0.6" />
                        </chart:ChartData.Children>
                    </chart:ChartData>
                </chart:C1Chart.Data>
                <chart:C1Chart.View>
                    <chart:ChartView>
                        <chart:ChartView.AxisX>
                            <chart:Axis IsTime="False" Reversed="True" UseExactLimits="True" MajorGridStrokeThickness="0" MajorTickThickness="0" MinorTickThickness="0" AnnoCreated="Axis_AnnoCreated">
                                <!--<chart:Axis.AnnoTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding}" Foreground="Red" />
                                    </DataTemplate>
                                </chart:Axis.AnnoTemplate>-->
                            </chart:Axis>

                        </chart:ChartView.AxisX>
                        <chart:ChartView.AxisY>
                            <chart:Axis Position="Far" AnnoFormat="n2" MajorTickThickness="0" MinorTickThickness="0">
                                <chart:Axis.AxisLine>
                                    <Line StrokeThickness="0" />
                                </chart:Axis.AxisLine>
                            </chart:Axis>
                        </chart:ChartView.AxisY>
                        <chart:ChartView.Layers>

                            <chart:ChartPanel>
                                <!-- vertical line and dot markers -->
                                <chart:ChartPanelObject x:Name="line"
                                                 Attach="DataX"
                                                 Action="MouseMove"
                                                 VerticalContentAlignment="Stretch"
                                                 HorizontalAlignment="Center">
                                    <Border Background="Black" BorderBrush="Black" Padding="1" BorderThickness="1 0 0 0" />
                                </chart:ChartPanelObject>
                                <chart:ChartPanelObject x:Name="dot"
                                                 Attach="DataX"
                                                 Action="MouseMove"
                                                 DataPoint="0.5,0.5"
                                                 HorizontalAlignment="Center"
                                                 VerticalAlignment="Center">
                                    <Grid DataContext="{Binding ElementName=dot}">
                                        <Ellipse Fill="White" Stroke="Black" StrokeThickness="2" Width="30" Height="30" />
                                        <TextBlock Text="{Binding DataPoint.Y}" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    </Grid>
                                </chart:ChartPanelObject>
                            </chart:ChartPanel>
                        </chart:ChartView.Layers>
                    </chart:ChartView>
                </chart:C1Chart.View>
            </chart:C1Chart>
           
            <StackPanel Grid.Row="3" Margin="5 0" Orientation="Horizontal">
                <TextBlock Text="Time:"  FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <ComboBox x:Name="timeComboBox" Foreground="White" Margin="10,0,0,0"  Width="200" MinWidth="0" SelectionChanged="ComboBox_SelectionChanged" >
                    <ComboBoxItem Content="DAY"/>
                    <ComboBoxItem Content="WEEK"/>
                    <ComboBoxItem Content="MONTH"/>
                    <ComboBoxItem Content="6 MONTH"/>
                    <ComboBoxItem Content="1 YEAR"/>
                    <ComboBoxItem/>
                </ComboBox>
                <!--<ToggleButton  x:Name="btnOneDay" Margin="0,0,10,0" Width="60" MinWidth="0" Content="DAY" Click="btnDate_Click"/>
                <ToggleButton x:Name="btnFiveDay" Margin="0,0,10,0"  Width="70" MinWidth="0" Content="WEEK" Click="btnDate_Click"/>
                <ToggleButton x:Name="btnOneMonth" Margin="0,0,10,0"  Width="90" MinWidth="0" Content="MONTH" Click="btnDate_Click"/>
                <ToggleButton x:Name="btnSixMonth" Margin="0,0,10,0"  Width="100" MinWidth="0" Content="6 MONTH" Click="btnDate_Click"/>
                <ToggleButton x:Name="btnOneYear" Margin="0,0,10,0"  Width="60" MinWidth="0"  Content="1 YEAR" Click="btnDate_Click"/>-->
            </StackPanel>
        </Grid>
        <c1:C1ProgressBar Width="400" Grid.Row="2"  Height="70"  Canvas.ZIndex="10"  x:Name="progressBar" HorizontalAlignment="Center" VerticalAlignment="Center" IndeterminateForeground="#FFB1356B" IsIndeterminate="True" Visibility="Collapsed"/>
    </Grid>
</Page>
