<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: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 Brushes.TitleBar.Background}">
            <Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource Styles.TitleBar.Text}" Text="系统参数"/>
        </StackPanel>
        <ScrollViewer CanContentScroll="False" PanningMode="Both" Grid.Row="1" >
            <StackPanel Margin="{StaticResource ControlMargin}">
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="基本"/>
                        <StackPanel >
                            <StackPanel Orientation="Horizontal">
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="数据库容量" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding DBKeepMonth}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="月" />
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="数据库文件路径" />
                                        <Button Style="{StaticResource Styles.Button.Icon}" Command="{Binding SelectDbPathCmd}" >
                                            <iconPacks:PackIconMaterial Kind="FolderOpen" />
                                        </Button>
                                    </StackPanel>
                                    <Viewbox Height="36" HorizontalAlignment="Left" >
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding DbPath}" />
                                    </Viewbox>

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

                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="归零间隔" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding AutoOrgInterval}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="min" />
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="机架长度" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosLength}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                            <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 Styles.Text.FieldHeader.Editable}" Text="编码器1比例" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Encoder1_mmpp}" HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="mm/脉冲"/>
                                    </StackPanel>

                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="高级AD数据" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsTimeGridAdvEnabled}"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" 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 Styles.Text.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 Styles.Text.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 Styles.Text.FieldHeader.Editable}" Text="编码器2比例" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Encoder2_mmpp}"  HorizontalAlignment="Left"/>
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                            <Run Text="mm/脉冲"/>
                                            </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 Styles.Text.FieldHeader.Editable}" Text="辊周长" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding MmOfR,StringFormat={}{0:F1}}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="mm" />
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="最小线速度" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding FilmVThreshold}"  HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                            <Run Text="m/min"/>
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>

                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" 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 Styles.Text.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 Styles.Text.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 Styles.Text.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 Styles.Text.FieldContent}"  FontSize="32" Text="长期无效"/>
                                        </ComboBoxItem>
                                    </ComboBox>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel  Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="数据有效时&#13;扫描" />
                                        <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding AutoF1F3}" HorizontalAlignment="Left"/>
                                    </StackPanel>
                                    <StackPanel  Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="扫描重启&#13;延时" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ReStartDelay}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="s" />
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>

                            </StackPanel>

                        </StackPanel>
                    </StackPanel>
                </Border>

                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="速度"/>
                        <WrapPanel Grid.Column="1" Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="扫描速度" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding VScan}" HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="定位速度" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding VAccuracy}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="调试速度" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding VJOG}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="开始速度" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding SVelocity}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="归零速度1" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding HVelocity1}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="归零速度2" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding HVelocity2}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" Text="|" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <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 Styles.Text.FieldHeader.Editable}" Text="加速时间" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ATime}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <Run Text="ms" />
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel  Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="减速时间" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding DTime}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                                <Run Text="ms" />
                                    </TextBlock>
                                </StackPanel>
                            </StackPanel>

                        </WrapPanel>
                    </StackPanel>
                </Border>
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="硬件"/>
                        <WrapPanel Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="有打孔模块" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" HorizontalAlignment="Left"
                                              IsChecked="{Binding HasPunch}" />
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}" Visibility="{Binding HasPunch,Converter={StaticResource visbilityconv}}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="打孔模块&#13;与探头偏移" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PunchOffset}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="mm" />
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="有按样&#13;生产模块" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" HorizontalAlignment="Left"
                                              IsChecked="{Binding HasProfileSample}" />
                                </StackPanel>
                            </StackPanel>
                            
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="有纵向&#13;光纤传感器" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" HorizontalAlignment="Left"
                                              IsChecked="{Binding HasVSign}" />
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}" Visibility="{Binding HasVSign,Converter={StaticResource visbilityconv}}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="纵向光纤&#13;与探头偏移" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox HorizontalAlignment="Left" MaxWidth="150" Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding VSignOffset}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="mm" />
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="有横向&#13;光纤传感器" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" HorizontalAlignment="Left"
                                              IsChecked="{Binding HasHSign}" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable.Row2}" Text="有机架修正&#13;功能" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" HorizontalAlignment="Left"
                                              IsChecked="{Binding HasScanCorr}" />
                                </StackPanel>
                            </StackPanel>
                        </WrapPanel>

                    </StackPanel>
                </Border>

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