<Page x:Class="FLY.Thick.Base.UI.PgScanCorr"
      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" 
      mc:Ignorable="d" 
      xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
      xmlns:local ="clr-namespace:FLY.Thick.Base.UI"
      d:DesignHeight="768" d:DesignWidth="1280"
      Background="WhiteSmoke"
      d:DataContext="{d:DesignInstance local:PgScanCorrVm}"
	Title="Page_ScanCorr">
    <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 Source="pack://application:,,,/FLY.Thick.Base.UI;component/Culture/StringResource.zh-CN.xaml"/>-->
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type ToggleButton}" x:Key="ToggleButtonStyle_12" >
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Padding" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                            <Canvas Height="45" Width="106">
                                <Path x:Name="Path_Background" Data="F1M1,1C1,1 105,1 105,1 105,1 105,44 105,44 105,44 1,44 1,44 1,44 1,1 1,1z" 
								Fill="#FF3B3B3B" Height="45" Width="106"/>
                                <Path x:Name="Path_block" Data="F1M1,1C1,1 23,1 23,1 23,1 23,35 23,35 23,35 1,35 1,35 1,35 1,1 1,1z" 
								Fill="#FFFFFFFF" Height="36" Canvas.Left="77" Canvas.Top="5" Width="24"/>
                                <TextBlock x:Name="TextBlock_No" Text="1" Foreground ="White" Canvas.Left="25"  Style="{StaticResource TextBlockStyle_FieldContent}" />
                            </Canvas>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="TextBlock_No" Property="Text" Value="2"/>
                                    <Setter TargetName="TextBlock_No" Property="Canvas.Left" Value="51"/>
                                    <Setter TargetName="Path_block" Property="Canvas.Left" Value="4"/>
                                    <Setter TargetName="Path_Background" Property="Fill" Value="#FF008BE5"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <local:Group2boolConverter x:Key="group2boolconv"/>

        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid Name="grid_initparam" DataContext="{Binding InitParamService}"/>
        <Grid Background="{StaticResource Background_Title}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" >
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"  Text="机架修正"/>
        </StackPanel>
        <local:CtMicroGage Grid.Column="1" x:Name="mircoGage" Background="Transparent" VerticalAlignment="Bottom"/>
    </Grid>
        <Grid Grid.Row="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>

            <Button Style="{StaticResource ButtonStyle_paramSection}" Command="{Binding ApplyCmd}" >
                <TextBlock Text="参数&#x000A;应用"/>
            </Button>
            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <StackPanel Margin="{StaticResource ControlMargin}">
                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="使能" />
                    <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding Enable}" />
                </StackPanel>
                <StackPanel Margin="{StaticResource ControlMargin}" Visibility="{Binding DataContext.HasHold, ElementName=grid_initparam, Converter={StaticResource visbilityconv}, ConverterParameter=Collapsed}">
                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="有效范围" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ValidBegin}" />
                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="-"/>
                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ValidEnd}" MinWidth="30" MaxWidth="120"/>
                        <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="ValidBegin" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                            <Run Text="-"/>
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="ValidEnd" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel  Margin="{StaticResource ControlMargin}">
                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="来回次数" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ScanTimer}" />
                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="次"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <Grid Grid.Column="2" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Button Content="开始" Style="{StaticResource ButtonStyle2}" VerticalAlignment="Bottom"  Command="{Binding StartCmd}"/>
                <ProgressBar Grid.Row="1" VerticalAlignment="Top" Height="10" Value="{Binding  ScanCorrService.Progress}"/>
            </Grid>

        </Grid>
        <Grid Grid.Row="2" Margin="0,5,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <Button Style="{StaticResource ButtonStyle_paramSection}" Command="{Binding SmoothCmd}" >
                <TextBlock Text="滤波器" />
            </Button>
            <WrapPanel Orientation="Horizontal" Grid.Column="1">
                <StackPanel   Margin="{StaticResource ControlMargin}">
                    <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="移动滤波" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding SmoothFactor}" />
                        <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="SmoothFactor" />
                                        <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                    </MultiBinding>
                                </Run>
                                <Run Text="mm"/>
                        </TextBlock>
                    </StackPanel>

                </StackPanel>
            </WrapPanel>
            
        </Grid>
        <Grid Grid.Row="3" Margin="0,5,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Border Style="{StaticResource BorderStyle_paramSection}" >
                <TextBlock Text="数据" />
            </Border>
            <Grid Grid.Column="1" Margin="{StaticResource ControlMargin}" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="342*" />
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel   Margin="{StaticResource ControlMargin}" >
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="组" />
                            <ToggleButton Style="{StaticResource ToggleButtonStyle_12}"  IsChecked="{Binding GroupIndex, Converter={StaticResource group2boolconv}}" />
                        </StackPanel>
                        <StackPanel   Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="平均AD" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding AvgAD, Converter={StaticResource intconv}}"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Column="2">
                        <Button Content="清空"  Style="{StaticResource ButtonStyle2}" VerticalAlignment="Bottom" Command="{Binding ClearCmd}"/>
                    </StackPanel>
                    
                </Grid>
                
                <WindowsFormsHost Margin="{StaticResource ControlMargin}" Grid.Row="1">
                    <Chr:Chart x:Name="chart1"/>
                </WindowsFormsHost>
            </Grid>

        </Grid>
    </Grid>
</Page>
