<!--This file is part of HTTP Directory Traversal Scanner.

HTTP Directory Traversal Scanner is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

HTTP Directory Traversal Scanner is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with HTTP Directory Traversal Scanner.  If not, see <http://www.gnu.org/licenses/>.-->
<Window x:Class="DirectoryTraversalScan.Window1"
        x:Name="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DirectoryTraversalScan.Components"
        MinWidth="660"
        Loaded="MainWindow_Loaded"
        Style="{StaticResource WindowStyle}">
    <Grid>
        <Grid.Resources>
            <!--<Style TargetType="Label">
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>-->
            <Style TargetType="TextBox">
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Margin" Value="4" />
            </Style>
            <HierarchicalDataTemplate DataType="{x:Type local:ResponseSet}"
                                      ItemsSource="{Binding Responses}">
                <TextBlock Text="{Binding ResponseCode}" />
                <HierarchicalDataTemplate.ItemTemplate>
                    <HierarchicalDataTemplate>
                        <TextBlock Text="{Binding RequestStatus}"
                                   Background="{Binding BackgroundColor}" />
                    </HierarchicalDataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>
            </HierarchicalDataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="70" />
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <Border Style="{StaticResource BorderStyle}" Margin="2,2,2,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="200" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="30"/>
                </Grid.RowDefinitions>



                <Label Content="Host" />
                <TextBox Grid.Column="1" IsEnabled="{Binding ScanSettingsEnabled}"
                     Text="{Binding Config.Host,UpdateSourceTrigger=PropertyChanged}" />

                <Label Grid.Column="2" Content="Port" />
                <TextBox Grid.Column="3" IsEnabled="{Binding ScanSettingsEnabled}"
                     Text="{Binding Config.Port,UpdateSourceTrigger=PropertyChanged}" />


                <Label Grid.Row="1" Content="Flag" />
                <TextBox Grid.Row="1" Grid.Column="1" 
                     Text="{Binding Config.FlagText,UpdateSourceTrigger=PropertyChanged}" />

                <Label Grid.Row="1" Grid.Column="2" Content="Path" />
                <TextBox Grid.Row="1" Grid.Column="3"
                     IsEnabled="{Binding ScanSettingsEnabled}"
                     Text="{Binding Config.Path,UpdateSourceTrigger=PropertyChanged}" />

                <Label Grid.Column="4" Content="File" />
                <TextBox Grid.Column="5" IsEnabled="{Binding ScanSettingsEnabled}"
                     Text="{Binding Config.File,UpdateSourceTrigger=PropertyChanged}" />

                <Button x:Name="ScanButton" Grid.Column="6" Grid.Row="0" 
                        Grid.RowSpan="2" VerticalAlignment="Bottom"
                        Click="ScanButton_Click"
                        Content="{Binding ButtonText}" />
            </Grid>
        </Border>        
        
        <Border Style="{StaticResource BorderStyle}" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="180" MaxWidth="400" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="200" MaxHeight="600" />
                    <RowDefinition />
                    <RowDefinition Height="20" />
                </Grid.RowDefinitions>

                <GridSplitter Width="4" Grid.RowSpan="2"
                          VerticalAlignment="Stretch" HorizontalAlignment="Right" />

                <!-- Groups -->
                <TreeView x:Name="Tree"  Grid.RowSpan="2" Margin="0,0,4,0"
                          SelectedItemChanged="Tree_SelectedItemChanged"
                          ItemsSource="{Binding Responses}" />
                
                <!-- Requests -->
                <ListBox Grid.Column="1"
                     ItemsSource="{Binding SelectedResponse.Requests}">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBox Background="Transparent" Text="{Binding Mode=OneWay}" IsReadOnly="True" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>                

                <GridSplitter Height="4" Grid.Column="1" Grid.Row="1"
                          HorizontalAlignment="Stretch" VerticalAlignment="Top" />

                <!-- Responses -->
                <TextBox Grid.Column="1" Grid.Row="1"  IsReadOnly="True" 
                         Margin="0,4,0,0" Background="Transparent"
                         TextWrapping="Wrap"
                         VerticalContentAlignment="Top"
                         VerticalScrollBarVisibility="Auto"
                    
                     Text="{Binding SelectedResponse.Text}" />

                <ProgressBar Grid.ColumnSpan="2" Grid.Row="2" 
                         Maximum="{Binding UrlCount}"
                         Value="{Binding UrlNumber}" />
            </Grid>
        </Border>
        
    </Grid>    
</Window>
