<UserControl x:Class="FFXIV_TexTools.Views.Wizard.WizardPageControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:FFXIV_TexTools.Views.Wizard"
             mc:Ignorable="d" 
             xmlns:resx="clr-namespace:FFXIV_TexTools.Resources"
             resx:Localization.Enabled="True"             
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <DataTemplate x:Key="CheckBoxTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Selected}"/>
                <TextBlock>
                    <Run Text="{Binding Name}"></Run><Run Foreground="DarkRed" Text="{Binding Path=NoDataIndicator, Mode=OneWay}"></Run>
                </TextBlock>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="RadioButtonTemplate">
            <StackPanel Orientation="Horizontal">
                <RadioButton GroupName="{Binding GroupName}" IsChecked="{Binding Selected}" />
                <TextBlock>
                    <Run Text="{Binding Name}"></Run><Run Foreground="DarkRed" Text="{Binding Path=NoDataIndicator, Mode=OneWay}"></Run>
                </TextBlock>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0">
            <GroupBox Grid.Row="0" Header="{Binding Source={x:Static resx:UIStrings.Options_List}}" Margin="5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40"/>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Button x:Name="SelectAllButton" Content="{Binding Source={x:Static resx:UIStrings.Select_All}}" Margin="5"  Grid.Column="1" Click="SelectAllButton_Click"/>
                    <Button x:Name="DeselectAllButton" Content="{Binding Source={x:Static resx:UIStrings.Deselect_All}}" Margin="5"  Grid.Column="0" Click="DeselectAllButton_Click"/>
                    
                    <ListBox x:Name="OptionsList" ScrollViewer.CanContentScroll="False" Grid.Row="1" Grid.ColumnSpan="2" SelectionChanged="OptionsList_SelectionChanged">
                        <ListBox.GroupStyle>
                            <GroupStyle>
                                <GroupStyle.HeaderTemplate>
                                    <DataTemplate>
                                        <Border BorderThickness="0,0,0,1">
                                            <Border.BorderBrush>
                                                <LinearGradientBrush EndPoint="1,0" MappingMode="RelativeToBoundingBox" StartPoint="0,1">
                                                    <GradientStop Color="Black" Offset="0"/>
                                                    <GradientStop Color="White" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.BorderBrush>
                                            <TextBlock FontWeight="Bold">
                                                <Run Text="{Binding Path=Name, Mode=OneWay}"></Run>
                                            </TextBlock>
                                        </Border>
                                    </DataTemplate>
                                </GroupStyle.HeaderTemplate>
                            </GroupStyle>
                        </ListBox.GroupStyle>
                        <ListBox.ItemTemplateSelector>
                            <local:ImportSelectionTemplateSelector RadioButtonTemplate="{StaticResource RadioButtonTemplate}" CheckBoxTemplate="{StaticResource CheckBoxTemplate}"/>
                        </ListBox.ItemTemplateSelector>
                    </ListBox>


                    <Grid Grid.Row="2" Grid.ColumnSpan="3" Visibility="{Binding Path=EditorVisibility}" Height="40">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" Content="Up" IsEnabled="{Binding Path=OptionSelected}"  Margin="5" Click="MoveGroupUp_Click"/>
                        <Button Grid.Column="1" Content="Down" IsEnabled="{Binding Path=OptionSelected}" Margin="5" Click="MoveGroupDown_Click"/>
                    </Grid>
                    
                    <Grid Grid.Row="3" Grid.ColumnSpan="3" Visibility="{Binding Path=EditorVisibility}" Height="40">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" Content="{Binding Source={x:Static resx:UIStrings.Delete}}" IsEnabled="{Binding Path=OptionSelected}"  Margin="5" Click="DeleteGroup_Click"/>
                        <Button Grid.Column="1" Content="{Binding Source={x:Static resx:UIStrings.Edit}}" IsEnabled="{Binding Path=OptionSelected}" Margin="5" Click="EditGroup_Click"/>
                        <Grid Grid.Column="2" x:Name="AddGroupGrid">
                            <Button Content="{Binding Source={x:Static resx:UIStrings.Add}}" Margin="5" Click="AddGroup_Click"/>
                            <Grid.ContextMenu>
                                <ContextMenu x:Name="AddContextMenu">
                                    <MenuItem Header="Standard Group" Click="AddStandardGroup_Click"></MenuItem>
                                    <MenuItem Header="IMC Mask Group" Click="AddImcGroup_Click"></MenuItem>
                                </ContextMenu>
                            </Grid.ContextMenu>
                        </Grid>
                    </Grid>
                </Grid>
            </GroupBox>
        </Grid>
        <Grid Column="1">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="1.5*"/>
            </Grid.RowDefinitions>
            <GroupBox Grid.Row="0" Header="{Binding Source={x:Static resx:UIStrings.Description}}" Margin="5">
                <TextBox x:Name="OptionDescriptionTextBox" IsReadOnly="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"/>
            </GroupBox>
            <GroupBox Grid.Row="1" Header="{Binding Source={x:Static resx:UIStrings.Preview}}" Margin="5">
                <Image x:Name="OptionPreviewImage"/>
            </GroupBox>
        </Grid>
    </Grid>
</UserControl>
