<!--
    Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
    the MIT License. See LICENSE in the project root for license information.
-->
<UserControl x:Class="TerminalApp.MarkdownPaneContent"
             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:local="using:TerminalApp"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:mtu="using:Microsoft.Terminal.UI"
             xmlns:mux="using:Microsoft.UI.Xaml.Controls"
             mc:Ignorable="d">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.ThemeDictionaries>
                <!--  same as in MainPage, this is SolidBackgroundFillColorTertiary  -->
                <ResourceDictionary x:Key="Dark">
                    <Color x:Key="PageBackground">#282828</Color>
                    <Color x:Key="PlayButtonHoveredColor">#90ef90</Color>
                    <Color x:Key="PlayButtonNormalColor">#8888</Color>
                </ResourceDictionary>
                <ResourceDictionary x:Key="Light">
                    <Color x:Key="PageBackground">#F9F9F9</Color>
                    <Color x:Key="PlayButtonHoveredColor">#257f01</Color>
                    <Color x:Key="PlayButtonNormalColor">#88222222</Color>
                </ResourceDictionary>
                <ResourceDictionary x:Key="HighContrast">
                    <!--  Define resources for HighContrast mode here  -->
                    <StaticResource x:Key="PageBackground"
                                    ResourceKey="SystemColorWindowColorBrush" />
                </ResourceDictionary>

            </ResourceDictionary.ThemeDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="Root"
          Background="{ThemeResource PageBackground}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBox x:Name="FilePathInput"
                     Grid.Column="0"
                     Margin="4"
                     PlaceholderText="Enter a path to a markdown file..."
                     Text="Z:\dev\simple-test.md">
                <TextBox.ContextFlyout>
                    <mtu:TextMenuFlyout />
                </TextBox.ContextFlyout>
            </TextBox>
            <StackPanel Grid.Column="1"
                        Orientation="Horizontal">
                <Button Margin="4"
                        Tapped="_loadTapped">
                    <FontIcon FontFamily="Segoe UI, Segoe Fluent Icons, Segoe MDL2 Assets"
                              FontSize="12"
                              Glyph="&#xe8e5;" />
                    <!--  OpenFile  -->
                </Button>
                <Button Margin="4"
                        Tapped="_editTapped">
                    <FontIcon x:Name="EditIcon"
                              FontFamily="Segoe UI, Segoe Fluent Icons, Segoe MDL2 Assets"
                              FontSize="12"
                              Glyph="&#xe932;" />
                    <!--  Label  -->
                </Button>
                <Button Margin="4"
                        Tapped="_closeTapped">
                    <FontIcon FontFamily="Segoe UI, Segoe Fluent Icons, Segoe MDL2 Assets"
                              FontSize="12"
                              Glyph="&#xe8bb;" />
                    <!--  ChromeClose  -->
                </Button>
            </StackPanel>
        </Grid>

        <Grid x:Name="TabContent"
              Grid.Row="1"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid x:Name="InProcContent"
                  Grid.Column="0"
                  Padding="16"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  Background="#ff0000" />

            <TextBox x:Name="_editor"
                     Grid.Column="1"
                     Padding="3"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     AcceptsReturn="True"
                     FontFamily="Cascadia Code"
                     IsSpellCheckEnabled="False"
                     Text="{x:Bind FileContents, Mode=TwoWay}"
                     Visibility="{x:Bind Editing}">
                <TextBox.ContextFlyout>
                    <mtu:TextMenuFlyout />
                </TextBox.ContextFlyout>
            </TextBox>

            <ScrollViewer x:Name="_scrollViewer"
                          Grid.Column="1"
                          Padding="3"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch"
                          Background="Transparent"
                          BringIntoViewOnFocusChange="True"
                          IsVerticalScrollChainingEnabled="True">
                <StackPanel x:Name="RenderedMarkdown"
                            Grid.Column="1"
                            Padding="16"
                            HorizontalAlignment="Stretch"
                            Background="Transparent"
                            Orientation="Vertical" />
            </ScrollViewer>

        </Grid>

    </Grid>
</UserControl>
