<Page x:Class="FLY.Thick.Base.UI.PgReject"
      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:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
      mc:Ignorable="d" 
      d:DesignHeight="768" d:DesignWidth="1024"
      Background="WhiteSmoke"
      d:DataContext="{d:DesignInstance local:PgRejectVm}"
	Title="Page_Reject">
    <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>

            <Style x:Key="AxisSectionStyle" TargetType="lvc:AxisSection" >
                <Setter Property="StrokeThickness" Value="1"/>
                <Setter Property="DataLabel" Value="True"/>
                <Setter Property="DisableAnimations" Value="True"/>
                <Setter Property="DataLabelForeground" Value="White"/>
                <Setter Property="Opacity" Value="0.5"/>
                <Setter Property="Panel.ZIndex" Value="1"/>
            </Style>
        </ResourceDictionary>
    </Page.Resources>
    <Grid Background="{StaticResource Brushes.Card.Background}">
        <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"/>
                <TextBlock Style="{StaticResource Styles.TitleBar.Text}" Text="剔除"/>
            </StackPanel>
            <local:CtMicroGage Grid.Column="1" x:Name="mircoGage" Background="Transparent" VerticalAlignment="Bottom"/>
        </Grid>
        <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="参数"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <WrapPanel Orientation="Horizontal" >
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="使能" />
                                    <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding Enable}" />
                                </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 ThresholdRatio,Converter={StaticResource percentconv}}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%"/>
                                    </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 LimitRangeRatio, Converter={StaticResource percentconv}}" />
                                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%"/>
                                    </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 SmoothRange}"  />
                                        <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="SmoothRange" />
                                                    <Binding Path="Mmpp"/>
                                                </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.Card}" Text="{Binding RejectRange}" />
                                        <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="RejectRange" />
                                                <Binding Path="Mmpp"/>
                                            </MultiBinding>
                                        </Run>
                                        <Run Text="mm"/>
                                        </TextBlock>
                                    </StackPanel>

                                </StackPanel>
                            </WrapPanel>

                            <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom">
                                <Button Content="应用" Style="{StaticResource Styles.Button.Square.Accent2}" Command="{Binding ApplyCmd}" />
                            </StackPanel>
                        </Grid>
                    </StackPanel>

                </Border>
                <Border Style="{StaticResource Styles.Card.Border}">
                    <StackPanel>
                        <TextBlock Style="{StaticResource Styles.Card.Title}" Text="调试"/>
                        <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom">
                            <Button Content="保存调试数据" Style="{StaticResource Styles.Button.Square2}" Command="{Binding SaveCmd}" />
                        </StackPanel>
                        <lvc:CartesianChart Margin="{StaticResource ControlMargin}" Height="350" 
                                            DisableAnimations="True" Hoverable="False" DataTooltip="{x:Null}"
                                            >
                            <lvc:CartesianChart.Series>
                                <lvc:LineSeries Values="{Binding FilterDatas}" 
                                                        Configuration="{Binding Mapper}" PointGeometry="{x:Null}" />
                                <lvc:LineSeries Values="{Binding RejectDatas}" 
                                                        Configuration="{Binding Mapper}" PointGeometry="{x:Null}" Fill="Transparent"/>
                            </lvc:CartesianChart.Series>
                            <lvc:CartesianChart.AxisX>
                                <lvc:Axis FontSize="16" LabelFormatter="{Binding XFormatter}" MinValue="{Binding XMin}" MaxValue="{Binding XMax}">
                                    <lvc:Axis.Separator>
                                        <lvc:Separator Stroke="LightGray"/>
                                    </lvc:Axis.Separator>
                                </lvc:Axis>
                            </lvc:CartesianChart.AxisX>
                            <lvc:CartesianChart.AxisY>
                                <lvc:Axis FontSize="16" LabelFormatter="{Binding YFormatter}" >
                                    <lvc:Axis.Separator>
                                        <lvc:Separator Stroke="LightGray"/>
                                    </lvc:Axis.Separator>
                                    <lvc:Axis.Sections>
                                        <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" Stroke="Red"
                                Value="{Binding Threshold}" 
                            />
                                        <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" Stroke="Orange"
                                Value="{Binding UpperLimit}" 
                            />
                                        <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" Stroke="Orange" 
                                Value="{Binding LowerLimit}" 
                            />
                                    </lvc:Axis.Sections>
                                </lvc:Axis>
                            </lvc:CartesianChart.AxisY>
                        </lvc:CartesianChart>

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


    </Grid>
</Page>
