<Window x:Class="Flyad7_WPF.Window_sync"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:flyadbase="clr-namespace:FlyADBase;assembly=FlyADBase"
        Title="Window_sync" Height="689" Width="1197" Loaded="Window_Loaded" Unloaded="Window_Unloaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="512*" />
        </Grid.ColumnDefinitions>
        <GroupBox Header="基本" Name="groupBox9" Width="194">
                <StackPanel Orientation="Vertical">
                    <StackPanel.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Height" Value="23"/>
                            <Setter Property="Width" Value="80"/>
                            <Setter Property="Margin" Value="3"/>
                        </Style>
                        <Style TargetType="TextBox">
                            <Setter Property="Height" Value="23"/>
                            <Setter Property="Width" Value="80"/>
                            <Setter Property="Margin" Value="3"/>
                        </Style>
                    </StackPanel.Resources>
                    <StackPanel Orientation="Vertical" Margin="3">
                        <TextBlock HorizontalAlignment="Left" Margin="6" Name="textBlock_pos1LCShift" FontSize="16">
                            <Run Text="逻辑横向脉冲偏移:"/>
                            <Run Text="{Binding Pos1LCShift, Mode=OneWay}"/>
                        </TextBlock>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置" Click="button_setPos1LCShift_Click" />
                            <TextBox Text="{Binding Pos1LCShift}" />
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="3">
                    <StackPanel Orientation="Vertical" Name="textBlock_position2" Margin="4">
                        <TextBlock HorizontalAlignment="Left"  Margin="2"  FontSize="16">
                                <Run Text="POS1脉冲:" />
                                <Run Text="{Binding Position, Mode=OneWay}" />
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Left" Margin="2"  FontSize="16">
                                <Run Text="POS2脉冲:" />
                                <Run Text="{Binding Position2, Mode=OneWay}" />
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="3">
                    <Button Content="纵向偏移设置" Click="button_setPos2Shift_Click" />
                    <TextBox Text="{Binding Pos2Shift}" />
                </StackPanel>
                <StackPanel >
                    <WrapPanel Orientation="Horizontal">
                            <Button Content="进入同步状态" Click="button_begin2_Click" />
                            <Button Content="退出同步状态" Click="button_syncEnd_Click" />
                            <Button Content="清空同步列表" Click="button_clear_Click" />
                            <Button Content="pos图" Click="button_graph_Click" />
                        </WrapPanel>
                    </StackPanel>
                    <StackPanel Name="textBlock_marker" >
                        <TextBlock FontSize="16" Margin="2" >
                            <Run Text="Marker:" /> 
                            <Run Text="{Binding Marker, Mode=OneWay}" />
                        </TextBlock>
                        <TextBlock FontSize="16" Margin="2" >
                            <Run Text="运行状态:" /> 
                            <Run Text="{Binding DriveStatus, Mode=OneWay}" />
                        </TextBlock>
                        <TextBlock FontSize="16" Margin="2" >
                            <Run Text="运行指令:" />
                            <Run Text="{Binding DriveOrder, Mode=OneWay}" />
                        </TextBlock>
                        <TextBlock FontSize="16" Margin="2" >
                            <Run Text="同步中:" />
                            <Run Text="{Binding IsSync, Mode=OneWay}" />
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
        </GroupBox>
        <TabControl Margin="5" Name="tabControl1" Width="422" Grid.Column="1">
            <TabItem Header="手动" Name="tabItem1">

                <Grid>
                   <StackPanel Orientation="Horizontal">
                        <StackPanel Width="210">
                            <GroupBox Header="SyncRunAtLC 同步扫描至" Margin="5" Name="groupBox_syncRunAtLC" >
                                <Grid>
                                    
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,7,0,0" Name="textBlock1" Text="开始主轴位置" VerticalAlignment="Top" />
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,35,0,0" Name="textBlock2" Text="结束主轴位置" VerticalAlignment="Top" />
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,64,0,0" Name="textBlock3" Text="结束横向逻辑位置" VerticalAlignment="Top" />
                                    <CheckBox Content="脉冲开关" Height="16" HorizontalAlignment="Left" Margin="6,122,0,0" Name="checkBox1" VerticalAlignment="Top" IsChecked="{Binding HasDataGrid}"/>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,93,0,0" Name="textBlock4" Text="命令识标号" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="84,6,0,0" Name="textBox1" VerticalAlignment="Top" Width="98" Text="{Binding Pos2Begin}"/>
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="84,35,0,0" Name="textBox2" VerticalAlignment="Top" Width="98" Text="{Binding Pos2End}"/>
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="108,64,0,0" Name="textBox3" VerticalAlignment="Top" Width="74" Text="{Binding Pos1LC}"/>
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="84,92,0,0" Name="textBox4" VerticalAlignment="Top" Width="98" Text="{Binding Marker}"/>
                                    <Button Content="添加" Height="23" HorizontalAlignment="Left" Margin="106,122,0,0" Name="button_addSyncRunAtLC" VerticalAlignment="Top" Width="75" Click="button_addSyncRunAtLC_Click" />
                                </Grid>
                            </GroupBox>
                            <GroupBox Header="SyncRunToLC 运行至逻辑位置" Margin="5" Name="groupBox_syncRunToLC" >
                                <Grid>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,39,0,0" Name="textBlock7" Text="横逻辑脉冲位置" VerticalAlignment="Top" />
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,67,0,0" Name="textBlock10" Text="速度" VerticalAlignment="Top" />
                                    <CheckBox Content="脉冲开关" Height="16" HorizontalAlignment="Left" Margin="4,97,0,0" VerticalAlignment="Top" IsChecked="{Binding HasDataGrid}"/>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="textBlock11" Text="命令识标号" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="108,38,0,0" VerticalAlignment="Top" Width="74" Text="{Binding Pos1}" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="35,67,0,0" VerticalAlignment="Top" Width="147" Text="{Binding Velocity}" />
                                    <TextBox Height="23" HorizontalAlignment="Right" Margin="0,6,6,0" VerticalAlignment="Top" Width="110" Text="{Binding Marker}"/>
                                    <Button Content="添加" Height="23" HorizontalAlignment="Left" Margin="107,97,0,0" Name="button_addSyncRunToLC" VerticalAlignment="Top" Width="75" Click="button_addSyncRunToLC_Click" />
                                </Grid>
                            </GroupBox>
                            <GroupBox Header="SyncRunTo 运行至物理位置" Margin="5" Name="groupBox_syncRunTo" >
                                <Grid>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,39,0,0" Name="textBlock5" Text="横向物理脉冲位置" VerticalAlignment="Top" />
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,67,0,0" Name="textBlock6" Text="速度" VerticalAlignment="Top" />
                                    <CheckBox Content="脉冲开关" Height="16" HorizontalAlignment="Left" Margin="4,97,0,0" Name="checkBox2" VerticalAlignment="Top" IsChecked="{Binding HasDataGrid}"/>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="textBlock9" Text="命令识标号" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="108,38,0,0" Name="textBox5" VerticalAlignment="Top" Width="74" Text="{Binding Pos1}"/>
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="35,67,0,0" Name="textBox6" VerticalAlignment="Top" Width="147" Text="{Binding Velocity}"/>
                                    <TextBox Height="23" HorizontalAlignment="Right" Margin="0,6,6,0" VerticalAlignment="Top" Width="110" Text="{Binding Marker}"/>
                                    <Button Content="添加" Height="23" HorizontalAlignment="Left" Margin="107,97,0,0" Name="button_addSyncRunTo" VerticalAlignment="Top" Width="75" Click="button_addSyncRunTo_Click" />
                                </Grid>
                            </GroupBox>

                        </StackPanel>
                        <StackPanel Width="210">
                            <GroupBox Header="SyncOrigin 归零" Margin="5" Name="groupBox_syncOrigin" >
                                <Grid>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="6,8,0,0" Name="textBlock8" Text="命令识标号" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="84,7,0,0" Name="textBox8" VerticalAlignment="Top" Width="98" Text="{Binding Marker}"/>
                                    <Button Content="添加" Height="23" HorizontalAlignment="Left" Margin="107,35,0,0" Name="button_addSyncOrigin" VerticalAlignment="Top" Width="75" Click="button_addSyncOrigin_Click" />
                                </Grid>
                            </GroupBox>
                            <GroupBox Header="SyncWait 等待，ms" Margin="5" Name="groupBox_syncWait" >
                                <Grid>
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="5,33,0,0" Text="ms" VerticalAlignment="Top" />
                                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="5,7,0,0" Text="命令识标号" VerticalAlignment="Top" />
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="29,33,0,0" VerticalAlignment="Top" Width="153" Text="{Binding MS}"/>
                                    <TextBox Height="23" HorizontalAlignment="Left" Margin="71,6,0,0" VerticalAlignment="Top" Width="110" Text="{Binding Marker}" />
                                    <Button Content="添加" Height="23" HorizontalAlignment="Left" Margin="107,62,0,0" Name="button_addSyncWait" VerticalAlignment="Top" Width="75" Click="button_addSyncWait_Click" />
                                </Grid>
                            </GroupBox>
                            <GroupBox Header="指令列表保存&amp;加载" Margin="5">
                                <StackPanel>
                                    <Button Content="保存" Height="23" HorizontalAlignment="Left" Margin="5" Width="75" Click="button_save_Click" />
                                    <Button Content="加载" Height="23" HorizontalAlignment="Right" Margin="5" Width="75" Click="button_load_Click" />
                                </StackPanel>
                            </GroupBox>
                        </StackPanel>
                    </StackPanel>
                    </Grid>
            </TabItem>
            <TabItem Header="自动" Name="tabItem2" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition  />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <WrapPanel Orientation="Vertical" Height="468">
                        <WrapPanel.Resources>
                            <Style TargetType="TextBlock" x:Key="TextBlockStyle_Title">
                                <Setter Property="FontWeight" Value="Bold"/>
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="FontSize" Value="20"/>
                                <Setter Property="Margin" Value="2"/>
                            </Style>
                        </WrapPanel.Resources>
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Text="膜范围" Style="{StaticResource TextBlockStyle_Title}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="开始" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding ScanBegin}"/>
                                <TextBlock Margin="3" Text="p" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="宽度" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding ScanWidth}"/>
                                <TextBlock Margin="3" Text="p" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Text="样品" Style="{StaticResource TextBlockStyle_Title}"/>
                            <StackPanel Orientation="Vertical" Name="stackpanel_SamplePos_Backw">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Height="23" Text="温修开始" FontSize="18" Margin="3"/>
                                    <TextBox Height="23" Width="80" Margin="3" Text="{Binding Begin}"/>
                                    <TextBlock Margin="3" Text="p" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Height="23" Text="温修结束" FontSize="18" Margin="3"/>
                                    <TextBox Height="23" Width="80" Margin="3" Text="{Binding End}"/>
                                    <TextBlock Margin="3" Text="p" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Vertical" Name="stackpanel_SamplePos_Forw">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Height="23" Text="样品开始" FontSize="18" Margin="3"/>
                                    <TextBox Height="23" Width="80" Margin="3" Text="{Binding Begin}"/>
                                    <TextBlock Margin="3" Text="p" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Height="23" Text="样品结束" FontSize="18" Margin="3"/>
                                    <TextBox Height="23" Width="80" Margin="3" Text="{Binding End}"/>
                                    <TextBlock Margin="3" Text="p" />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Text="速度" Style="{StaticResource TextBlockStyle_Title}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="扫描速度" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding Velocity}"/>
                                <TextBlock Margin="3" Text="p/s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="样品速度" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding VSample}"/>
                                <TextBlock Margin="3" Text="p/s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="线速度" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding FilmVelocity}"/>
                                <TextBlock Margin="3" Text="m/min" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="当前速度" FontSize="18" />
                                <TextBlock Height="23" Margin="3" >
                                    <Run Text="{Binding CurrVelocity,Mode=OneWay,StringFormat={}{0:F1}}"/>
                                    <Run Text="m/min"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="当前线速度" FontSize="18" />
                                <TextBlock Height="23" Margin="3" >
                                    <Run Text="{Binding CurrFilmVelocity,Mode=OneWay,StringFormat={}{0:F1}}"/>
                                    <Run Text="m/min"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="与前机距离" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding DistanceWithHeader}"/>
                                <TextBlock Margin="3" Text="m" />
                            </StackPanel>

                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Text="比例" Style="{StaticResource TextBlockStyle_Title}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="编码器1" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding Mmpp1}"/>
                                <TextBlock Margin="3" Text="mm/p" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="编码器2" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="80" Text="{Binding Mmpp2}"/>
                                <TextBlock Margin="3" Text="mm/p" />
                            </StackPanel>

                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5">
                            <TextBlock Text="耗时" Style="{StaticResource TextBlockStyle_Title}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="温修" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="40" Text="{Binding ConsumeOfSampleBackw}"/>
                                <TextBlock Height="23" Margin="3" Text="s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="样品" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="40" Text="{Binding ConsumeOfSampleForw}"/>
                                <TextBlock Height="23" Margin="3" Text="s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="扫描" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="40" Text="{Binding ConsumeOfScan}"/>
                                <TextBlock Height="23" Margin="3" Text="s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="grid等" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="40" Text="{Binding ConsumeOfGrid}"/>
                                <TextBlock Height="23" Margin="3" Text="s" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="样品间隔" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="40" Text="{Binding SampleInterval}"/>
                                <TextBlock Height="23" Margin="3" Text="次" FontSize="18" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" Text="周期测试间隔" FontSize="18" />
                                <TextBox Height="23" Margin="3" Width="55" Text="{Binding TestInterval}"/>
                                <TextBlock Height="23" Margin="3" Text="s" FontSize="18" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" FontSize="18" >
                                    <Run Text="测试记数:" />
                                    <Run Text="{Binding TestCnt,Mode=OneWay}" />
                                    <Run Text="s" />
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Height="23" Margin="3" FontSize="18" >
                                    <Run Text="测试状态:" />
                                    <Run Text="{Binding TestState,Mode=OneWay}" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>

                        <TextBlock HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" >
                        <TextBlock.Inlines>
                            <Run Text="样品累计: " FontSize="16" />
                            <Run Text="{Binding sampleCount,Mode=OneWay}"/>
                            <Run Text="&#x0a;"/>
                            <Run Text="主轴脉冲: " FontSize="16" />
                            <Run Text="{Binding last_pos2,Mode=OneWay}"/>
                            <Run Text="&#x0a;"/>
                            <Run Text="温修主轴脉冲消耗: " FontSize="10" />
                            <Run Text="{Binding Pos2ConsumeOfSampleBackw,Mode=OneWay}"/>
                            <Run Text="&#x0a;"/>
                            <Run Text="样品主轴脉冲消耗: " FontSize="10" />
                            <Run Text="{Binding Pos2ConsumeOfSampleForw,Mode=OneWay}"/>
                            <Run Text="&#x0a;"/>
                            <Run Text="扫描主轴脉冲消耗: " FontSize="10" />
                            <Run Text="{Binding Pos2ConsumeOfScan,Mode=OneWay}"/>
                            <Run Text="&#x0a;"/>
                            <Run Text="等待主轴脉冲消耗: " FontSize="10" />
                            <Run Text="{Binding Pos2ConsumeOfWaitNextScan,Mode=OneWay}"/>
                        </TextBlock.Inlines>
                        </TextBlock>
                        <TextBlock Height="23" HorizontalAlignment="Left" Margin="10" Name="textBlock12" VerticalAlignment="Top" >
                            <Run Text="{Binding LastOrder,Mode=OneWay}"/>
                        </TextBlock>
                    </WrapPanel>
                    </ScrollViewer>
                    <WrapPanel Grid.Row="1" Orientation="Horizontal" >
                        <Button Content="1.初始化" Height="37" Margin="5" Width="90" Click="button_init_Click" FontSize="18" />
                        <Button Content="2.开始" Height="37" Margin="5" Width="90" Click="button_go_Click" FontSize="18" />
                        <Button Content="3.停止" Height="37" Margin="5" Width="90" Click="button_stop_Click" FontSize="18" />
                        <Button Content="4.周期测试" Height="37" Margin="5" Padding="5" Click="button_test_Click" FontSize="18" />
                        <Button Content="5.测试停止" Height="37" Margin="5" Padding="5" Click="button_teststop_Click" FontSize="18" />
                        <Button Content="1" Height="37" Margin="5" Width="45" Click="button_pos2sync1_Click" FontSize="18" />
                        <Button Content="0" Height="37" Margin="5" Width="45" Click="button_pos2sync0_Click" FontSize="18" />
                        <Button Content="保存数据" Height="37" Margin="5" Padding="5" Click="button_save_autosync_Click" FontSize="18" />
                        
                    </WrapPanel>

                </Grid>
            </TabItem>
        </TabControl>
        <ListBox Name="listView1" Grid.Column="2" Margin="5" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock x:Name="textblock_body" Text="{Binding .}"  />
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding State}" Value="{x:Static flyadbase:SyncOrderState.Doing}">
                            <Setter TargetName="textblock_body"  Property="Foreground" Value="Red"/>
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Window>
