<Window x:Class="Flyad7_WPF.MainWindow"
        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"
        xmlns:local="clr-namespace:Flyad7_WPF"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
         xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
        Title="MainWindow" Height="606" Width="1161" d:DataContext="{d:DesignInstance Type=flyadbase:FlyAD7}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Converters/MyConv.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="MOTORTYPE">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="flyadbase:MOTORTYPE" />
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>

            <Style TargetType="TextBlock" x:Key="TextBlockStyle_groupTitle">
                <Setter Property="FontSize" Value="16" />
            </Style>
            <Style TargetType="TextBlock" x:Key="TextBlockStyle_itemTitle">
                <Setter Property="Width" Value="60" />
                <Setter Property="Margin" Value="3" />
            </Style>
            <Style TargetType="TextBlock" x:Key="TextBlockStyle_itemContent">
                <Setter Property="Width" Value="100"/>
                <Setter Property="Height" Value="23" />
                <Setter Property="Margin" Value="3" />
            </Style>
            <Style TargetType="TextBox" x:Key="TextBoxStyle_itemContent">
                <Setter Property="Width" Value="100"/>
                <Setter Property="Height" Value="23" />
                <Setter Property="Margin" Value="3" />
            </Style>
            <Style TargetType="Button" x:Key="ButtonStyle">
                <Setter Property="Height" Value="30"/>
                <Setter Property="Margin" Value="3"/>
                <Setter Property="Padding" Value="20,3"/>
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="573*" />
        </Grid.ColumnDefinitions>
        <Grid Name="grid_param"/>
        <Grid Name="grid_viewModel"/>
        <StackPanel Orientation="Vertical">
            <GroupBox Margin="5" Name="groupBox2" >
                <GroupBox.Header>
                    <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="连接" />
                </GroupBox.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <Button Padding="20,5" Margin="3" Name="button_connect" Click="btnConnectClick" >
                                <Button.Style>
                                    <Style TargetType="Button">
                                        <Setter Property="Content" Value="连接"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=txtIp,Path=IsEnable}" Value="False">
                                                <Setter Property="Content" Value="重连"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                            <TextBox Name="txtIp" Text="{Binding Addr }" Width="283" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <CheckBox IsChecked="{Binding HasCRC}" Content="CRC" VerticalAlignment="Center" Margin="5"/>
                            <TextBlock >
                            <Run>连接状态:</Run>
                            <Run Text="{Binding IsConnected, Mode=OneWay}"/>
                            <Run>连接次数:</Run>
                            <Run Text="{Binding ConnectCnt, Mode=OneWay}"/>
                            </TextBlock>

                        </StackPanel>
                    </StackPanel>


                </Grid>
            </GroupBox>
            <GroupBox HorizontalAlignment="Left"  Name="groupBox_adpos" VerticalAlignment="Top">
                <StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="200">
                            <Run Text="AD:" />
                            <Run Text="{Binding AD}"/>
                        </TextBlock>
                        <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="200" >
                            <Run Text="{Binding Now}"/>
                        </TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">


                        <StackPanel Orientation="Horizontal" Width="200">
                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="auto" >
                            <Run Text="位置1" />
                            <Run Text="{Binding Position}"/>
                            </TextBlock>
                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="auto" Foreground="Red">
                            <Run Text="|" />
                            <Run Text="{Binding Speed}"/>
                            <Run Text="pps" />
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Width="200">
                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="auto" >
                            <Run Text="位置2" />
                            <Run Text="{Binding Position2}"/>
                            </TextBlock>
                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Width="auto" Foreground="Blue">
                            <Run Text="|" />
                            <Run Text="{Binding Speed2}"/>
                            <Run Text="pps" />
                            </TextBlock>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </GroupBox>
            <TabControl Margin="5" Width="450">
                <TabItem Header="IO">
                    <StackPanel Orientation="Horizontal">
                        <GroupBox HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top">
                            <GroupBox.Header>
                                <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="I/O" />
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="输入" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding IStatus,Mode=OneWay,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="120" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="输出" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="120" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    
                                    <Button Style="{StaticResource ButtonStyle}" Content="输出设置" Click="button_output_Click" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Name="textbox_output" />
                                </StackPanel>
                                <StackPanel>
                                    <StackPanel.Resources>
                                        <Style TargetType="Button" x:Key="ButtonStyle_Bit">
                                            <Setter Property="Height" Value="30"/>
                                            <Setter Property="Width" Value="50"/>
                                            <Setter Property="Margin" Value="3"/>
                                        </Style>
                                    </StackPanel.Resources>
                                    <StackPanel Orientation="Horizontal">
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="0" Click="button_setbit_Click">
                                            <TextBlock>
                                                1(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=0}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="1" Click="button_setbit_Click">
                                            <TextBlock>
                                                2(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=1}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="2" Click="button_setbit_Click">
                                            <TextBlock>
                                                3(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=2}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="3" Click="button_setbit_Click">
                                            <TextBlock>
                                                4(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=3}"/>)
                                            </TextBlock>
                                        </Button>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="4" Click="button_setbit_Click">
                                            <TextBlock>
                                                5(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=4}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="5" Click="button_setbit_Click">
                                            <TextBlock>
                                                6(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=5}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="6" Click="button_setbit_Click">
                                            <TextBlock>
                                                7(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=6}"/>)
                                            </TextBlock>
                                        </Button>
                                        <Button Style="{StaticResource ButtonStyle_Bit}" Tag="7" Click="button_setbit_Click">
                                            <TextBlock>
                                                8(<Run Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource binConv}, ConverterParameter=7}"/>)
                                            </TextBlock>
                                        </Button>
                                    </StackPanel>
                                    <Button Style="{StaticResource ButtonStyle}" Click="btnAutoOutClick" >
                                        <TextBlock>
                                            走马灯(<Run Text="{Binding ElementName=grid_viewModel,Path=DataContext.IsAutoOutRunning,Mode=OneWay}"/>)
                                        </TextBlock>
                                    </Button>
                                </StackPanel>

                            </StackPanel>
                        </GroupBox>
                    </StackPanel>
                </TabItem>

                <TabItem Header="参数" >
                    <WrapPanel Orientation="Horizontal">
                        <GroupBox HorizontalAlignment="Left" Margin="5" Name="groupBox4" VerticalAlignment="Top" >
                            <GroupBox.Header>
                                <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="速度" />
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="速度" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding Velocity}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="启动速度" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding SVelocity}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="加速时间" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding ATime}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="减速时间" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding DTime}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="归0速度1" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding HVelocity1}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="归0速度2" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemContent}" Text="{Binding HVelocity2}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Content="设置" Click="btnSetPosParamClick" Style="{StaticResource ButtonStyle}"/>
                                </StackPanel>
                            </StackPanel>

                        </GroupBox>
                        <GroupBox HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top">
                            <GroupBox.Header>
                                <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="系统参数" />
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="原点脉冲" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding PosOffset}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="JOG速度" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding JogVelocity}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="Pos/Grid" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding PosOfGrid}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="电机类型" />
                                    <ComboBox SelectedValue="{Binding MotorType}" ItemsSource="{Binding Source={StaticResource MOTORTYPE}}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Center" Padding="0" Width="101" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="电机脉冲" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding Ratio01}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="编码器脉冲" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding Ratio02}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="更新" />
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                        <GroupBox HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top">
                            <GroupBox.Header>
                                <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="其它参数" />
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="总脉冲" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding PosLen}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="AD滞后" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding ADLag}" />
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                    </WrapPanel>
                </TabItem>
                <TabItem Header="系统授权">
                    <GroupBox HorizontalAlignment="Left" Margin="5" Name="groupBox9" VerticalAlignment="Top">
                        <GroupBox.Header>
                            <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="系统授权" />
                        </GroupBox.Header>
                        <StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="状态码" />
                                <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding AreaStatus, Mode=OneWay}" IsEnabled="False" Width="150" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="返回码" />
                                <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding AreaRet, Mode=OneWay}" IsEnabled="False" Width="150"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="序列码" />
                                <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding Code, Converter={StaticResource ResourceKey=bytesconv}, Mode=OneWay}" IsEnabled="False" Width="150"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="剩余时间" />
                                <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding Surplus, Mode=OneWay}" IsEnabled="False" Width="150"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="授权码" />
                                <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding Access, Converter={StaticResource ResourceKey=bytesconv}, Mode=OneWay}" IsEnabled="False" Width="150"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" Grid.Row="5">
                                <Button Style="{StaticResource ButtonStyle}" Content="初始化" Click="button_initarea_Click" />
                                <Button Style="{StaticResource ButtonStyle}" Content="输入授权码" Click="button_setaccess_Click" />
                                <TextBlock Text="{Binding AreaWaitForAnswer}" />
                            </StackPanel>
                        </StackPanel>
                    </GroupBox>
                </TabItem>
                <TabItem Header="运动">
                    <StackPanel Orientation="Horizontal">
                        <GroupBox HorizontalAlignment="Left" Margin="5" Name="groupBox5" VerticalAlignment="Top">
                            <GroupBox.Header>
                                <TextBlock Style="{StaticResource TextBlockStyle_groupTitle}" Text="DriveMan" />
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="Runto" Click="button_runto_Click" />
                                    <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Name="textBox_to" Text="1000" AcceptsReturn="False" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="runto 0" Click="button_runto0_Click" />
                                    <Button Style="{StaticResource ButtonStyle}" Content="runto 总长" Click="button_runtoPosLen_Click" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="Org" Click="button_org_Click" />
                                    <Button Style="{StaticResource ButtonStyle}" Content="Stop" Click="button_stop_Click" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="&lt;&lt;-" Click="button_backw_Click" />
                                    <Button Style="{StaticResource ButtonStyle}" Content="-&gt;&gt;" Click="button_forw_Click" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource ButtonStyle}" Content="同步调试" Click="button_sync_Click" />
                                </StackPanel>
                                <TextBlock HorizontalAlignment="Left" Margin="3">
                <Run Text="{Binding DriveStatus}" />
                <Run Text="......." />
                <Run Text="{Binding DriveOrder}" /></TextBlock>
                            </StackPanel>
                        </GroupBox>
                        <GroupBox Header="来回走" Height="117" HorizontalAlignment="Left" Margin="5" Name="groupBox_fb" VerticalAlignment="Top" Width="162">
                            <Grid>
                                <TextBox Height="23" HorizontalAlignment="Left" Margin="6,62,0,0" Text="{Binding FB_Pos2}" VerticalAlignment="Top" Width="84" />
                                <TextBox Height="23" HorizontalAlignment="Left" Margin="6,36,0,0" Text="{Binding FB_Pos1}" VerticalAlignment="Top" Width="84" />
                                <Label Content="---" Height="28" HorizontalAlignment="Left" Margin="65,2,0,0" Name="label1" VerticalAlignment="Top" Width="25" />
                                <CheckBox Content="enable" Height="16" HorizontalAlignment="Left" Margin="6,6,0,0" VerticalAlignment="Top" IsChecked="{Binding FB_Enable}" />
                            </Grid>
                        </GroupBox>
                    </StackPanel>
                </TabItem>
            </TabControl>
        </StackPanel>

        <GroupBox Header="图" Grid.Column="1" Margin="5" Name="groupBox8" >
            <TabControl x:Name="tabControl" >
                <TabItem Header="TimeGrid">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="141*"/>
                            <ColumnDefinition Width="524*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal" Name="stackpanel_graph" Grid.ColumnSpan="2">
                            <CheckBox Content="接收TimeGrid" IsChecked="{Binding DataContext.HasTimeGrid,ElementName=grid_param}" VerticalAlignment="Center" Margin="3" />

                        </StackPanel>
                        <WindowsFormsHost Grid.Row="1" Grid.ColumnSpan="2">
                            <Chr:Chart x:Name="chart2" />
                        </WindowsFormsHost>
                    </Grid>
                </TabItem>
                <TabItem Header="Grid">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <StackPanel Orientation="Horizontal" Name="stackpanel_graph_grid">
                            <Button Content="反向获取" Height="23" Name="button2" Width="75" Click="button2_Click" Margin="3" />
                            <Button Content="正向获取" Height="23" Name="button1" Width="75" Click="button1_Click" Margin="3" />
                            <Button Content="清除" Height="23" Width="75" Click="button_cleargrid_Click" Margin="3" />
                            <Button Content="保存" Height="23" Width="75" Click="button_gridSave_Click" Margin="3" />
                            <CheckBox Content="接收Grid" IsChecked="{Binding DataContext.HasGrid,ElementName=grid_param}" VerticalAlignment="Center" Margin="3" />
                            <TextBlock Margin="3">
                        <Run Text="Grid Marker:"/>
                        <Run Name="run_gridmarker"/>
                            </TextBlock>
                        </StackPanel>
                        <WindowsFormsHost Grid.Row="1">
                            <Chr:Chart x:Name="chart1" />
                        </WindowsFormsHost>
                    </Grid>
                </TabItem>
                <TabItem Header="GridAdv">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <StackPanel >
                            <GroupBox Name="gbTimeGridAdv" Header="TimeGridAdv操作" d:DataContext="{d:DesignInstance Type=local:GridAdvVm}">
                                <StackPanel>
                                    <StackPanel Orientation="Horizontal" >
                                        <CheckBox Content="接收GridAdv" IsChecked="{Binding HasGridAdv }" VerticalAlignment="Center" Margin="3" />
                                        <Button Style="{StaticResource ButtonStyle}" Content="保存" Command="{Binding SaveCmd}" />
                                        <Button Style="{StaticResource ButtonStyle}" Content="读取" Command="{Binding LoadCmd}" />
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <Button Style="{StaticResource ButtonStyle}" Content="计算滞后" Command="{Binding CalAdLagCmd}" />
                                        <TextBlock Margin="10,0">
                                    当前相关性=<Run Text="{Binding CurrR, StringFormat={}{0:F4}, Mode=OneWay}"/>
                                        </TextBlock>
                                        <StackPanel>
                                            <TextBlock Margin="10,0">
                                        计算进度 AdLag=<Run Text="{Binding ProgressOfAdLag, Mode=OneWay}"/> | R=<Run Text="{Binding ProgressOfR, StringFormat={}{0:F4}, Mode=OneWay}"/>
                                            </TextBlock>
                                            <TextBlock Margin="10,0">
                                        结果 AdLag=<Run Text="{Binding BestAdLag, Mode=OneWay}"/> | R=<Run Text="{Binding BestR, StringFormat={}{0:F4}, Mode=OneWay}"/>
                                            </TextBlock>
                                        </StackPanel>

                                    </StackPanel>
                                </StackPanel>
                            </GroupBox>

                            <GroupBox x:Name="gbAutoGetGridAdv" Header="自动采集不同速度TimeGridAdv" d:DataContext="{d:DesignInstance Type=local:AutoGetGridAdv}" >
                                <StackPanel >
                                    <StackPanel Orientation="Horizontal" >
                                        <Button Style="{StaticResource ButtonStyle}" Content="数据分析" Command="{Binding AnalyzeCmd}" />
                                        <Button Style="{StaticResource ButtonStyle}" Content="开始" Command="{Binding StartCmd}" />
                                        <Button Style="{StaticResource ButtonStyle}" Content="停止" Command="{Binding StopCmd}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding FB_Pos1}" />
                                            <TextBlock Text="&lt;----&gt;" VerticalAlignment="Center"/>
                                            <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding FB_Pos2}" />
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <StackPanel Margin="2">
                                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="开始速度" />
                                            <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding StartV}" />
                                        </StackPanel>
                                        <StackPanel Margin="2">
                                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="结束速度" />
                                            <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding EndV}" />
                                        </StackPanel>
                                        <StackPanel Margin="2">
                                            <TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="步进" />
                                            <TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding StepV}" />
                                        </StackPanel>
                                    </StackPanel>
                                    
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Margin="10,0">
                                            运行中 =<Run Text="{Binding IsRunning, Mode=OneWay}"/>
                                        </TextBlock>
                                        <TextBlock Margin="10,0">
                                                Error=<Run Text="{Binding ErrMsg,Mode=OneWay}" />
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding IsError}" Value="False">
                                                            <Setter Property="Visibility" Value="Collapsed"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </StackPanel>

                                    <TextBlock Margin="10,0">
                                            Progess=<Run Text="{Binding ProgressMsg,Mode=OneWay}"/>
                                    </TextBlock>
                                </StackPanel>
                                
                                
                            </GroupBox>
                            
                        </StackPanel>

                        <WindowsFormsHost Grid.Row="1">
                            <Chr:Chart x:Name="chart3" />
                        </WindowsFormsHost>
                    </Grid>
                </TabItem>
            </TabControl>

        </GroupBox>

    </Grid>
</Window>
