<UserControl x:Class="FormDesigner.TextBoxPropertiesForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FormDesigner">

    <UserControl.Resources>
        <local:PDFDeviceColorToSolidColorBrushConverter x:Key="pdfDeviceColorToSolidColorBrushConverter"/>
        <local:BoolToVisibilityConverter x:Key="boolToVisibilityConverter"/>
        <local:ReverseBoolToVisibilityConverter x:Key="reverseBoolToVisibilityConverter"/>
    </UserControl.Resources>

    <Grid>
        <Grid Background="DarkGray" Opacity="0.4"/>

        <Grid Height="500" Width="500" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Border Background="#FAFAFA" BorderBrush="Black" BorderThickness="2">
                <Border.Effect>
                    <DropShadowEffect Color="Black" Opacity="0.6" Direction="315" ShadowDepth="5"/>
                </Border.Effect>
            </Border>

            <Grid Background="#FAFAFA" Margin="7">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="Field name:" VerticalAlignment="Center"/>
                    <TextBox Grid.Column="1" Margin="2" Text="{Binding Path=TextBoxField.Name, Mode=TwoWay}"/>

                    <TextBlock Grid.Row="1" Text="Tooltip:" VerticalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="1" Margin="2" Text="{Binding Path=TextBoxField.Tooltip, Mode=TwoWay}"/>
                </Grid>

                <Grid Grid.Row="1" Margin="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Grid Margin="6">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="30"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Visibility:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Column="1" Margin="2" ItemsSource="{Binding PDFFieldWidgetVisibilityStatuses}" SelectedItem="{Binding Path=TextBoxWidget.VisibilityStatus, Mode=TwoWay}"/>

                        <TextBlock Grid.Row="1" Text="Align:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Row="1" Grid.Column="1" Margin="2" ItemsSource="{Binding PDFFieldTextAlignments}" SelectedItem="{Binding Path=TextBoxWidget.Align, Mode=TwoWay}"/>

                        <TextBlock Grid.Column="2" Text="Orientation:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Column="3" Margin="2" ItemsSource="{Binding PDFRotationModes}" SelectedItem="{Binding Path=TextBoxWidget.Rotation, Mode=TwoWay}"/>
                    </Grid>

                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="30"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Border width:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Column="1" Margin="2" ItemsSource="{Binding BorderWidths}" SelectedIndex="{Binding Path=TextBoxWidget.BorderWidth, Mode=TwoWay}"/>

                        <TextBlock Grid.Row="1" Text="Border style:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Row="1" Grid.Column="1" Margin="2" ItemsSource="{Binding PDFBorderStyles}" SelectedItem="{Binding Path=TextBoxWidget.BorderStyle, Mode=TwoWay}"/>

                        <TextBlock Grid.Column="2" Text="Border color:" VerticalAlignment="Center"/>
                        <local:ColorUserControl Grid.Column="3" Margin="2" SelectedColor="{Binding Path=TextBoxWidget.BorderColor, Mode=TwoWay, Converter={StaticResource pdfDeviceColorToSolidColorBrushConverter}}"/>

                        <TextBlock Grid.Row="1" Grid.Column="2" Text="Fill color:" VerticalAlignment="Center"/>
                        <local:ColorUserControl Grid.Row="1" Grid.Column="3" Margin="2" SelectedColor="{Binding Path=TextBoxWidget.BackColor, Mode=TwoWay, Converter={StaticResource pdfDeviceColorToSolidColorBrushConverter}}"/>
                    </Grid>

                    <Grid Grid.Row="2">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="30"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="110"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Font:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Column="1" Grid.ColumnSpan="3" Margin="2" ItemsSource="{Binding Fonts}" SelectedIndex="{Binding SelectedFontIndex, Mode=TwoWay}"/>

                        <TextBlock Grid.Row="1" Text="Size:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Row="1" Grid.Column="1" Margin="2" ItemsSource="{Binding FontSizes}" SelectedValue="{Binding SelectedFontSize, Mode=TwoWay}"/>

                        <TextBlock Grid.Row="1" Grid.Column="2" Text="Color:" VerticalAlignment="Center"/>
                        <local:ColorUserControl Grid.Row="1" Grid.Column="3" Margin="2" SelectedColor="{Binding Path=TextBoxWidget.TextColor, Mode=TwoWay, Converter={StaticResource pdfDeviceColorToSolidColorBrushConverter}}"/>
                    </Grid>
                </Grid>

                <Grid Grid.Row="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <CheckBox Grid.Row="0" Grid.Column="0" Margin="4" Content="Multiline" IsChecked="{Binding Path=TextBoxField.Multiline, Mode=TwoWay}"/>
                    <CheckBox Grid.Row="1" Grid.Column="0" Margin="4" Content="Scroll long text" IsChecked="{Binding Path=TextBoxField.ScrollLongText, Mode=TwoWay}"/>
                    <StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" Margin="4">
                        <CheckBox Content="Limit of" Name="LimitCheckBox" VerticalAlignment="Center" IsChecked="{Binding IsLimitVisible, Mode=OneWay}" Unchecked="LimitCheckBoxCheckChanged" Checked="LimitCheckBoxCheckChanged"/>
                        <TextBox Margin="10,0,0,0" Width="70" Text="{Binding Path=TextBoxField.MaxLength, Mode=TwoWay}" Visibility="{Binding IsLimitVisible, Mode=OneWay, Converter={StaticResource boolToVisibilityConverter}}"/>
                        <TextBlock Text="characters" VerticalAlignment="Center"/>
                    </StackPanel>
                    <CheckBox Grid.Row="3" Grid.Column="0" Margin="4" Content="Password" IsChecked="{Binding Path=TextBoxField.Password, Mode=TwoWay}"/>
                    <CheckBox Grid.Row="4" Grid.Column="0" Margin="4" Content="Field is used for file selection" IsChecked="{Binding Path=TextBoxField.FileSelect, Mode=TwoWay}"/>
                    <CheckBox Grid.Row="5" Grid.Column="0" Margin="4" Content="Check spelling" IsChecked="{Binding Path=TextBoxField.CheckSpelling, Mode=TwoWay}"/>
                    <StackPanel Grid.Row="6" Grid.Column="0" Orientation="Horizontal" Margin="4">
                        <CheckBox Content="Comb of" VerticalAlignment="Center" IsChecked="{Binding IsComb, Mode=TwoWay}"/>
                        <TextBox Margin="10,0,0,0" Width="70" TextChanged="CombTextChanged" Text="{Binding Path=TextBoxField.MaxLength, Mode=TwoWay}" Visibility="{Binding IsComb, Converter={StaticResource boolToVisibilityConverter}}"/>
                        <TextBlock Text="characters" VerticalAlignment="Center"/>
                    </StackPanel>

                    <CheckBox Grid.Row="0" Grid.Column="1" Margin="4" Content="Read only" IsChecked="{Binding Path=TextBoxField.ReadOnly, Mode=TwoWay}"/>
                    <CheckBox Grid.Row="1" Grid.Column="1" Margin="4" Content="No export" IsChecked="{Binding Path=TextBoxField.NoExport, Mode=TwoWay}"/>
                    <CheckBox Grid.Row="2" Grid.Column="1" Margin="4" Content="Locked" IsChecked="{Binding IsLocked, Mode=TwoWay}"/>
                </Grid>

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="3" Margin="0,6,0,0">
                    <Button Margin="4" Width="100" Height="24" Content="OK" Click="Ok_Click" Visibility="{Binding IsCancelable, Converter={StaticResource boolToVisibilityConverter}}"/>
                    <Button Margin="4" Width="100" Height="24" Content="Cancel" Click="Cancel_Click" Visibility="{Binding IsCancelable, Converter={StaticResource boolToVisibilityConverter}}"/>
                    <Button Margin="4" Width="100" Height="24" Content="Close" Click="Ok_Click" Visibility="{Binding IsCancelable, Converter={StaticResource reverseBoolToVisibilityConverter}}"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
