<Page x:Class="FLY.Thick.Base.UI.PgInitparam"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:FLY.Thick.Base.UI"   
      xmlns:common="clr-namespace:FLY.Thick.Base.Common;assembly=FLY.Thick.Base"
      xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
      mc:Ignorable="d" 
      d:DesignHeight="900" d:DesignWidth="1280"
      Background="WhiteSmoke"
	Title="Page_Initparam"
      d:DataContext="{d:DesignInstance local:PgInitParamVm}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
             </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Brush_theme_bar}">
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="系统参数"/>
        </StackPanel>
        <ScrollViewer  PanningMode="Both" Grid.Row="1" >
            <StackPanel  >
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Style="{StaticResource BorderStyle_paramSection}">
                        <TextBlock Text="基本" />
                    </Border>

                    <StackPanel Grid.Column="1" >
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="数据库容量" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding DBKeepMonth}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="月" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="数据库文件路径" />
                                    <Button Style="{StaticResource ButtonStyle_icon}" Command="{Binding SelectDbPathCmd}" >
                                        <iconPacks:PackIconMaterial Kind="FolderOpen" />
                                    </Button>
                                </StackPanel>
                                <Viewbox Height="36" HorizontalAlignment="Left" >
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding DbPath}" />
                                </Viewbox>

                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">

                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="归零间隔" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding AutoOrgInterval}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="min" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="机架长度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding PosLength}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                            <Run>
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="PosLength" />
                                    <Binding Path="Encoder1_mmpp"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                    </TextBlock>
                                </StackPanel>

                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="编码器1比例" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Encoder1_mmpp}" HorizontalAlignment="Left"/>
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="mm/脉冲"/>
                                </StackPanel>

                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="高级AD数据" />
                                <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding IsTimeGridAdvEnabled}"/>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="AD延时" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ADLag}" HorizontalAlignment="Left"/>
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="*1.28ms"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="线速度源" />
                                <ComboBox Width="191" MinHeight="40" HorizontalAlignment="Left">
                                    <ComboBoxItem x:Name="comboBoxotem_EN2" IsSelected="{Binding FilmVSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:FilmVSRC.EN2}}">
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="编码器2"/>
                                    </ComboBoxItem>
                                    <ComboBoxItem x:Name="comboBoxotem_ROUND" IsSelected="{Binding FilmVSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:FilmVSRC.ROUND}}">
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="辊信号"/>
                                    </ComboBoxItem>
                                </ComboBox>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Visibility="{Binding IsSelected,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed, ElementName=comboBoxotem_EN2}">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="编码器2比例" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Encoder2_mmpp}"  HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                            <Run Text="mm/脉冲"/>
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="编码器2放大" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding Encoder2_comp}"  HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                            <Run Text="倍"/>
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Visibility="{Binding IsSelected,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed, ElementName=comboBoxotem_ROUND}">

                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="辊周长" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding MmOfR,StringFormat={}{0:F1}}" />
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="mm" />
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="最小线速度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding FilmVThreshold}"  HorizontalAlignment="Left"/>
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                            <Run Text="m/min"/>
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>

                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="数据有效源" />
                                <ComboBox Width="191" MinHeight="40" HorizontalAlignment="Left">
                                    <ComboBoxItem x:Name="comboBoxotem_byen2"  IsSelected="{Binding DataValidSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:DATAVALIDSRC.BYEN2}}">
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="线速度"/>
                                    </ComboBoxItem>
                                    <ComboBoxItem  x:Name="comboBoxotem_byinput"  IsSelected="{Binding DataValidSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:DATAVALIDSRC.BYINPUT}}">
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="本地输入口"/>
                                    </ComboBoxItem>
                                    <ComboBoxItem  x:Name="comboBoxotem_valid"  IsSelected="{Binding DataValidSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:DATAVALIDSRC.VALID}}" >
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="长期有限"/>
                                    </ComboBoxItem>
                                    <ComboBoxItem  x:Name="comboBoxotem_invalid"  IsSelected="{Binding DataValidSrc, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:DATAVALIDSRC.INVALID}}">
                                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}"  FontSize="32" Text="长期无效"/>
                                    </ComboBoxItem>
                                </ComboBox>
                            </StackPanel>

                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="数据有效时扫描" />
                                <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding AutoF1F3}" HorizontalAlignment="Left"/>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="扫描重启延时" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ReStartDelay}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="s" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="有按样生产模块" />
                                <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding HasProfileSample}" HorizontalAlignment="Left"/>
                            </StackPanel>
                        </StackPanel>

                    </StackPanel>
                </Grid>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Style="{StaticResource BorderStyle_paramSection}">
                        <TextBlock Text="速度"/>
                    </Border>
                    <WrapPanel Grid.Column="1" Orientation="Horizontal">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="扫描速度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding VScan}" HorizontalAlignment="Left"/>
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run>
                                    <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="VScan" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                    
                                <Run Text="m/min" />
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="精确定位速度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding VAccuracy}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run>
                                    <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="VAccuracy" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                <Run Text="m/min" />
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="调试速度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding VJOG}" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                    <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run>
                                    <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="VJOG" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                <Run Text="m/min" />
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>


                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="开始速度" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding SVelocity}" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run >
                                    <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="SVelocity" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                <Run Text="m/min" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>

                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="归零速度1" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding HVelocity1}" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run >
                                                                            <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="HVelocity1" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                <Run Text="m/min" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="归零速度2" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding HVelocity2}" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm_interval}" Text="|" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run >
                                    <MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                            <Binding Path="HVelocity2" />
                                            <Binding Path="Encoder1_mmpp" />
                                            <Binding Path="Speed1Scale" />
                                        </MultiBinding>
                                </Run>
                                <Run Text="m/min" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>

                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="加速时间" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ATime}" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run Text="ms" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="减速时间" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding DTime}" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" >
                                <Run Text="ms" />
                                </TextBlock>
                            </StackPanel>
                        </StackPanel>

                    </WrapPanel>
                </Grid>

            </StackPanel>
        </ScrollViewer>
        <Button Style="{StaticResource ButtonStyle_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45" 
                    Command="{Binding ApplyCmd}"/>
    </Grid>
</Page>
