<Page x:Class="FLY.Thick.Base.UI.PgBorderSearchPlastic"
      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:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
      xmlns:local ="clr-namespace:FLY.Thick.Base.UI"
      xmlns:misc="clr-namespace:Misc;assembly=MISC"
      mc:Ignorable="d" 
      d:DesignHeight="727" d:DesignWidth="1280"
      d:DataContext="{d:DesignInstance local:PgBorderSearchVm}"
      x:Name="root"
      Background="WhiteSmoke"
	Title="Page_BorderSearch">
    <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 Height="496*" />
        </Grid.RowDefinitions>
        <Grid Name="grid_initparam" DataContext="{Binding InitParamService}"/>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}">
            <Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack" />
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"  Text="边界查找"/>
        </StackPanel>
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="496*" />
            </Grid.RowDefinitions>
            <Grid >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button Style="{StaticResource ButtonStyle_paramSection}" Command="{Binding  ApplyCmd}" >
                    <TextBlock Text="参数&#x0a;应用"/>
                </Button>
                <StackPanel Grid.Column="1">

                    <StackPanel Orientation="Horizontal">
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="使能" />
                            <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding Enable}" HorizontalAlignment="Left"/>
                        </StackPanel>
                        <Grid>
                            <StackPanel  Margin="{StaticResource ControlMargin}" >
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="温修AD" />
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Text="{Binding TempAD}" />
                            </StackPanel>
                        </Grid>
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="温修范围%" />
                            <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsTempRangeByPercent}" HorizontalAlignment="Left"/>
                        </StackPanel>
                        <StackPanel Margin="{StaticResource ControlMargin}" >
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="温修范围" />
                            <Grid>
                                <TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding TempRange}" Visibility="{Binding IsTempRangeByPercent, Converter={StaticResource visbilityconv},ConverterParameter=CollapsedWhenTrue}"/>
                                <StackPanel Orientation="Horizontal" Visibility="{Binding IsTempRangeByPercent, Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding TempRangePercent,Converter={StaticResource percentconv}}"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%"/>
                                </StackPanel>
                            </Grid>
                        </StackPanel>

                    </StackPanel>
                    <WrapPanel Orientation="Horizontal">
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="滤波器" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding N}" />
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                    <Binding Path="N" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </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}" Text="{Binding SensorWidth}" />
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                        <Binding Path="SensorWidth" />
                                        <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                    </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </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}" Text="{Binding N2}" />
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                        <Binding Path="N2" />
                                        <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                    </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </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}" Text="{Binding N3}" />
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}"/>
                                <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F1}">
                                        <Binding Path="N3" />
                                        <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                    </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </TextBlock>
                            </StackPanel>


                        </StackPanel>
                    </WrapPanel >
                </StackPanel >


            </Grid>
            <Grid Grid.Row="1" DataContext="{Binding BorderSearchService}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <Border Style="{StaticResource Styles.ParamSection.Border}">
                    <TextBlock Text="结果"/>
                </Border>
                <Grid Grid.Column="1" Margin="{StaticResource ControlMargin}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <WrapPanel Grid.Column="1" Orientation="Horizontal">
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Text="正向边界" >
                                <TextBlock.Style>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding DataContext.Direction,ElementName=root}" Value="{x:Static misc:DIRECTION.FORWARD}">
                                                <Setter Property="Foreground" Value="Red"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
                        <Run Text="{Binding Border_Forw.Begin, Converter={StaticResource intconv}, Mode=OneWay}"/>
                        <Run Text="-"/>
                        <Run Text="{Binding Border_Forw.End, Converter={StaticResource intconv}, Mode=OneWay}"/>
                                </TextBlock>
                                <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="Border_Forw.Begin" />
                                    <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="Border_Forw.End" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </TextBlock>
                            </StackPanel>

                        </StackPanel>
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Text="反向边界" >
                                <TextBlock.Style>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding DataContext.Direction,ElementName=root}" Value="{x:Static misc:DIRECTION.BACKWARD}">
                                                <Setter Property="Foreground" Value="Red"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
                        <Run Text="{Binding Border_Backw.Begin, Converter={StaticResource intconv}, Mode=OneWay}"/>
                        <Run Text="-"/>
                        <Run Text="{Binding Border_Backw.End, Converter={StaticResource intconv}, Mode=OneWay}"/>
                                </TextBlock>
                                <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="Border_Backw.Begin" />
                                    <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="Border_Backw.End" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </TextBlock>
                            </StackPanel>

                        </StackPanel>
                        <StackPanel  Margin="{StaticResource ControlMargin}">
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="膜宽" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
                                <Run Text="{Binding Width,Mode=OneWay}"/>
                                </TextBlock>
                                <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="Width" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                                </TextBlock>
                            </StackPanel>

                        </StackPanel>
                    </WrapPanel>
                    <WindowsFormsHost Grid.Row="1" Margin="{StaticResource ControlMargin}">
                        <Chr:Chart x:Name="chart1"/>
                    </WindowsFormsHost>
                </Grid>


            </Grid>
        </Grid>

    </Grid>
</Page>
