<Window x:Class="SharepointToolbox.Views.Dialogs.SitePickerDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:loc="clr-namespace:SharepointToolbox.Localization"
        Title="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.title]}"
        Width="760" Height="560"
        WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
        Background="{DynamicResource AppBgBrush}"
        Foreground="{DynamicResource TextBrush}"
        TextOptions.TextFormattingMode="Ideal"
        Loaded="Window_Loaded">
  <Grid Margin="12">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <!-- Text filter row -->
    <DockPanel Grid.Row="0" Margin="0,0,0,6">
      <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.filter]}"
                 VerticalAlignment="Center" Margin="0,0,8,0" />
      <TextBox x:Name="FilterBox" TextChanged="FilterBox_TextChanged" />
    </DockPanel>

    <!-- Size + type filter row -->
    <DockPanel Grid.Row="1" Margin="0,0,0,8" LastChildFill="False">
      <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type]}"
                 VerticalAlignment="Center" Margin="0,0,6,0" />
      <ComboBox x:Name="TypeFilter" Width="170" SelectedIndex="0"
                SelectionChanged="TypeFilter_SelectionChanged" Margin="0,0,12,0">
        <ComboBoxItem Tag="All"
                      Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type.all]}" />
        <ComboBoxItem Tag="TeamSite"
                      Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type.team]}" />
        <ComboBoxItem Tag="CommunicationSite"
                      Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type.communication]}" />
        <ComboBoxItem Tag="Classic"
                      Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type.classic]}" />
        <ComboBoxItem Tag="Unknown"
                      Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.type.other]}" />
      </ComboBox>

      <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.size]}"
                 VerticalAlignment="Center" Margin="0,0,6,0" />
      <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.size.min]}"
                 VerticalAlignment="Center" Margin="0,0,4,0"
                 Foreground="{DynamicResource TextMutedBrush}" />
      <TextBox x:Name="MinSizeBox" Width="80" Margin="0,0,8,0"
               TextChanged="SizeBox_TextChanged" />
      <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.size.max]}"
                 VerticalAlignment="Center" Margin="0,0,4,0"
                 Foreground="{DynamicResource TextMutedBrush}" />
      <TextBox x:Name="MaxSizeBox" Width="80"
               TextChanged="SizeBox_TextChanged" />
    </DockPanel>

    <!-- Site list with checkboxes -->
    <ListView x:Name="SiteList" Grid.Row="2" Margin="0,0,0,8"
              SelectionMode="Single"
              BorderThickness="1" BorderBrush="{DynamicResource BorderSoftBrush}"
              GridViewColumnHeader.Click="SiteList_ColumnHeaderClick">
      <ListView.View>
        <GridView>
          <GridViewColumn Width="32">
            <GridViewColumn.Header>
              <GridViewColumnHeader Tag="IsSelected" Content="" />
            </GridViewColumn.Header>
            <GridViewColumn.CellTemplate>
              <DataTemplate>
                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          HorizontalAlignment="Center" />
              </DataTemplate>
            </GridViewColumn.CellTemplate>
          </GridViewColumn>
          <GridViewColumn Width="200" DisplayMemberBinding="{Binding Title}">
            <GridViewColumn.Header>
              <GridViewColumnHeader Tag="Title"
                                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.col.title]}" />
            </GridViewColumn.Header>
          </GridViewColumn>
          <GridViewColumn Width="280" DisplayMemberBinding="{Binding Url}">
            <GridViewColumn.Header>
              <GridViewColumnHeader Tag="Url"
                                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.col.url]}" />
            </GridViewColumn.Header>
          </GridViewColumn>
          <GridViewColumn Width="110" DisplayMemberBinding="{Binding KindDisplay}">
            <GridViewColumn.Header>
              <GridViewColumnHeader Tag="Kind"
                                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.col.type]}" />
            </GridViewColumn.Header>
          </GridViewColumn>
          <GridViewColumn Width="80" DisplayMemberBinding="{Binding SizeDisplay}">
            <GridViewColumn.Header>
              <GridViewColumnHeader Tag="StorageUsedMb"
                                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.col.size]}" />
            </GridViewColumn.Header>
          </GridViewColumn>
        </GridView>
      </ListView.View>
    </ListView>

    <!-- Status text -->
    <TextBlock x:Name="StatusText" Grid.Row="3" Margin="0,0,0,8"
               Foreground="{DynamicResource TextMutedBrush}" FontSize="11" />

    <!-- Button row -->
    <DockPanel Grid.Row="4">
      <Button x:Name="LoadButton"
              Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.btn.load]}"
              Width="110" Margin="0,0,8,0"
              Click="LoadButton_Click" />
      <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.btn.selectAll]}"
              Width="120" Margin="0,0,8,0"
              Click="SelectAll_Click" />
      <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.btn.deselectAll]}"
              Width="140" Margin="0,0,8,0"
              Click="DeselectAll_Click" />
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Right">
        <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.btn.ok]}"
                Width="80" Margin="4,0" IsDefault="True"
                Click="OK_Click" />
        <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[sitepicker.btn.cancel]}"
                Width="80" Margin="4,0" IsCancel="True" />
      </StackPanel>
    </DockPanel>
  </Grid>
</Window>
