<Page
    x:Name="pageRoot"
    x:Class="ControlExplorer.SourceCodePage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ControlExplorer"
    xmlns:common="using:ControlExplorer.Common"
    xmlns:c1="using:C1.Xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ControlExplorerBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="90"/>
            <RowDefinition Height="66"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <!--Header-->
        <StackPanel Margin="20 0 0 0" Orientation="Horizontal" VerticalAlignment="Center">
            <Image Source="/Resources/images/winrtxamlLogo_64.png" Width="64" Height="64"/>
            <TextBlock Text="Studio WinRT Edition" VerticalAlignment="Center" Margin="12 5 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="48" Foreground="{ThemeResource ControlExplorerMainTitleThemeBrush}"/>
        </StackPanel>

        <!-- Back button and page title -->
        <Grid Grid.Row="1" Background="{ThemeResource ControlExplorerLightStripeThemeBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Margin="20 0 0 0" VerticalAlignment="Center" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" Foreground="{ThemeResource ControlExplorerLightForegroundThemeBrush}"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <StackPanel Orientation="Horizontal"  Grid.Column="1" >
                <!--<ContentControl x:Name="pageIcon" Height="42" Width="42" VerticalAlignment="Center" ContentTemplate="{Binding Icon}" Style="{StaticResource PageIconStyle}"/>
                <TextBlock x:Name="pageTitle" Text="{Binding Name}" VerticalAlignment="Center" Margin="0 5 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="34" Foreground="#FFFFFFFF"/>-->
                <TextBlock Text="{Binding SampleNamespace}" Style="{StaticResource HeaderTextBlockStyle}"
                        IsHitTestVisible="false" TextWrapping="NoWrap" Margin="0 5 8 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="30" Foreground="{ThemeResource ControlExplorerLightForegroundThemeBrush}"/>
                <TextBlock Text="{Binding SampleNameWithoutNamespace}" Style="{StaticResource HeaderTextBlockStyle}"
                        IsHitTestVisible="false" TextWrapping="NoWrap" Margin="0 5 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="30"  Foreground="{ThemeResource ControlExplorerLightForegroundThemeBrush}"/>
                <TextBlock Text=" - Source Code" Style="{StaticResource HeaderTextBlockStyle}"
                        IsHitTestVisible="false" TextWrapping="Wrap" Margin="0 5 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="30" Foreground="{ThemeResource ControlExplorerLightForegroundThemeBrush}"/>
            </StackPanel>
            <HyperlinkButton x:Name="btnDownloadSample" Content="Download Sample" HorizontalAlignment="Right" Grid.Column="1" VerticalAlignment="Bottom" Margin="10 10 10 -45" NavigateUri="{Binding DownloadLink}" FontSize="15" Foreground="{ThemeResource ControlExplorerHyperlinkThemeBrush}" FontWeight="Bold"/>
        </Grid>
        
        <c1:C1TabControl Grid.Row="2" BorderThickness="0">
            <c1:C1TabControl.Items>
                <c1:C1TabItem Header="{Binding XamlFileName}" Width="280">
                    <local:SyntaxHighlighter Text="{Binding Xaml}" Mode="Xaml" />
                </c1:C1TabItem>
                <c1:C1TabItem Header="{Binding CodeFileName}" Width="280">
                    <local:SyntaxHighlighter Text="{Binding Code}" Mode="CSharp"/>
                </c1:C1TabItem>
            </c1:C1TabControl.Items>
        </c1:C1TabControl>
        <ProgressRing Grid.Row="2" x:Name="progressRing" Width="100" Height="100"/>
    </Grid>
</Page>
