<UserControl
    x:Class="BPASmartClient.DosingSystem.View.RecipeSettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
    xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">

    <UserControl.Resources>
        <SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
        <SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
        <SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
        <SolidColorBrush x:Key="CursorColor" Color="Aqua" />
        <SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
        <SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" />

        <Style x:Key="TextBlockStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="楷体" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Background" Value="Transparent" />
            <!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />-->
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Center" />
        </Style>

        <Style x:Key="buttonStyle" TargetType="Button">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Foreground" Value="Aqua" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="BorderThickness" Value="0" />
        </Style>

    </UserControl.Resources>

    <UserControl.DataContext>
        <vm:RecipeSettingsViewModel />
    </UserControl.DataContext>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="30" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <!--#region 操作按钮-->
        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
            <pry:IcoButton
                Grid.Column="3"
                Width="140"
                Margin="10"
                HorizontalAlignment="Left"
                Command="{Binding NewRecipe}"
                Content="新建配方"
                FontSize="16"
                Foreground="Aqua"
                IcoText="&#xe626;"
                Style="{StaticResource NewButtonStyle}" />

            <pry:IcoButton
                Grid.Column="3"
                Width="140"
                Margin="10"
                HorizontalAlignment="Left"
                Command="{Binding SaveRecipe}"
                Content="保存配方"
                EnableColor="#FFB7B7B7"
                FontSize="17"
                Foreground="Aqua"
                IcoText="&#xe936;"
                IsEnabled="True"
                Style="{StaticResource NewButtonStyle}" />
        </StackPanel>
        <!--#endregion-->

        <!--#region 表格标题栏设置-->
        <!--<Grid Grid.Row="1" Background="#dd2AB2E7">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.3*" />
                <ColumnDefinition />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition Width="0" />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition Width="0.5*" />
            </Grid.ColumnDefinitions>

            <TextBlock
                Grid.Column="0"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="序号" />

            <Grid Grid.Column="1">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="配方名称" />
                <Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
            </Grid>

            <TextBlock
                Grid.Column="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="编码" />

            <Grid Grid.Column="3">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="结束时间" />
                <Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
            </Grid>

            <Grid Grid.Column="5">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="制作状态" />
                <Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" />
            </Grid>

            <TextBlock
                Grid.Column="6"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="完成时间" />

        </Grid>-->
        <!--#endregion-->

        <!--#region 表格数据显示-->
        <ScrollViewer
            Grid.Row="2"
            HorizontalScrollBarVisibility="Hidden"
            VerticalScrollBarVisibility="Hidden">
            <ItemsControl ItemsSource="{Binding Recipes}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <RadioButton Background="Transparent" GroupName="all">
                            <RadioButton.Template>
                                <ControlTemplate TargetType="RadioButton">

                                    <Grid Name="gr" Height="30">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="0.3*" />
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="0.7*" />
                                            <ColumnDefinition Width="0.7*" />
                                            <ColumnDefinition Width="0" />
                                            <ColumnDefinition Width="0.7*" />
                                            <ColumnDefinition Width="0.5*" />
                                        </Grid.ColumnDefinitions>

                                        <TextBlock
                                            Grid.Column="0"
                                            Foreground="#ff00ccff"
                                            Style="{StaticResource TextBlockStyle}"
                                            Text="{Binding SerialNum}" />

                                        <Grid Grid.Column="1">
                                            <TextBlock
                                                Margin="5,0,0,0"
                                                HorizontalAlignment="Left"
                                                Foreground="#ff00ccff"
                                                Style="{StaticResource TextBlockStyle}"
                                                Text="{Binding RecipeName}" />
                                        </Grid>


                                        <TextBlock
                                            Grid.Column="2"
                                            Foreground="#ff00ccff"
                                            Style="{StaticResource TextBlockStyle}"
                                            Text="{Binding RecipCode}" />

                                        <!--<Grid Grid.Column="3">

                                            <Button
                                                Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
                                                CommandParameter="{Binding RecipCode}"
                                                Content="编辑"
                                                Style="{StaticResource buttonStyle}" />
                                        </Grid>-->


                                        <Grid Grid.Column="5">
                                            <Button
                                                Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
                                                CommandParameter="{Binding RecipCode}"
                                                Content="详情"
                                                Style="{StaticResource buttonStyle}" />
                                        </Grid>

                                        <Grid Grid.Column="6">
                                            <Button
                                                Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
                                                CommandParameter="{Binding RecipCode}"
                                                Content="删除"
                                                Style="{StaticResource buttonStyle}" />
                                        </Grid>

                                    </Grid>

                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsChecked" Value="True">
                                            <Setter TargetName="gr" Property="Background" Value="#3300ccff" />
                                        </Trigger>

                                        <Trigger Property="IsMouseOver" Value="true">
                                            <Setter TargetName="gr" Property="Background" Value="#3300ccff" />
                                        </Trigger>

                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </RadioButton.Template>
                        </RadioButton>


                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        <!--#endregion-->
    </Grid>
</UserControl>
