<Page x:Class="FLY.Thick.Base.UI.PgFlyAd"
      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:conv="clr-namespace:FLY.Thick.Base.UI.Converter" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
      mc:Ignorable="d" 
      d:DesignHeight="1200" d:DesignWidth="1024"
      Background="WhiteSmoke"
      d:DataContext="{d:DesignInstance local:PgFlyAdVm}"
	>
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Converters.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <conv:IPEPConverter x:Key="ipepconv" />
            <conv:OutSpeed2mpminConverter x:Key="outsp2mpminconv" />
            <conv:Pos2mmConverter x:Key="p2mmconv" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid Background="{StaticResource Brushes.TitleBar.Background}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" >
                <Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"   >
                    <iconPacks:PackIconMaterial Kind="ArrowLeftThick" />
                </Button>
                <TextBlock Style="{StaticResource Styles.TitleBar.Text}"  Text="{StaticResource str.PgFlyAd.Title}"/>
            </StackPanel>
            <local:CtMicroGage Grid.Column="1" x:Name="mircoGage" Background="Transparent" VerticalAlignment="Bottom"/>
        </Grid>
        <ScrollViewer PanningMode="Both" Grid.Row="1" >
            <StackPanel Margin="{StaticResource ControlMargin}">
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="{StaticResource str.PgFlyAd.Param}"/>
                        <StackPanel >
                            <WrapPanel Orientation="Horizontal">
          
                                <StackPanel Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosOfGrid}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosOfGrid}" />
                                    </StackPanel>
                                    
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.GridSmooth}" />
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding GridSmooth}" />
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.MOTORTYPE}" />
                                    </StackPanel>

                                    <ComboBox Width="120" HorizontalAlignment="Left" MinHeight="{StaticResource FontSize.FieldContent}">
                                        <ComboBoxItem IsSelected="{Binding MotorType, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:MOTORTYPE.SERVO}}">
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"  FontSize="{StaticResource FontSize.FieldContent.Middle}" Text="{StaticResource str.PgFlyAd.SERVO}"/>
                                        </ComboBoxItem>
                                        <ComboBoxItem IsSelected="{Binding MotorType, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:MOTORTYPE.VF0}}" >
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"  FontSize="{StaticResource FontSize.FieldContent.Middle}" Text="{StaticResource str.PgFlyAd.VF0}"/>
                                        </ComboBoxItem>
                                        <ComboBoxItem IsSelected="{Binding MotorType, Converter={StaticResource e2bconv}, ConverterParameter={x:Static common:MOTORTYPE.NULL}}" >
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"  FontSize="{StaticResource FontSize.FieldContent.Middle}" Text="{StaticResource str.PgFlyAd.NULL}"/>
                                        </ComboBoxItem>
                                    </ComboBox>
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.Ratio01}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Ratio01}" />
                                    </StackPanel>
                                    
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.Ratio02}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Ratio02}" />
                                    </StackPanel>
                                    
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosOffset}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosOffset}" />
                                    </StackPanel>
                                    
                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosMaxMin}" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding HasPosMaxMin}" HorizontalAlignment="Left"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Visibility="{Binding HasPosMaxMin,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
                                    <StackPanel Margin="{StaticResource ControlMargin}" >
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosMin}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosMin}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="{StaticResource str.PgFlyAd.Unit}"/>
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosMax}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosMax}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="{StaticResource str.PgFlyAd.Unit}"/>
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>

                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.JogVelocity}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding JogVelocity}" />
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.ADLag}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ADLag}" HorizontalAlignment="Left"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="ms"/>
                                    </StackPanel>
                                </StackPanel>
                                <StackPanel  Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.HardwareVersion}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="v"/>
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding HardwareVersion}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}">
                                            <Run Text="{StaticResource str.PgFlyAd.Version}"/>:v<Run Text="{Binding Version}"/>
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </WrapPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                <Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="{StaticResource str.PgFlyAd.Apply}" Command="{Binding ApplyCmd}"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Border>
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="{StaticResource str.PgFlyAd.Initparam}"/>
                        <StackPanel >
                            <WrapPanel Orientation="Horizontal">

                                <StackPanel  Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.PosLength}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding PosLength}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                        <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="{StaticResource str.PgFlyAd.mmpp}" />
                                    <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/p"/>
                                    </StackPanel>

                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel  Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.VJOG}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding VJOG}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" />
                                            <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="{StaticResource str.PgFlyAd.SVelocity}" />
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding SVelocity}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" />
                                        <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 Orientation="Horizontal">
                                    <StackPanel  Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.HV1}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding HVelocity1}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" />
                                            <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="{StaticResource str.PgFlyAd.HV2}" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding HVelocity2}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" />
                                            <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>

                                <StackPanel Orientation="Horizontal">
                                    <StackPanel  Margin="{StaticResource ControlMargin}">
                                        <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.ATime}" />
                                        <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="{StaticResource str.PgFlyAd.DTime}" />
                                        <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>
                                </StackPanel>

                            </WrapPanel>
                            <StackPanel Orientation="Horizontal" FlowDirection="RightToLeft">
                                <Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="{StaticResource str.PgFlyAd.Apply}" Command="{Binding Apply2Cmd}"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Border>
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}"
                                   Text="{StaticResource str.PgFlyAd.Action}" />
                        <StackPanel Orientation="Horizontal">
                            <Button Style="{StaticResource Styles.Button.Square2}" Content="{StaticResource str.PgFlyAd.Backw}" Command="{Binding BackwCmd}"/>
                            <Button Style="{StaticResource Styles.Button.Square2}" Content="{StaticResource str.PgFlyAd.Forw}" Command="{Binding ForwCmd}" />
                            <Button Style="{StaticResource Styles.Button.Square2}" Content="{StaticResource str.PgFlyAd.Org}" Command="{Binding OrgCmd}" />
                            <Button Style="{StaticResource Styles.Button.Square.Accent2}" Background="{StaticResource Brushes.Validation}" 
                                    Content="{StaticResource str.PgFlyAd.Stop}" Command="{Binding StopCmd}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="{StaticResource str.PgFlyAd.RunTo}" Command="{Binding RunToCmd}"/>
                            <StackPanel  Margin="{StaticResource ControlMargin}" >
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="{StaticResource str.PgFlyAd.TargetPos}" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding TargetPos}" HorizontalAlignment="Left"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="{StaticResource str.PgFlyAd.Unit}"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Border>

            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>
