<UserControl
    x:Class="Cube.Pdf.Editor.PositionControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:xc="clr-namespace:Cube.Xui.Converters;assembly=Cube.Xui"
    xmlns:my="clr-namespace:Cube.Pdf.Editor"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="100"
    d:DesignWidth="600">

    <!-- **********************************************************************
      Resources
    *********************************************************************** -->
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Themes/GenericDialog.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Themes/InsertStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <!-- **********************************************************************
      Main
    *********************************************************************** -->
    <GroupBox
        Header="{Binding Position.Select.Text}"
        Margin="{StaticResource VerticalFirst}"
        Grid.Row="0">
        <StackPanel Orientation="Horizontal">
            <!-- **************************************************************
              Selected
            *************************************************************** -->
            <RadioButton
                Content="{Binding Position.SelectedIndex.Text}"
                IsEnabled="{Binding Position.SelectedIndex.Value, Converter={xc:PositiveOrZero}}">
                <i:Interaction.Behaviors>
                    <my:InsertPositionBehavior
                        Command="{Binding Position.Select.Command}"
                        CommandParameter="{Binding Position.SelectedIndex.Value}" />
                </i:Interaction.Behaviors>
            </RadioButton>

            <!-- **************************************************************
              First
            *************************************************************** -->
            <RadioButton Content="{Binding Position.First.Text}">
                <i:Interaction.Behaviors>
                    <my:InsertPositionBehavior
                        Command="{Binding Position.Select.Command}"
                        CommandParameter="{StaticResource NegativeOne}" />
                </i:Interaction.Behaviors>
            </RadioButton>

            <!-- **************************************************************
              Last
            *************************************************************** -->
            <RadioButton Content="{Binding Position.Last.Text}">
                <i:Interaction.Behaviors>
                    <my:InsertPositionBehavior
                        Command="{Binding Position.Select.Command}"
                        CommandParameter="{Binding Position.Count.Value}" />
                </i:Interaction.Behaviors>
            </RadioButton>

            <!-- **************************************************************
              UserIndex
            *************************************************************** -->
            <RadioButton
                x:Name="UserIndexRadioButton"
                Content="{Binding Position.UserIndex.Text}"
                IsChecked="True">
                <i:Interaction.Behaviors>
                    <my:InsertPositionBehavior
                        Command="{Binding Position.Select.Command}"
                        CommandParameter="{Binding Position.UserIndex.Value}" />
                </i:Interaction.Behaviors>
            </RadioButton>

            <StackPanel
                Orientation="Horizontal"
                IsEnabled="{Binding IsChecked, ElementName=UserIndexRadioButton}">
                <TextBox
                    Text="{Binding Position.UserIndex.Value}"
                    Style="{StaticResource InsertPositionStyle}" />
                <TextBlock Text="{Binding Position.Count.Text}" />
            </StackPanel>
        </StackPanel>
    </GroupBox>
</UserControl>
