<UserControl x:Class="SharepointToolbox.Views.Tabs.DuplicatesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:SharepointToolbox.Localization"
             xmlns:common="clr-namespace:SharepointToolbox.Views.Common">
    <DockPanel LastChildFill="True">
        <!-- Options panel -->
        <ScrollViewer DockPanel.Dock="Left" Width="240" VerticalScrollBarVisibility="Auto" Margin="8,8,4,8">
            <StackPanel>
                <GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[grp.dup.type]}" Margin="0,0,0,8">
                    <StackPanel Margin="4">
                        <RadioButton Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[rad.dup.files]}"
                                     IsChecked="{Binding ModeFiles}" Margin="0,2" />
                        <RadioButton Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[rad.dup.folders]}"
                                     IsChecked="{Binding ModeFolders}" Margin="0,2" />
                    </StackPanel>
                </GroupBox>

                <GroupBox Margin="0,0,0,8">
                    <GroupBox.Header>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[grp.dup.criteria]}" VerticalAlignment="Center" />
                            <common:InfoButton Margin="6,0,0,0"
                                               Title="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.dup.criteria.title]}"
                                               Body="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.dup.criteria.body]}" />
                        </StackPanel>
                    </GroupBox.Header>
                    <StackPanel Margin="4">
                        <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[lbl.dup.note]}"
                                   TextWrapping="Wrap" FontSize="11" Foreground="{DynamicResource TextMutedBrush}" Margin="0,0,0,6" />
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.dup.size]}"
                                  IsChecked="{Binding MatchSize}" Margin="0,2" />
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.dup.created]}"
                                  IsChecked="{Binding MatchCreated}" Margin="0,2" />
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.dup.modified]}"
                                  IsChecked="{Binding MatchModified}" Margin="0,2" />
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.dup.subfolders]}"
                                  IsChecked="{Binding MatchSubfolders}" Margin="0,2" />
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.dup.filecount]}"
                                  IsChecked="{Binding MatchFileCount}" Margin="0,2" />
                    </StackPanel>
                </GroupBox>

                <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[lbl.library]}" />
                <TextBox Text="{Binding Library, UpdateSourceTrigger=PropertyChanged}" Height="26"
                         ToolTip="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[ph.dup.lib]}" Margin="0,0,0,6" />

                <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.include.subsites]}"
                          IsChecked="{Binding IncludeSubsites}" Margin="0,4,0,8" />

                <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[btn.run.scan]}"
                        Command="{Binding RunCommand}" Height="28" Margin="0,0,0,4" />
                <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[btn.cancel]}"
                        Command="{Binding CancelCommand}" Height="28" Margin="0,0,0,8" />

                <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.split.label]}" Margin="0,4,0,0" />
                <ComboBox SelectedIndex="{Binding SplitModeIndex}" Height="26" Margin="0,0,0,4">
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.split.single]}" />
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.split.bySite]}" />
                </ComboBox>
                <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.html.layout.label]}" Margin="0,2,0,0" />
                <ComboBox SelectedIndex="{Binding HtmlLayoutIndex}" Height="26" Margin="0,0,0,6">
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.html.layout.separate]}" />
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[export.html.layout.tabbed]}" />
                </ComboBox>

                <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.btn.exportCsv]}"
                        Command="{Binding ExportCsvCommand}" Height="28" Margin="0,0,0,4" />
                <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.btn.exportHtml]}"
                        Command="{Binding ExportHtmlCommand}" Height="28" Margin="0,0,0,4" />

                <TextBlock Text="{Binding StatusMessage}" TextWrapping="Wrap" FontSize="11" Foreground="{DynamicResource TextMutedBrush}" Margin="0,4" />
            </StackPanel>
        </ScrollViewer>

        <!-- Results DataGrid -->
        <DataGrid ItemsSource="{Binding Results}" IsReadOnly="True" AutoGenerateColumns="False"
                  VirtualizingPanel.IsVirtualizing="True" Margin="4,8,8,8"
                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  ColumnWidth="Auto">
            <DataGrid.Columns>
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[duplicates.col.group]}"
                                    Binding="{Binding GroupName}" Width="160" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[duplicates.col.copies]}"
                                    Binding="{Binding GroupSize}" Width="60"
                                    ElementStyle="{StaticResource RightAlignStyle}" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.name]}"
                                    Binding="{Binding Name}" Width="160" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.library]}"
                                    Binding="{Binding Library}" Width="120" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.size]}"
                                    Binding="{Binding SizeBytes, Converter={StaticResource BytesConverter}}"
                                    Width="90" ElementStyle="{StaticResource RightAlignStyle}" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.created]}"
                                    Binding="{Binding Created, StringFormat=yyyy-MM-dd}" Width="100" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.modified]}"
                                    Binding="{Binding Modified, StringFormat=yyyy-MM-dd}" Width="100" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[report.col.path]}"
                                    Binding="{Binding Path}" Width="400" />
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
