<Window x:Class="Dependencies.SearchFolder"
        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"
        xmlns:local="clr-namespace:Dependencies"
        mc:Ignorable="d"
        Title="Search folders customization" Height="400" Width="600">
    <Grid Margin="10 10 10 10" MinHeight="100"  MinWidth="560">

        <Grid.RowDefinitions>
            <RowDefinition Height="0*"/>
            <RowDefinition Height="30*"/>
            <RowDefinition Height="276*"/>
            <RowDefinition Height="36*"/>
            <RowDefinition Height="7*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="139"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="30"/>
            </Grid.ColumnDefinitions>

            <Label Content="Binary current directory:" 
                   VerticalAlignment="Center"
                   Grid.Column="0"
                   Height="26" Margin="0,2"
                   />

            <TextBox Text="{Binding Path=WorkingDirectory, Mode=OneWay}"
                    Name="WorkingDirectoryTextBox"
                    TextWrapping="Wrap" 
                    HorizontalContentAlignment="Stretch"
                    HorizontalAlignment="Stretch"
                    Width="auto" 
                    Grid.Column="1" Margin="0,5"
                    />

            <Button Content="..."
                    Margin="2,5,0,5"
                    Click="OnBinaryWorkindDirectoryChange"
                    Grid.Column="2"/>
        </Grid>

        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="29*"/>
                <RowDefinition Height="247*"/>
            </Grid.RowDefinitions>

            <Label Content="Additional search folders:" 
                   HorizontalAlignment="Left" 
                   HorizontalContentAlignment="Left"
                   VerticalAlignment="Top"
                   Grid.Row="0"
                   Height="25"
                   Margin="0 0 0 0" Width="144"
                   />

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="70*"/>
                    <ColumnDefinition Width="10"/>
                    <ColumnDefinition Width="80"/>
                </Grid.ColumnDefinitions>

                <ListBox ItemsSource="{Binding Path=SearchFolders}" 
                     Name="SearchFoldersList"
                     Height="auto" 
                     Margin="2,0,0,0" 
                     VerticalAlignment="Stretch"
                     VerticalContentAlignment="Stretch"
                     HorizontalContentAlignment="Stretch"
                     HorizontalAlignment="Stretch"
                     Width="auto" 
                     AllowDrop="True" 
                     Drop="SearchFolder_Drop" 
                     DragOver="SearchFolder_DragOver" 
                     DragLeave="SearchFolder_DragLeave" 
                     MouseDoubleClick ="SearchFoldersList_MouseDoubleClick"
                     SelectionChanged="OnSearchFolderViewSelectedItemChanged"
                     Background="#FFE2E2E2" 
                     FontSize="10"
                     Grid.Column="0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Path=Folder}"/>
                                <TextBox  Text="{Binding Path=Folder}" Visibility="{Binding IsEditable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

                <Grid Grid.Column="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="10"/>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="150*"/>
                    </Grid.RowDefinitions>

                    <Button Content="New" 
                        Height="20"
                        Margin="2,0,2,10"
                        
                        Click="OnNewEntry"
                        Grid.Row="0"/>

                    <Button Content="Edit" 
                        Height="20"
                        Margin="2,0,2,10"
                        Click="OnEditEntry"
                        Grid.Row="1"/>

                    <Button Content="Browse ..." 
                        Height="20"
                        Margin="2,0,2,10"
                        Click="OnBrowseEntry"
                        Grid.Row="2"/>

                    <Button Content="Delete" 
                        Height="20"
                        Margin="2,0,2,10"
                        Click="OnDeleteEntry"
                        Grid.Row="3"/>

                    <Button Content="Move Up" 
                        Height="20"
                        Margin="2,0,2,10"
                        Click="OnMoveUpEntry"
                        Grid.Row="5"/>

                    <Button Content="Move Down" 
                        Height="20"
                        Margin="2,0,2,10"
                        Click="OnMoveDownEntry"
                        Grid.Row="6"/>
                </Grid>
            </Grid>
        </Grid>

        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150*"/>
                <ColumnDefinition Width="70"/>
                <ColumnDefinition Width="70"/>
            </Grid.ColumnDefinitions>

            <Button Content="Cancel" 
                    Height="20"
                    Margin="2 0 2 0"
                    Click="OnCancel"
                    Grid.Column="1"/>

            <Button Content="OK" 
                    Height="20"
                    Margin="2 0 2 0"
                    Click="OnValidate"
                    Grid.Column="2"/>
        </Grid>
    </Grid>
</Window>
