<Page
    x:Class="StockPortfolio.MyPortfolioMainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Name="pageRoot"
    xmlns:c1fg="using:C1.Xaml.FlexGrid"
    xmlns:c1tile="using:C1.Xaml.Tile"
    xmlns:c1="using:C1.Xaml"
    xmlns:local="using:StockPortfolio"
    RequestedTheme="Light"
    >
  
    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="56"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <c1:C1ProgressBar Grid.RowSpan="3" Height="50" Width="100"  Canvas.ZIndex="10" IndeterminateForeground="#FFB1356B" HorizontalAlignment="Center" VerticalAlignment="Center"  x:Name="progressBar" IsIndeterminate="True" Visibility="Collapsed"/>
        <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>
        <c1fg:C1FlexGrid x:Name="marketFlexGrid" Grid.Row="2"  Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"                           
                                         HeadersVisibility="Column"
                                         AutoGenerateColumns="False"
                                         HorizontalScrollBarVisibility="Disabled"
                                         SelectionMode="Row" 
                                         GridLinesVisibility="None"  
                                         AlternatingRowBackground="LightGray"
                                         HeaderGridLinesBrush="#666666" DoubleClick="marketFlexGridDoubleClick"
                         
                         >
            <c1fg:C1FlexGrid.Columns>
                <c1fg:Column Binding="{Binding Symbol}" Width="60"/>
                <!--<c1fg:Column Header="StockName" Binding="{Binding CurrentStockQuote.StockName}" Width="150"/>-->          
                <c1fg:Column Header="Price" Binding="{Binding CurrentStockQuote.LastTrade}" Width="40"/>
                <!--<c1fg:Column Header="LastTradeDate" Binding="{Binding CurrentStockQuote.LastTradeDate}" Width="150"/>-->
                <c1fg:Column  Header="Gain/Gain%"  Width="110">
                    <c1fg:Column.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <FontIcon Glyph="{Binding CurrentStockQuote.Change, Converter={StaticResource doubleToGlyph}}" Foreground="{Binding CurrentStockQuote.Change, Converter={StaticResource doubleToBrush}}"/>
                                <TextBlock Margin="3,0,0,0" Foreground="{Binding CurrentStockQuote.Change, Converter={StaticResource doubleToBrush}}" HorizontalAlignment="Center" VerticalAlignment="Center">
                                   <Run Text="{Binding CurrentStockQuote.Change}"/>
                                   <Run Text="("/>
                                   <Run Text="{Binding CurrentStockQuote.PercentChange}"/>
                                    <Run Text=")"/>
                                </TextBlock>
                            </StackPanel>

                        </DataTemplate>
                    </c1fg:Column.CellTemplate>
                </c1fg:Column>
                <!--<c1fg:Column Header="DayHight" Binding="{Binding CurrentStockQuote.Dayhigh}" Width="80"/>
                <c1fg:Column Header="Daylow" Binding="{Binding CurrentStockQuote.Daylow}" Width="80"/>
                <c1fg:Column Header="WeekHigh" Binding="{Binding CurrentStockQuote.Week52high}" Width="80"/>
                <c1fg:Column Header="WeekLow" Binding="{Binding CurrentStockQuote.Week52low}" Width="80"/>
                <c1fg:Column Header="PreviousClose" Binding="{Binding CurrentStockQuote.PreviousClose}" Width="120"/>-->
                <c1fg:Column Header="Count" Binding="{Binding Count}" Width="40"/>
                <c1fg:Column Header="Buy" Width="50" >
                    <c1fg:Column.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="Buy" Background="#FFB1356B" Foreground="White" BorderBrush="White" VerticalAlignment="Center" FontSize="15" Content="Buy"  Click="Buy_Click"  HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </c1fg:Column.CellTemplate>
                </c1fg:Column>
                <c1fg:Column Header="Sell"  Width="50">
                    <c1fg:Column.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="Sell" Background="#FFB1356B" Foreground="White" BorderBrush="White" VerticalAlignment="Center" FontSize="15" Content="Sell" Click="Sell_Click" HorizontalAlignment="Center"/>
                        </DataTemplate>
                    </c1fg:Column.CellTemplate>
                </c1fg:Column>
                <c1fg:Column Header="Chart" Width="100">
                    <c1fg:Column.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="Chart" FontSize="10"  Click="Chart_Click" HorizontalAlignment="Center">
                                <Button.Content>
                                    <Grid x:Name="topchart">
                                        <Path Stretch="Fill" Data="M19.418091,46.627349 L21.027205,45.466271 21.642095,47.48139 22.802418,47.353861 24.000496,45.985681 25.050035,44.578902 25.861701,45.131904 26.538979,44.325924 27.335879,45.276045 28.182484,43.138235 29.671412,42.201407 30.989388,39.811786 31.985484,39.974638 34.217057,37.293504 34.216889,51.298818 19.417958,51.480712 19.418032,48.772889 z" Stroke="#FF1490F1" StrokeThickness="0.5" Margin="0.228000000119209,0.970000028610229,0.879000008106232,0.00700000021606684">
                                            <Path.Fill>
                                                <LinearGradientBrush EndPoint="0.49,1.124" StartPoint="0.51,-0.124">
                                                    <GradientStop Color="#FF3DCDFF" Offset="0" />
                                                    <GradientStop Color="#FF025A92" Offset="0.994" />
                                                    <GradientStop Color="#FF58D3FF" Offset="0.459" />
                                                </LinearGradientBrush>
                                            </Path.Fill>
                                        </Path>
                                        <Path Stretch="Fill" Stroke="#FF000000" StrokeThickness="0.6" Data="M18.7542,36.302229 L18.754386,52.109433 35.987561,51.975318" Margin="0.228000000119209,0,0,0" />
                                        <Path Stretch="Fill" Stroke="#FF000000" StrokeThickness="1" Data="M0.4555,13.8895 L2.33,12.64 3.1432168,13.889999 5.0812337,13.640499 7.9578115,10.577999 10.16197,11.656536 11.801665,8.0720657 13.71085,6.6401582 16.523986,4.0147157" Margin="0,5.3289999961853,2.13000011444092,1.35199999809265" />
                                        <Path Width="2.876" Height="2.875" Fill="#FF000000" Stretch="Fill" StrokeThickness="0" Data="M15.3305,3.6395 L16.956,5.4524999 17.206576,3.5774999 z" HorizontalAlignment="Right" Margin="0,5.31799983978271,2.13000011444092,0" VerticalAlignment="Top" />
                                        <Path Width="1.25" Height="0.25" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" StrokeThickness="0.25" Data="M0.268,1.202 L1.268,1.202" HorizontalAlignment="Left" Margin="0.370999991893768,1.07700002193451,0,0" VerticalAlignment="Top" />
                                        <Path Width="1.25" Height="0.25" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" StrokeThickness="0.25" Data="M0.268,1.202 L1.268,1.202" HorizontalAlignment="Left" Margin="0.370999991893768,6.03999996185303,0,0" VerticalAlignment="Top" />
                                    </Grid>
                                </Button.Content>
                            </Button>
                        </DataTemplate>
                    </c1fg:Column.CellTemplate>
                </c1fg:Column>
            </c1fg:C1FlexGrid.Columns>
        </c1fg:C1FlexGrid>

    </Grid>
    <Page.BottomAppBar>
        <CommandBar x:Name="bottomAppBar" >
            
        </CommandBar>
    </Page.BottomAppBar>
</Page>
