<Window x:Class="ScratchNet.CreateFunctionDialogEx"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ScratchNet"
        xmlns:loc="clr-namespace:ScratchNet.Properties;assembly=ScriptEditor"
        FontSize="12"  SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
        Title="{x:Static loc:Language.CreateFuncTitle}" Height="300" Width="400" MinWidth="400" ResizeMode="NoResize">
    <Window.Resources>
        <DataTemplate DataType="{x:Type local:TextFunctionItem}">
            <TextBox BorderThickness="0" Background="Pink" MinWidth="20" Padding="2, 1" Margin="3, 0"
                     VerticalAlignment="Center" Text="{Binding Path=Value}" Tag="{Binding}" GotFocus="OnTextBoxGotFocus"/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:StringFunctionItem}">
            <TextBox BorderThickness="0" Background="White" MinWidth="20" Padding="2, 1" Margin="3,0"
                     VerticalAlignment="Center" Text="{Binding Path=Value}" Tag="{Binding}" GotFocus="OnTextBoxGotFocus"/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:BooleanFunctionItem}">
            <Grid Margin="3, 0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <Polygon VerticalAlignment="Stretch" Points="0, 4, 4, 0, 4, 8" SnapsToDevicePixels="True" 
                             Margin="0" Stretch="Fill" Width="7"
                             Fill="White"/>
                <Polygon VerticalAlignment="Stretch" Grid.Column="2" Points="0, 0, 0, 8, 4, 4" Stretch="Fill"
                             Fill="White"
                             SnapsToDevicePixels="True" Width="7"/>
                <TextBox Grid.Column="1" BorderThickness="0" Background="White" MinWidth="20" Padding="2, 1" Margin="0"
                     VerticalAlignment="Center" Text="{Binding Path=Value}" Tag="{Binding}" GotFocus="OnTextBoxGotFocus"/>
            </Grid>
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:NumberFunctionItem}">
            <Grid  Margin="3, 0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <Border VerticalAlignment="Stretch" CornerRadius="6,0,0,6 " Width="7" Grid.Column="0" 
                            Background="White" 
                            SnapsToDevicePixels="True" />
                <Border VerticalAlignment="Stretch" CornerRadius="0,6,6,0 " Width="7" Grid.Column="2" 
                            Background="White" 
                            SnapsToDevicePixels="True" />

                <TextBox Grid.Column="1" BorderThickness="0" Background="White" MinWidth="20" Padding="2, 1" Margin="0"
                     VerticalAlignment="Center" Text="{Binding Path=Value}" Tag="{Binding}" GotFocus="OnTextBoxGotFocus"/>
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" MinHeight="20"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto" MinHeight="20"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" MinWidth="20"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Canvas Margin="0" Grid.ColumnSpan="4" Name="DeleteCanvas">
            <Button Name="DeleteButton" Focusable="False" Visibility="Collapsed" Content="X" Click="OnDelete">
                <Button.Template>
                    <ControlTemplate>
                        <Label FontSize="10" FontWeight="Bold">X</Label>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </Canvas>
        <Grid MinWidth="50"
                      Margin="5,0,5,5" Grid.Row="1" Grid.ColumnSpan="4">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10" MaxWidth="10"/>
                <ColumnDefinition Width="20" MaxWidth="20"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Polygon Grid.Column="1" Points="5,0,0,4,20,4,15,0" 
                                 Fill="DarkViolet"
                                 Stroke="DarkViolet" 
                                 Stretch="Fill"/>
            <Border Margin="0,0,0,0" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Name="ViewBorder"
                            Background="DarkViolet"
                                
                            SnapsToDevicePixels="True">

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"
                            VerticalAlignment="Center" Focusable="False" Grid.ColumnSpan="3">
                    <TextBlock VerticalAlignment="Center" Margin="10,5,5,0" FontWeight="Bold" Foreground="Blue">function</TextBlock>
                    <TextBox BorderThickness="0" MinWidth="20" Padding="2, 1" Margin="3, 5,1,5" ToolTip="{x:Static loc:Language.FunctionName}"
                     VerticalAlignment="Center" Text="Name" Name="FunctionNameText"/>
                    <TextBlock VerticalAlignment="Center" Margin="1, 5">(</TextBlock>
                    <ItemsControl Name="FunctionStructure" Background="DarkViolet" MinWidth="50"
                      Margin="0">
                        <ItemsControl.Effect>
                            <DropShadowEffect BlurRadius="5" Direction="-90" RenderingBias="Performance" ShadowDepth="1"/>
                        </ItemsControl.Effect>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" 
                            VerticalAlignment="Center" Focusable="False" IsItemsHost="True"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.Template>
                            <ControlTemplate>
                                <StackPanel Orientation="Horizontal" Margin="0">
                                    <ItemsPresenter Margin="0"/>
                                </StackPanel>
                            </ControlTemplate>
                        </ItemsControl.Template>
                    </ItemsControl>
                    <TextBlock VerticalAlignment="Center" Margin="1, 5,5,1">)</TextBlock>
                </StackPanel>
            </Border>
            <Border Grid.Row="2" Grid.Column="0"  Background="DarkViolet"
                            SnapsToDevicePixels="True">
            </Border>

            <Border Grid.Row="4" Grid.Column="0"  
                                Background="DarkViolet"
                                SnapsToDevicePixels="True"/>
            <Polygon Grid.Row="4" Grid.Column="1" Points="0,0,0,4,5,0,15,0,20,4,20,0" 
                             Fill="DarkViolet" 
                                 Stretch="Fill" SnapsToDevicePixels="True"/>
            <Border Grid.Row="4" Grid.Column="2"  Background="DarkViolet"
                            SnapsToDevicePixels="True"
                                />
        </Grid>
        <TextBlock Text="{x:Static loc:Language.AddNumberParameter}" Grid.Row="2" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
        <TextBlock Text="{x:Static loc:Language.AddStringParameter}" Grid.Row="3" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
        <TextBlock Text="{x:Static loc:Language.AddBoolParameter}" Grid.Row="4" Grid.Column="1" Margin="5" VerticalAlignment="Center"/>
        <Button Content="{x:Static loc:Language.Number}" Grid.Row="2" Grid.Column="2" Width="80" Click="OnAddNumber" Margin="5"/>
        <Button Content="{x:Static loc:Language.String}" Grid.Row="3" Grid.Column="2" Width="80" Click="OnAddString" Margin="5"/>
        <Button Content="{x:Static loc:Language.Boolean}" Grid.Row="4" Grid.Column="2" Width="80" Click="OnAddBoolean" Margin="5"/>
        <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.ColumnSpan="5" HorizontalAlignment="Right">
            <Button Name="ButtonOK" Width="120" Content="{x:Static loc:Language.Confirm}" Margin="5" Click="OnConfirm" IsDefault="True"/>
            <Button Name="ButtonCancel" Width="120" Content="{x:Static loc:Language.Cancel}" Margin="5" Click="OnCancel" IsCancel="True"/>
        </StackPanel>
    </Grid>
</Window>
