<UserControl x:Class="Machinations.WPF.ComponentsSettings"
             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:converters="clr-namespace:Machinations.WPF.Converters"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
        <converters:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter"/>
        <Style TargetType="ToggleButton">
            <Setter Property="Width" Value ="100"/>
            <Setter Property="Height" Value ="20"/>
            <Setter Property="Background" Value ="White"/>
            <Setter Property="Margin" Value="1"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="CheckBox">
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style>
    </UserControl.Resources>
    <StackPanel x:Name="SettingsPanel" Margin="5">
        <StackPanel x:Name="GraphSettings"  Visibility="{Binding IsMachinationsGraph, Converter={StaticResource BoolToVisConverter}}">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Name" />
                <TextBox Grid.Column="1" Text="{Binding GraphName, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Author"/>
                <TextBox Grid.Column="1" Text="{Binding GraphAuthor, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="TimeMode"/>
                <ComboBox Grid.Column="1" SelectedIndex="{Binding GraphSelectedTimeMode}" IsEnabled="True">
                    <ComboBoxItem Content="turn-based"/>
                    <ComboBoxItem Content="asynchronous"/>
                    <ComboBoxItem Content="synchronous"/>
                </ComboBox>
            </Grid>
            <Grid Margin="2" Visibility="{Binding GraphActionIsVisible,
                Converter={StaticResource InverseBoolToVisibilityConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Interval"/>
                <TextBox Grid.Column="1" Text="{Binding GraphFireInterval, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2" Visibility="{Binding GraphActionIsVisible, Converter={StaticResource BoolToVisConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Actions/Turn"/>
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding GraphActionsPerTurn}" Minimum="1" Maximum="100" Increment="1"/> 
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Distribution"/>
                <ComboBox Grid.Column="1" SelectedIndex="{Binding GraphDistributionIndex}" IsEnabled="False">
                    <ComboBoxItem Content="instantaneous"/>
                    <ComboBoxItem Content="fixed speed"/>
                </ComboBox>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Color coding"/>
                <CheckBox Grid.Column="1" IsChecked="{Binding GraphColorCoding}"/>
            </Grid>
             <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Skip turn"/>
                <CheckBox Grid.Column="1" IsChecked="{Binding CanSkipTurn}"/>
            </Grid>
            <!--<Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Pull all skips inh"/>
                <CheckBox Grid.Column="1" IsChecked="{Binding PullAllSkipsInhibited}"/>
            </Grid>-->
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Dice"/>
                <TextBox Grid.Column="1" Text="{Binding GraphDice, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Skill"/>
                <TextBox Grid.Column="1" Text="{Binding GraphSkill, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Multiplayer"/>
                <TextBox Grid.Column="1" Text="{Binding GraphMultiplayer, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Strategy"/>
                <TextBox Grid.Column="1" Text="{Binding GraphStrategy, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Width"/>
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding GraphWidth}" Minimum="300" Maximum="3000" Increment="100"/>
                <!--<TextBox Grid.Column="1" Text="{Binding GraphWidth, UpdateSourceTrigger=PropertyChanged}"/>-->
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Height"/>
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding GraphHeight}" Minimum="300" Maximum="3000" Increment="100"/>
                <!--<TextBox Grid.Column="1" Text="{Binding GraphHeight, UpdateSourceTrigger=PropertyChanged}"/>-->
            </Grid>

        </StackPanel>
        <StackPanel Name ="BaseElementSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Color"/>
                <xctk:ColorPicker Grid.Column="1"
                                  Name="ClrPckerBackground" 
                                  SelectedColor="{Binding SelectedColor}"/>
                <!--<TextBox Grid.Column="1" Text="{Binding SelectedColor, UpdateSourceTrigger=PropertyChanged}"/>-->
            </Grid>
            <Grid Margin="2" Visibility="{Binding HasTurnPools , Converter={StaticResource BoolToVisConverter}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="Turn pools"/>
                <ListView Grid.Row="1" 
                          ItemsSource="{Binding GraphSpecialPools}"
                          SelectionMode="Multiple"
                          SelectionChanged="Selector_OnSelectionChanged"
                          IsSynchronizedWithCurrentItem="True">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" MouseEnter="UIElement_OnMouseEnter" MouseLeave="UIElement_OnMouseLeave">
                                <TextBlock Text="Pool"  Margin="0,0,10,0"/>
                                <TextBlock Text="{Binding Id}" Margin="0,0,10,0"/>
                                <TextBlock Text="{Binding Caption}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>
        </StackPanel>
        <StackPanel Name="NodeSettings" Visibility="Collapsed" >
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Label" Width="80"/>
                <TextBox Grid.Column="1" Text="{Binding SelectedLabel, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Activation"/>
                <ComboBox Grid.Column="1" SelectedIndex="{Binding SelectedNodeActivationIndex}">
                    <ComboBoxItem Content="Passive"/>
                    <ComboBoxItem Content="Interactive"/>
                    <ComboBoxItem Content="Automatic"/>
                    <ComboBoxItem Content="OnStart"/>
                </ComboBox>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Actions" Width="80"/>
                <TextBox Grid.Column="1" Text="{Binding SelectedNodeActions, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Pull Mode"/>
                <ComboBox Grid.Column="1" SelectedIndex="{Binding SelectedNodePullIndex}">
                    <ComboBoxItem Content="Pull any"/>
                    <ComboBoxItem Content="Pull all"/>
                    <ComboBoxItem Content="Push any"/>
                    <ComboBoxItem Content="Push all"/>
                </ComboBox>
            </Grid>
        </StackPanel>
        <StackPanel Name="SourceSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Resources" Width="80"/>
                <xctk:ColorPicker Grid.Column="1"
                                  SelectedColor="{Binding SelectedNodeResourcesColor}"/>
            </Grid>
        </StackPanel>
        <StackPanel Name="PoolSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Number" />
                <TextBox Grid.Column="1" Text="{Binding SelectedPoolResources, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Capacity" />
                <TextBox Grid.Column="1" Text="{Binding SelectedPoolCapacity, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2" Visibility="{Binding IsMachinationsGraph, Converter={StaticResource BoolToVisConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="TurnPool" />
                <CheckBox Grid.Column="1" IsChecked="{Binding SelectedTurnPool, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2" Visibility="{Binding IsMachinationsGraph, Converter={StaticResource BoolToVisConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="TurnPoolMode" />
                <ComboBox Grid.Column="1" IsEnabled="{Binding SelectedTurnPool}" SelectedIndex="{Binding SelectedTurnPoolMode}">
                    <ComboBoxItem Content="Normal"/>
                    <ComboBoxItem Content="Inverse"/>
                </ComboBox>
            </Grid>
            <ToggleButton Content="Fire twice" IsChecked="{Binding FireTwice}"/>
        </StackPanel>
        <StackPanel Name="GateSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Type" />
                <ComboBox Grid.Column ="1" SelectedIndex="{Binding SelectedGateModeIndex}">
                    <ComboBoxItem Content="Deterministic"/>
                    <ComboBoxItem Content="Dice"/>
                    <ComboBoxItem Content="Skill"/>
                    <ComboBoxItem Content="Multiplayer"/>
                    <ComboBoxItem Content="Strategy"/>
                </ComboBox>
            </Grid>
        </StackPanel>
        <StackPanel Name="ConnectionSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Line label" />
                <TextBox Grid.Column="1" Text="{Binding SelectedLabel, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
             <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Thickness" />
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding Thickness}" Minimum="0" Maximum="5" Increment="1"/>
            </Grid>
            <!--<Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Min. value" />
                <TextBox Grid.Column="1" Text="{Binding SelectedLineOrRegisterMinValue, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Max. value" />
                <TextBox Grid.Column="1" Text="{Binding SelectedLineOrRegisterMaxValue, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>-->
        </StackPanel>
        <StackPanel Name="StateConnectionSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Common values" />
                <ComboBox Grid.Column="1" ItemsSource="{Binding CommonStateCValues}" SelectedItem="{Binding SelectedCommonValue}" />
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Only increase" />
                <CheckBox Grid.Column="1" IsChecked="{Binding ForwardOnly}"/>
            </Grid>
        </StackPanel>
        <StackPanel Name="DelaySettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Queue" Width="80"/>
                <CheckBox Grid.Column="1" IsChecked="{Binding SelectedDelayIsQueue}"/>
            </Grid>
        </StackPanel>
        <StackPanel Name="RegisterSettings" Visibility="Collapsed">
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Line label" />
                <TextBox Grid.Column="1" Text="{Binding SelectedLabel, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Interactive"/>
                <CheckBox Grid.Column="1" IsChecked="{Binding SelectedRegisterIsInteractive}"/>
            </Grid>
            <Grid Margin="2" Visibility="{Binding SelectedRegisterIsInteractive, Converter={StaticResource BoolToVisConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Starting Value"/>
                <TextBox Grid.Column="1" Text="{Binding SelectedRegisterStartingValue, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
            <Grid Margin="2" Visibility="{Binding SelectedRegisterIsInteractive, Converter={StaticResource BoolToVisConverter}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Step"/>
                <TextBox Grid.Column="1" Text="{Binding SelectedRegisterStep, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
        </StackPanel>
        <StackPanel Name="AiSettings" Visibility="Collapsed">
            <TextBlock Text="Script:" Width="80" HorizontalAlignment="Left"/>
            <TextBox Text="{Binding SelectedAIScript, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap" MaxWidth="180"/>
        </StackPanel>
        <StackPanel Name="UserComponentSettings" Visibility="Collapsed" >
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Size" Width="80"/>
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding UserComponentRadius}" Minimum="60" Maximum="260" Increment="20"/>
            </Grid>
            <Grid Margin="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="Card color" Width="80"/>
            <xctk:ColorPicker Grid.Column="1" SelectedColor="{Binding UserComponentColor}"/>
        </Grid>
        </StackPanel>
        <StackPanel Name="CardsSettings" Visibility="Collapsed" >
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Showed card" Width="80"/>
                <xctk:ShortUpDown Grid.Column="1" Value="{Binding ShowedCard}" Minimum="0" Maximum="{Binding CardsCount}" Increment="1"/>
            </Grid>
        </StackPanel>
        <StackPanel Name="NameSettings" Visibility="Collapsed" >
            <Grid Margin="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="Label" Width="80"/>
                <TextBox Grid.Column="1" Text="{Binding SelectedLabel, UpdateSourceTrigger=PropertyChanged}"/>
            </Grid>
        </StackPanel>
    </StackPanel>
</UserControl>
