<UserControl
    x:Class="Cube.Pdf.App.Editor.PositionControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:my="clr-namespace:Cube.Pdf.App.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.Text}"
        Margin="{StaticResource VerticalFirst}"
        Grid.Row="0">
        <StackPanel Orientation="Horizontal">
            <!-- **************************************************************
              Selected
            *************************************************************** -->
            <RadioButton
                Content="{Binding Position.Selected.Text}"
                IsEnabled="{Binding Position.Selected.Value}">
                <i:Interaction.Behaviors>
                    <my:InsertPositionBehavior
                        Command="{Binding Position.Command}"
                        CommandParameter="{Binding Data.SelectedIndex}" />
                </i:Interaction.Behaviors>
            </RadioButton>

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

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

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

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