<Page
    x:Class="XamlCruncher.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:XamlCruncher"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        
        <TextBlock Name="filenameText"
                   Grid.Row="0"
                   Grid.Column="0"
                   Grid.ColumnSpan="2"
                   FontSize="18"
                   TextTrimming="WordEllipsis" />

        <local:SplitContainer x:Name="splitContainer" 
                              Orientation="{Binding Orientation}"
                              SwapChildren="{Binding SwapEditAndDisplay}"
                              MinimumSize="200"
                              Grid.Row="1"
                              Grid.Column="0"
                              Grid.ColumnSpan="2">
            <local:SplitContainer.Child1>
                <local:TabbableTextBox x:Name="editBox"
                                       AcceptsReturn="True"
                                       FontSize="{Binding FontSize}"
                                       TabSpaces="{Binding TabSpaces}"
                                       TextChanged="OnEditBoxTextChanged"
                                       SelectionChanged="OnEditBoxSelectionChanged"/>
            </local:SplitContainer.Child1>
            
            <local:SplitContainer.Child2>
                <local:RulerContainer x:Name="resultContainer"
                                      ShowRuler="{Binding ShowRuler}"
                                      ShowGridLines="{Binding ShowGridLines}" />
            </local:SplitContainer.Child2>
        </local:SplitContainer>
        
        <TextBlock Name="statusText"
                   Text="OK"
                   Grid.Row="2"
                   Grid.Column="0"
                   FontSize="18"
                   TextWrapping="Wrap" />
        
        <TextBlock Name="lineColText"
                   Grid.Row="2"
                   Grid.Column="1"
                   FontSize="18" />
    </Grid>
    
    <Page.BottomAppBar>
        <AppBar>
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button Style="{StaticResource RefreshAppBarButtonStyle}"
                            AutomationProperties.Name="Odśwież"
                            Click="OnRefreshAppBarButtonClick" />

                    <Button Style="{StaticResource SettingsAppBarButtonStyle}"
                            AutomationProperties.Name="Ustawienia"
                            Click="OnSettingsAppBarButtonClick" />    
                </StackPanel>
                    
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Style="{StaticResource OpenFileAppBarButtonStyle}"
                            AutomationProperties.Name="Otwórz plik"
                            Click="OnOpenAppBarButtonClick" />

                    <Button Style="{StaticResource SaveLocalAppBarButtonStyle}"
                            AutomationProperties.Name="Zapisz jako"
                            Click="OnSaveAsAppBarButtonClick" />

                    <Button Style="{StaticResource SaveAppBarButtonStyle}"
                            AutomationProperties.Name="Zapisz"
                            Click="OnSaveAppBarButtonClick" />
                    
                    <Button Style="{StaticResource AddAppBarButtonStyle}"
                            AutomationProperties.Name="Dodaj"
                            Click="OnAddAppBarButtonClick" />
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
</Page>
