<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DataBindingView"
             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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:s="https://github.com/canton7/Stylet"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.50*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <materialDesign:Card Grid.Column="0"
                             UniformCornerRadius="0"
                             materialDesign:ShadowAssist.ShadowDepth="Depth3"
                             materialDesign:ShadowAssist.ShadowEdges="Right"
                             Background="{DynamicResource MaterialDesignPaper}"
                             Panel.ZIndex="2">
            <Grid Margin="10 5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <ComboBox Grid.Row="0"
                          Style="{StaticResource MaterialDesignFilledComboBox}"
                          Margin="0 5"
                          materialDesign:HintAssist.Hint="Data binding mode"
                          MinWidth="128"
                          SelectedValue="{Binding SelectedDataBindingMode}"
                          ItemsSource="{Binding DataBindingModes}"
                          SelectedValuePath="Value"
                          DisplayMemberPath="Description" />

                <TextBox Grid.Row="1"
                         Style="{StaticResource MaterialDesignFilledTextBox}"
                         Margin="0 5"
                         Text="{Binding EasingTime}"
                         materialDesign:TextFieldAssist.HasClearButton="True"
                         materialDesign:TextFieldAssist.SuffixText="ms"
                         materialDesign:HintAssist.Hint="Easing time"
                         IsEnabled="{Binding IsDataBindingEnabled}" />

                <ComboBox Grid.Row="2"
                          Style="{StaticResource MaterialDesignFilledComboBox}"
                          Margin="0 5"
                          materialDesign:HintAssist.Hint="Easing type"
                          MinWidth="128"
                          IsEnabled="{Binding IsEasingTimeEnabled}"
                          SelectedItem="{Binding SelectedEasingViewModel}"
                          ItemsSource="{Binding EasingViewModels}">
                    <ComboBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel />
                        </ItemsPanelTemplate>
                    </ComboBox.ItemsPanel>
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Polyline Stroke="{DynamicResource MaterialDesignBody}"
                                          StrokeThickness="1"
                                          Points="{Binding EasingPoints}"
                                          Stretch="Uniform"
                                          Width="14"
                                          Height="14"
                                          Margin="0 0 10 0" />
                                <TextBlock Text="{Binding Description}" />
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <materialDesign:Card Grid.Row="3" Grid.ColumnSpan="2" Margin="0 5 0 0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Margin="10 10 0 0">
                            Result
                        </TextBlock>
                        <TextBlock Grid.Row="0"
                                   Grid.Column="1"
                                   Margin="0 10 10 0"
                                   Visibility="{Binding AlwaysApplyDataBindings.Value, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}"
                                   ToolTip="Check 'Apply data bindings in editor'"
                                   Cursor="Help">
                            Other bindings not updating?
                        </TextBlock>
                        <Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignLightSeparator}" Margin="0" />
                        <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10 4 10 10">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TextBlock Margin="0 2" Visibility="{Binding ActiveItem.SupportsTestValue, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">Input</TextBlock>
                            <ContentControl Grid.Row="0"
                                            Grid.Column="1"
                                            Visibility="{Binding ActiveItem.SupportsTestValue, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
                                            s:View.Model="{Binding TestInputValue}"
                                            Margin="0 2"
                                            FontFamily="Consolas"
                                            VerticalAlignment="Stretch"
                                            HorizontalAlignment="Right" />

                            <TextBlock Grid.Row="1" Grid.Column="0" Margin="0 2">Output</TextBlock>
                            <ContentControl Grid.Row="1"
                                            Grid.Column="1"
                                            s:View.Model="{Binding TestResultValue}"
                                            Margin="0 2"
                                            FontFamily="Consolas"
                                            VerticalAlignment="Stretch"
                                            HorizontalAlignment="Right" />
                        </Grid>
                    </Grid>
                </materialDesign:Card>

                <Grid Grid.Row="4" VerticalAlignment="Bottom" Margin="0 5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0"
                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
                            Margin="0 0 5 0"
                            ToolTip="Copy the entire data binding"
                            Command="{s:Action CopyDataBinding}">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="ContentCopy" />
                            <TextBlock Text="COPY" Margin="8 0 0 0" />
                        </StackPanel>
                    </Button>
                    <Button Grid.Column="1"
                            Style="{StaticResource MaterialDesignRaisedAccentButton}"
                            Margin="5 0 0 0"
                            ToolTip="Paste the entire data binding"
                            Command="{s:Action PasteDataBinding}">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="ContentPaste" />
                            <TextBlock Text="PASTE" Margin="8 0 0 0" />
                        </StackPanel>
                    </Button>
                </Grid>
            </Grid>
        </materialDesign:Card>

        <materialDesign:Card Grid.Column="1" UniformCornerRadius="0" Background="{DynamicResource MaterialDesignToolBarBackground}" Panel.ZIndex="1">
            <Grid Margin="10 5">
                <ContentControl s:View.Model="{Binding ActiveItem}"
                                VerticalContentAlignment="Stretch"
                                HorizontalContentAlignment="Stretch"
                                IsTabStop="False" />
            </Grid>
        </materialDesign:Card>
    </Grid>
</UserControl>