<local:NodeControlBase  x:Class="Serein.Workbench.Node.View.FlowCallNodeControl"
                        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:local="clr-namespace:Serein.Workbench.Node.View"
                        xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
                        xmlns:converter="clr-namespace:Serein.Workbench.Converters"
                        xmlns:themes="clr-namespace:Serein.Workbench.Themes"
                        mc:Ignorable="d" 
                        MaxWidth="300"
                        d:DataContext="{d:DesignInstance vm:FlowCallNodeControlViewModel}">

    <UserControl.Resources>
        <converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
        <converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <converter:MethodDetailsSelectorConverter  x:Key="MethodDetailsSelector"/>
        <converter:InvertableBooleanToVisibilityConverter x:Key="InvertedBoolConverter"/>
    </UserControl.Resources>
    
    
    <Border BorderBrush="#C7FFE7"  BorderThickness="1">
        <Grid>
            <Grid.ToolTip>
                <ToolTip Background="LightYellow" Foreground="#071042" Content="{Binding NodeModel.MethodDetails}" />
            </Grid.ToolTip>
            
            
            
            
            <!--<TextBlock Text="{Binding NodeModel.DebugSetting.IsInterrupt}}"></TextBlock>-->
            <!--DataContext="{Binding}-->
            
            <Border x:Name="InterruptBorder" Tag="{Binding NodeModel.DebugSetting.IsInterrupt}">
                <Border.Style>
                    <Style TargetType="Border">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=Tag,RelativeSource={RelativeSource Mode=Self}}" Value="True">
                                <Setter Property="BorderBrush" Value="Red" />
                                <Setter Property="BorderThickness" Value="2" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=Tag,RelativeSource={RelativeSource Mode=Self}}" Value="False">
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="BorderThickness" Value="0" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>


                <Grid Background="#C7FFE7" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <local:ExecuteJunctionControl  Grid.Column="0"  NodeViewModel="{Binding}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
                        <StackPanel Grid.Column="1" Grid.RowSpan="2" Orientation="Horizontal">
                            
                            <TextBlock  Text="{Binding NodeModel.DisplayName, Mode=TwoWay}" HorizontalAlignment="Center"/>
                        </StackPanel>
                    </Grid>


                    <Grid x:Name="MethodInfoGrid" Grid.Row="2" Margin="10,0,10,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="画布" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="40"/>
                        <ComboBox Grid.Row="0"
                                  Grid.Column="1"
                                  DisplayMemberPath="Model.Name"  
                                  SelectedItem="{Binding SelectCanvas}" 
                                  ItemsSource="{Binding Canvass}"
                                  HorizontalAlignment="Stretch"
                                  HorizontalContentAlignment="Stretch"
                                  IsEnabled="{Binding IsEnabledOnView}"/>

                        <TextBlock Text="节点"  Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="40" Visibility="{Binding SelectCanvas.Model.PublicNodes, Converter={StaticResource CountToVisibilityConverter}}"/>
                        <ComboBox DisplayMemberPath="DisplayName"  
                                 Grid.Row="1" Grid.Column="1" 
                                 SelectedItem="{Binding SelectNode}"
                                 ItemsSource="{Binding SelectCanvas.Model.PublicNodes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 HorizontalAlignment="Stretch"
                                 HorizontalContentAlignment="Stretch"
                                 IsEnabled="{Binding IsEnabledOnView}"
                                 Visibility="{Binding SelectCanvas.Model.PublicNodes, UpdateSourceTrigger=PropertyChanged,Converter={StaticResource CountToVisibilityConverter}}">
                        </ComboBox>
                        
                        
                        <TextBlock Text="接口名称" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="50"/>
                        <TextBox Text="{Binding FlowCallNode.ApiGlobalName, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Width="{Binding ElementName=MethodDetailsControl,Path=ActualWidth}"/>

                        <themes:MethodDetailsControl Grid.Row="3" Grid.ColumnSpan="2" x:Name="MethodDetailsControl" NodeViewModel="{Binding}">
                            <themes:MethodDetailsControl.MethodDetails>
                                <MultiBinding Converter="{StaticResource MethodDetailsSelector}">
                                    <Binding Path="FlowCallNode.IsShareParam" UpdateSourceTrigger="PropertyChanged"/>
                                    <Binding Path="SelectNode.MethodDetails" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
                                    <Binding Path="FlowCallNode.MethodDetails" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
                                </MultiBinding>
                            </themes:MethodDetailsControl.MethodDetails>
                        </themes:MethodDetailsControl>
                    </Grid>
                    
                    <Border Grid.Row="2" x:Name="ParameterProtectionMask" 
                           
                            Background="#40508D" Opacity="0.5" BorderThickness="0" 
                            Visibility="{Binding NodeModel.DebugSetting.IsProtectionParameter, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter }}" />

                    <StackPanel Grid.Row="3" Background="Azure"  Orientation="Horizontal" Margin="3">
                        <StackPanel Orientation="Horizontal">
                            <CheckBox  IsChecked="{Binding FlowCallNode.IsShareParam, Mode=TwoWay}"/>
                            <TextBlock Text="共享参数"/>
                        </StackPanel>
                        
                        <StackPanel Orientation="Horizontal">
                            <CheckBox IsChecked="{Binding NodeModel.DebugSetting.IsEnable, Mode=TwoWay}"/>
                            <TextBlock Text="是否使能"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <CheckBox  IsChecked="{Binding NodeModel.DebugSetting.IsProtectionParameter, Mode=TwoWay}"/>
                            <TextBlock Text="参数保护"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <CheckBox  IsChecked="{Binding NodeModel.DebugSetting.IsInterrupt, Mode=TwoWay}"/>
                            <TextBlock Text="中断节点"/>
                        </StackPanel>


                    </StackPanel>

                </Grid>

            </Border>
        </Grid>
    </Border>
</local:NodeControlBase>
