<Window x:Class="FLYAD7_Simulation_Wpf.WindowCoating"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:FLYAD7_Simulation_Wpf"
        Title="涂布模拟" Height="520" Width="724" xmlns:my="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization">
    <Window.Resources>
        <local:CoatingModeConverter x:Key="coatingmodeconv" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="273*" />
        </Grid.RowDefinitions>
        <Grid x:Name="hmi_cc"/>
        <Grid x:Name="inner_cc"/>
        <Grid x:Name="hmi"/>
        <StackPanel Orientation="Horizontal">
            <Grid HorizontalAlignment="Left" Margin="12,3" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <Grid.Resources>
                    <Style TargetType="TextBlock" x:Key="textBlockStyle_title">
                        <Setter Property="FontSize" Value="18"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Margin" Value="5"/>
                    </Style>
                    <Style TargetType="TextBlock" x:Key="textBlockStyle_curr">
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Margin" Value="2"/>
                        <Setter Property="Foreground" Value="Gray"/>
                    </Style>

                    <Style TargetType="TextBox" x:Key="textBoxStyle_set">
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="Margin" Value="2"/>
                    </Style>
                </Grid.Resources>

                <TextBlock Style="{StaticResource textBlockStyle_title}" Text="泵速(R/min)" Grid.Row="1" />
                <TextBlock Style="{StaticResource textBlockStyle_title}" Text="左刀间距(um)" Grid.Row="2" />
                <TextBlock Style="{StaticResource textBlockStyle_title}" Text="右刀间距(um)" Grid.Row="3" />

                <TextBlock Style="{StaticResource textBlockStyle_title}" Text="对外当前值" Grid.Column="1" />

                <Button Margin="3" Click="button_set_out_Click" Grid.Column="2">
                    <TextBlock Style="{StaticResource textBlockStyle_title}" Text="对外设置值" />
                </Button>
                <TextBlock Style="{StaticResource textBlockStyle_title}" Text="内部当前值" Grid.Column="3" />
                <Button Margin="3" Click="button_set_inner_Click" Grid.Column="4">
                    <TextBlock Style="{StaticResource textBlockStyle_title}" Text="内部设置值" />
                </Button>

                <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding Pump}" DataContext="{Binding DataContext,ElementName=hmi_cc}"/>
                    <TextBlock Text="/"/>
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding PumpSet}" DataContext="{Binding DataContext,ElementName=hmi}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding LeftDis}" DataContext="{Binding DataContext,ElementName=hmi_cc}" />
                    <TextBlock Text="/"/>
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding LeftSet}" DataContext="{Binding DataContext,ElementName=hmi}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Center">
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding RightDis}" DataContext="{Binding DataContext,ElementName=hmi_cc}"/>
                    <TextBlock Text="/"/>
                    <TextBlock Style="{StaticResource textBlockStyle_curr}" Text="{Binding RightSet}" DataContext="{Binding DataContext,ElementName=hmi}" />
                </StackPanel>

                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="2" Grid.Row="1" Name="textbox_pumpset_out"  />
                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="2" Grid.Row="2" Name="textbox_leftset_out" />
                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="2" Grid.Row="3" Name="textbox_rightset_out" />

                <TextBlock Style="{StaticResource textBlockStyle_curr}" Grid.Column="3" Grid.Row="1" Text="{Binding Pump}" DataContext="{Binding DataContext,ElementName=inner_cc}" />
                <TextBlock Style="{StaticResource textBlockStyle_curr}" Grid.Column="3" Grid.Row="2" Text="{Binding LeftDis}" DataContext="{Binding DataContext,ElementName=inner_cc}"/>
                <TextBlock Style="{StaticResource textBlockStyle_curr}" Grid.Column="3" Grid.Row="3" Text="{Binding RightDis}" DataContext="{Binding DataContext,ElementName=inner_cc}" />

                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="4" Grid.Row="1" Name="textbox_pumpset_inner"/>
                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="4" Grid.Row="2" Name="textbox_leftset_inner" />
                <TextBox Style="{StaticResource textBoxStyle_set}" Grid.Column="4" Grid.Row="3" Name="textbox_rightset_inner"/>


            </Grid>
            <StackPanel>
                <CheckBox Content="设置位" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding OK}" DataContext="{Binding DataContext,ElementName=hmi}"/>
                <CheckBox Content="涂布状态" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding DeviceState}" IsEnabled="False"/>
            </StackPanel>
            
        </StackPanel>

        <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="12,3">
            <StackPanel Orientation="Horizontal"  Margin="3">
                <TextBlock Text="modbusTCP 端口:" />
                <TextBlock Text="{Binding Port}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal"  Margin="3">
                <TextBlock Text="线速度(m/min)" />
                <TextBox Text="{Binding FilmVelocity}" Width="117" />
            </StackPanel>
            <ComboBox Height="23" Margin="3" Name="comboBox1" VerticalAlignment="Top" Width="120" >
                <ComboBoxItem IsSelected="{Binding CoatingMode, Converter={StaticResource coatingmodeconv}, ConverterParameter=Extrusion}">
                    <TextBlock Text="挤压涂布"/>
                </ComboBoxItem>
                <ComboBoxItem IsSelected="{Binding CoatingMode, Converter={StaticResource coatingmodeconv}, ConverterParameter=Transfer}">
                    <TextBlock Text="转移涂布"/>
                </ComboBoxItem>
            </ComboBox>
            <TextBlock FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" >
                <Run Text="当前平均值:" />
                <Run Text="{Binding Avg}" />
            </TextBlock>
        </StackPanel>
        <Grid Margin="12,3" Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition  />
            </Grid.RowDefinitions>
            <WindowsFormsHost >
                <my:Chart x:Name="chart1" />
            </WindowsFormsHost>
            <WindowsFormsHost Grid.Row="1">
                <my:Chart x:Name="chart2" />
            </WindowsFormsHost>
        </Grid>


    </Grid>
</Window>
