<Page x:Class="ThickTcpUiInWindow.Page_ScanCorr"
      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:ThickTcpUiInWindow"
      d:DesignHeight="768" d:DesignWidth="1024"
      Loaded="Page_Loaded" Unloaded="Page_Unloaded"
      Background="White"
	Title="Page_ScanCorr">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;component/Converter/Dictionary_MyConv.xaml"/>
                <!--<ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;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 ResourceKey=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_null"/>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"  Text="{DynamicResource strScanCorr}"/>
        </StackPanel>

        <Grid Grid.Row="1" Margin="0,5,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>

            <Button Style="{StaticResource ResourceKey=ButtonStyle3}" Width="150" Margin="0,5,5,5" Click="button_apply_Click" >
                <StackPanel Orientation="Vertical">
                    <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="{DynamicResource strParam}"/>
                    <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="{DynamicResource strApply}" Margin="0"/>
                </StackPanel>
                
            </Button>
            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <StackPanel Orientation="Vertical" Margin="5">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strEnable}" />
                    <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding Enable}" HorizontalAlignment="Left"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding DataContext.HasHold, ElementName=grid_null, Converter={StaticResource visbilityconv}, ConverterParameter=Collapsed}">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strValidRange}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding ValidBegin}" />
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="-"/>
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding ValidEnd}" MinWidth="30" MaxWidth="120"/>
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="ValidBegin" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                </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_null"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                        </TextBlock>
                    </StackPanel>

                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="5">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strScanTimes}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding ScanTimer}" />
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="{DynamicResource strTimes}"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <Grid Grid.Column="2" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Button Content="{DynamicResource strStart}" Style="{StaticResource ResourceKey=ButtonStyle2}" VerticalAlignment="Bottom"  Click="button_start_click"/>
                <ProgressBar Grid.Row="1" Name="progressBar1" VerticalAlignment="Top" Height="10" Value="{Binding 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 ResourceKey=ButtonStyle3}" Width="150" Margin="0,5,5,5" Click="button_smooth_click" >
                <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="{DynamicResource strFilter}" />
            </Button>
            <WrapPanel Orientation="Horizontal" Grid.Column="1">
                <StackPanel Orientation="Vertical" Margin="5">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strMovingAverageFilters}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding SmoothFactor}" />
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" >
                                <Run>
                                    <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                        <Binding Path="SmoothFactor" />
                                        <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                    </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 Width="150" Background="{StaticResource Color_theme_activity}" Margin="0,5,5,5" >
                <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="{DynamicResource strData}" />
            </Border>
            <Grid Grid.Column="1" Margin="5" Name="grid_result">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="342*" />
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Margin="5" Name="stackpanel_groupindex">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="{DynamicResource strGroup}" />
                            <ToggleButton Style="{StaticResource ResourceKey=ToggleButtonStyle_12}"  IsChecked="{Binding GroupIndex, Converter={StaticResource group2boolconv}}" />
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Margin="5">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="{DynamicResource strAvgAD}" />
                            <StackPanel Orientation="Horizontal">

                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="{Binding AvgAD, Converter={StaticResource ResourceKey=intconv}}"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Column="2">
                        <Button Content="{DynamicResource strClear}"  Style="{StaticResource ResourceKey=ButtonStyle2}" VerticalAlignment="Bottom" Click="button_clear_click"/>
                    </StackPanel>
                    
                </Grid>
                
                <WindowsFormsHost Margin="5" Grid.Row="1">
                    <Chr:Chart x:Name="chart1"/>
                </WindowsFormsHost>
            </Grid>

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