<UserControl x:Class="FormDesigner.DropDownListPropertiesForm"
   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"/>
                    <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=DropDownListField.Name, Mode=TwoWay}"/>

                    <TextBlock Grid.Row="1" Text="Tooltip:" VerticalAlignment="Center"/>
                    <TextBox Grid.Row="1" Grid.Column="1" Margin="2" Text="{Binding Path=DropDownListField.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"/>
                        </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=DropDownListWidget.VisibilityStatus, Mode=TwoWay}"/>

                        <TextBlock Grid.Column="2" Text="Orientation:" VerticalAlignment="Center"/>
                        <ComboBox Grid.Column="3" Margin="2" ItemsSource="{Binding PDFRotationModes}" SelectedItem="{Binding Path=DropDownListWidget.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=DropDownListWidget.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=DropDownListWidget.BorderStyle, Mode=TwoWay}"/>

                        <TextBlock Grid.Column="2" Text="Border color:" VerticalAlignment="Center"/>
                        <local:ColorUserControl Grid.Column="3" Margin="2" SelectedColor="{Binding Path=DropDownListWidget.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=DropDownListWidget.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=DropDownListWidget.TextColor, Mode=TwoWay, Converter={StaticResource pdfDeviceColorToSolidColorBrushConverter}}"/>
                    </Grid>
                </Grid>

                <Grid Grid.Row="3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <!--Up part of the window: name, value, listbox and buttons-->
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="80"/>
                        </Grid.ColumnDefinitions>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>

                            <!--Name and value-->
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Column="0" Text="Name:" VerticalAlignment="Center"/>
                                <TextBox Grid.Column="1" Margin="2" Name="NameTextBox"/>

                                <TextBlock Grid.Column="2" Text="Value:" VerticalAlignment="Center"/>
                                <TextBox Grid.Column="3" Margin="2" Name="ValueTextBox"/>
                            </Grid>

                            <ListBox Grid.Row="1" Name="ListBoxUi" BorderThickness="1" BorderBrush="Black" Margin="2" ItemsSource="{Binding ListBoxItems}" DisplayMemberPath="Name" SelectionChanged="ListBoxUi_SelectionChanged"/>
                        </Grid>

                        <!--Buttons-->
                        <Grid Grid.Column="1">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Button Grid.Row="0" Margin="4" Height="24" Content="Add" Click="AddItem_Click"/>
                            <Button Grid.Row="1" Margin="4" Height="24" Content="Delete" Click="DeleteItem_Click" IsEnabled="{Binding IsDeleteEnabled}"/>
                            <Button Grid.Row="2" Margin="4" Height="24" Content="Up" Click="Up_Click" IsEnabled="{Binding IsUpEnabled}"/>
                            <Button Grid.Row="3" Margin="4" Height="24" Content="Down" Click="Down_Click" IsEnabled="{Binding IsDownEnabled}"/>
                        </Grid>
                    </Grid>

                    <!--Down part with checkboxes-->
                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <CheckBox Grid.Row="0" Grid.Column="0" Margin="2" Content="Sort items" IsChecked="{Binding Path=DropDownListField.Sort, Mode=TwoWay}"/>
                        <CheckBox Grid.Row="1" Grid.Column="0" Margin="2" Content="Multiple selection" IsChecked="{Binding Path=DropDownListField.MultipleSelection, Mode=TwoWay}"/>
                        <CheckBox Grid.Row="2" Grid.Column="0" Margin="2" Content="Check spelling" IsChecked="{Binding Path=DropDownListField.CheckSpelling, Mode=TwoWay}"/>
                        <CheckBox Grid.Row="3" Grid.Column="0" Margin="2" Content="Commit selected value immediately" IsChecked="{Binding Path=DropDownListField.CommitOnSelChange, Mode=TwoWay}"/>

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

                <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right" 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>
