<Window x:Class="MegaRobo.C00225155App.MenuViews.EditSampleBottlePropertiesWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MegaRobo.C00225155App.MenuViews"
        xmlns:common="clr-namespace:Common;assembly=Common"
        xmlns:convert="clr-namespace:MegaRobo.C00225155App.Converters"
        mc:Ignorable="d" WindowStyle="ToolWindow" 
        Title="样品瓶参数设置"  Height="800" Width="1000"  WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <!--<Style x:Key="DataGridCellCenterStyle" TargetType="DataGridCell">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>

        <Style x:Key="DataGridHeaderCenterStyle" TargetType="DataGridColumnHeader">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>-->

        <ContextMenu x:Key="datagridContextMenu">
            <ContextMenu.DataContext>
                <Binding Path="PlacementTarget.DataContext" RelativeSource="{RelativeSource Self}" />
            </ContextMenu.DataContext>
            <MenuItem Header="增加" Command="{Binding AddCommand_Datagrid}"  CommandParameter="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
            <MenuItem Header="删除" Command="{Binding DeleteCommand_Datagrid}" CommandParameter="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
            <MenuItem Header="清空" Command="{Binding ClearCommand_Datagrid}" CommandParameter="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
        </ContextMenu>

        <convert:EnumDescriptionConverter x:Key="enumDescription"/>
        <convert:BooleanToVisibilityConverter x:Key="boolToVisibility"/>
    </Window.Resources>
    <DockPanel LastChildFill="True">
        <Button Content="保存"  Click="SaveButton_Click"  Style="{DynamicResource okBtnStyle}"   Width="90" Height="35" FontSize="20"  DockPanel.Dock="Bottom" Margin="0,0,50,20" />

        <StackPanel  Grid.ColumnSpan="2" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5">
            <TextBlock Text="样品型号:" Style="{StaticResource txtBlockBaseStyle}" />
            <ComboBox Width="110"  Height="28"  Background="#FF98B9D6"  SelectedItem="{Binding SampleBottle.SampleBottleType, Mode=TwoWay}"  ItemsSource="{x:Static common:EnumHelper.SampleBottleTypes}"/>
            <TextBlock Text="工装:" Style="{StaticResource txtBlockBaseStyle}" />
            <TextBlock Text="{Binding SampleBottle.BoxSNCode}"  Style="{StaticResource txtBlockStyle }" VerticalAlignment="Center" Margin="3"/>
            <TextBlock Text="位置:" Style="{StaticResource txtBlockBaseStyle}" />
            <TextBlock Text="{Binding SampleBottle.PosId_InBox}"  Style="{StaticResource txtBlockStyle}" VerticalAlignment="Center" Margin="3"/>
            <TextBlock Text="二维码:" Style="{StaticResource txtBlockBaseStyle}" />
            <TextBlock Text="{Binding SampleBottle.SNCode}"  Style="{StaticResource txtBlockStyle }" VerticalAlignment="Center" Margin="3"/>
            <TextBlock Text="是否有样品瓶：" Style="{StaticResource txtBlockBaseStyle}"  Margin="20,5,5,0"/>
            <CheckBox IsChecked="{Binding SampleBottle.HaveBottle,Mode=TwoWay,FallbackValue=False}"  Height="20"  Margin="3,4,0,0"/>

        </StackPanel>

        <TabControl Style="{StaticResource FancyTabControlStyle2}" DockPanel.Dock="Top" Margin="5,10">
            <TabItem Header="投料站" Style="{StaticResource FancyTabItemStyle}" Foreground="Black">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ToolBar Grid.Row="0" Grid.Column="0" Style="{StaticResource toolbarstyle}" Margin="10,0,10,0" >
                        <!--<Button Style="{StaticResource btnMenu}" Content="复制" Width="70" Command="{Binding CopyCommand}"/>
                        <Button Style="{StaticResource btnMenu}" Content="粘贴" Width="70" Command="{Binding PasteCommand}"/>-->
                        <Button Style="{StaticResource btnMenu}" Content="上移" Width="70" Command="{Binding MoveUpCommand}"/>
                        <Button Style="{StaticResource btnMenu}" Content="下移" Width="70" Command="{Binding MoveDownCommand}"/>
                        <Button Style="{StaticResource btnMenu}" Content="增加" Margin="0" Width="60" Command="{Binding AddCommand}" CommandParameter="Liquid" />
                        <Button Style="{StaticResource btnMenu}" Content="删除" Width="60" Command="{Binding DeleteCommand}" CommandParameter="Liquid"/>
                        <Button Style="{StaticResource btnMenu}" Content="清空" Width="60" Command="{Binding ClearCommand}" CommandParameter="Liquid"/>
                    </ToolBar>

                    <DataGrid  x:Name="myDataGrid_liquid" Grid.Row="2" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="1" Style="{DynamicResource dgStyle}" 
                         ItemsSource="{Binding SampleBottle.MaterialDoseFlowList}" 
                         SelectedItem="{Binding SelectedFlow_Dose, Mode=TwoWay}" 
                         AutoGenerateColumns="False"  AlternatingRowBackground="AliceBlue"  SelectionMode="Single" Margin="5,10,5,10" 
                         HorizontalContentAlignment="Center">
                        <DataGrid.Columns>
                            <DataGridComboBoxColumn Header="物料类型"  Width="*" >
                                <DataGridComboBoxColumn.ItemsSource>
                                    <Binding Source="{x:Static common:EnumHelper.FunctionTypes}"/>
                                </DataGridComboBoxColumn.ItemsSource>

                                <DataGridComboBoxColumn.SelectedItemBinding>
                                    <Binding Path="FunctionFlowType" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
                                </DataGridComboBoxColumn.SelectedItemBinding>

                            </DataGridComboBoxColumn>
                            <DataGridTextColumn Header="试剂名称"  Width="*"  Binding="{Binding UseMaterialName,Mode=TwoWay}"/>
                            <DataGridTextColumn Header="体积(ul)/重量(mg)" Width="*" Binding="{Binding TargetVolume,StringFormat=F2}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>

            <!--<TabItem Header="反应站" Style="{StaticResource FancyTabItemStyle}" Foreground="Black">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="50"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
                        <TextBlock Text="反应类型：" VerticalAlignment="Center"  Style="{StaticResource txtBlocStyle1 }"/>
                        <ComboBox Width="120"  Height="28"  FontSize="14" Background="#FF98B9D6"  SelectedItem="{Binding SampleBottle.ReactTemperatureType, Mode=TwoWay}"  ItemsSource="{x:Static common:EnumHelper.ReactTemperatureEnums}"/>

                        --><!--<TextBlock Text="反应操作类型：" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1 }"/>
                        <ComboBox Width="120"  Height="28" FontSize="14"  Background="#FF98B9D6"  SelectedItem="{Binding SampleBottle.ReactOperateType, Mode=TwoWay}"  ItemsSource="{x:Static common:EnumHelper.ReactOperateTypeEnums}"/>--><!--

                        <TextBlock Text="反应时间："  Margin="30,0,3,0"  VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <TextBox Text="{Binding  SampleBottle.CurrentTemperatureModel.Time,Mode=TwoWay}"  Style="{StaticResource textBoxStyle }"/>
                        <TextBlock Text="min"  VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>

                        <TextBlock Text="温度：" Margin="30,0,3,0" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <TextBox Text="{Binding SampleBottle.CurrentTemperatureModel.TargetTemperature,Mode=TwoWay}"  Style="{StaticResource textBoxStyle }"/>
                        <TextBlock Text="℃" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>

                        <TextBlock Text="速度：" Margin="30,0,3,0" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <TextBox Text="{Binding SampleBottle.CurrentTemperatureModel.Speed,Mode=TwoWay}"  Style="{StaticResource textBoxStyle }"/>
                        <TextBlock Text="r/s" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2">
                        <TextBlock Text="取样方式：" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <ComboBox Width="120"  Height="28" FontSize="14" Background="#FF98B9D6"  SelectedItem="{Binding SampleBottle.SampleMethod, Mode=TwoWay}"  ItemsSource="{x:Static common:EnumHelper.ReactSampleTypeEnums}"/>

                        <TextBlock Text="穿刺高度：" Margin="30,0,3,0" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <TextBox Text="{Binding SampleBottle.PunchHeight,Mode=TwoWay}"  Style="{StaticResource textBoxStyle }"/>

                        <TextBlock Text="加液方式：" Margin="30,0,3,0" VerticalAlignment="Center" Style="{StaticResource txtBlocStyle1}"/>
                        <ComboBox Width="120"  Height="28" FontSize="14" Background="#FF98B9D6"  SelectedItem="{Binding SampleBottle.AddLiquidType, Mode=TwoWay}"  ItemsSource="{x:Static common:EnumHelper.AddLiquidTypeEnums}"/>
                    </StackPanel>

                    <GroupBox Grid.Row="2"  Grid.Column="0" Header="取样配置" Foreground="Black">
                        <DataGrid  Grid.Row="2"  Grid.Column="0" x:Name="myDataGrid_sample" Style="{DynamicResource dgStyle}"  
                             ItemsSource="{Binding SampleBottle.SampleFunctionFlowList}" 
                             SelectedItem="{Binding SelectedSample, Mode=TwoWay}" 
                             AutoGenerateColumns="False"  AlternatingRowBackground="AliceBlue"  SelectionMode="Single"  
                             ContextMenu="{StaticResource datagridContextMenu}" Tag="Sample">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="时间(min)" Width="*" Binding="{Binding OperateTime,Mode=TwoWay}"/>
                                <DataGridTextColumn Header="取样体积(ul)" Width="*" Binding="{Binding TargetAddVolume,StringFormat=F2}"/>
                                <DataGridCheckBoxColumn Header="取样完加液" Width="*" Binding="{Binding bAfterAddLiquid,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                                <DataGridCheckBoxColumn Header="是否稀释" Width="*" Binding="{Binding IsDulite,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </GroupBox>

                    <GroupBox Grid.Row="2"  Grid.Column="1"  Header="取样完紧接着加液" Visibility="{Binding SelectedSample.bAfterAddLiquid,Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed}">
                        <DataGrid  Grid.Row="2"  Grid.Column="1" x:Name="myDataGrid_SampleAfteraddliquid" Style="{DynamicResource dgStyle}"  
                            ItemsSource="{Binding SelectedSample.AddLiquidList}" 
                            SelectedItem="{Binding SelectedSampleAfterAddLiquid, Mode=TwoWay}" 
                            AutoGenerateColumns="False"  AlternatingRowBackground="AliceBlue"  SelectionMode="Single" 
                            ContextMenu="{StaticResource datagridContextMenu}" Tag="SampleAfterAddLiquid">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="加入液体名称"  Width="*" Binding="{Binding LiquidName,Mode=TwoWay}"/>
                                <DataGridTextColumn Header="加入体积(ul)" Width="*" Binding="{Binding TargetAddVolume,StringFormat=F2}"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </GroupBox>

                    <GroupBox Grid.Row="3"  Grid.Column="1" Header="加液配置" Foreground="Black">
                        <DataGrid  Grid.Row="3"  Grid.Column="0" x:Name="myDataGrid_addliquid" Style="{DynamicResource dgStyle}"  
                           ItemsSource="{Binding SampleBottle.AddLiquidFunctionFlowList}" 
                           SelectedItem="{Binding SelectedAddLiquid, Mode=TwoWay}" 
                           AutoGenerateColumns="False"  AlternatingRowBackground="AliceBlue"  SelectionMode="Single"  
                           ContextMenu="{StaticResource datagridContextMenu}" Tag="AddLiquid">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="时间(min)" Width="*" Binding="{Binding OperateTime,Mode=TwoWay}"/>
                                <DataGridTextColumn Header="加入液体名称"  Width="*" Binding="{Binding LiquidName,Mode=TwoWay}"/>
                                <DataGridTextColumn Header="加入体积(ul)" Width="*" Binding="{Binding TargetAddVolume,StringFormat=F2}"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </GroupBox>
                    <Grid Grid.Row="3" Grid.Column="0">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        --><!--<StackPanel Orientation="Horizontal" Grid.Row="0">
                            <TextBlock Text="是否稀释：" Style="{StaticResource txtBlocStyle1}" />
                            <CheckBox IsChecked="{Binding IsDulite,Mode=TwoWay,FallbackValue=False}" Height="15" IsEnabled="False"/>
                        </StackPanel>--><!--
                        <GroupBox Grid.Row="0" Header="稀释配置" Visibility="{Binding SelectedSample.IsDulite,Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed}">
                            <DataGrid  Grid.Row="0" x:Name="myDataGrid_dilute" Style="{DynamicResource dgStyle}"  
                             ItemsSource="{Binding SelectedSample.DiluentFunctionFlowList}" 
                             SelectedItem="{Binding SelectedDiluent, Mode=TwoWay}" 
                             AutoGenerateColumns="False"  AlternatingRowBackground="AliceBlue"  SelectionMode="Single" 
                             ContextMenu="{StaticResource datagridContextMenu}" Tag="Diluent">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="稀释剂"  Width="*" Binding="{Binding DiluentName,Mode=TwoWay}"/>
                                    <DataGridTextColumn Header="加入体积(ul)" Width="*" Binding="{Binding TargetDiluentVolume,StringFormat=F2}"/>
                                    --><!--<DataGridTextColumn Header="稀释倍数" Width="*" Binding="{Binding DiluentFactor,StringFormat=F2}" IsReadOnly="True"/>--><!--
                                </DataGrid.Columns>
                            </DataGrid>
                        </GroupBox>
                    </Grid>
                </Grid>
            </TabItem>-->
        </TabControl>
    </DockPanel>
</Window>
