<Page x:Class="FLY.FilmCasting.AutoDie.UI.Client.PgSetup"
      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.FilmCasting.AutoDie.UI.Client"
      xmlns:misc="clr-namespace:Misc;assembly=MISC"
      mc:Ignorable="d" 
      d:DesignWidth="1024"
      Background="WhiteSmoke"
      d:DataContext="{d:DesignInstance local:PgSetupVm}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.FilmCasting.AutoDie.UI.Client;component/Themes/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <local:StableConverter x:Key="stableconv"/>
            <local:TimeSpan2SecondConverter x:Key="ts2secconv"/>
            <local:HeatEffectConverter x:Key="heconv"/>
            <local:MaxR2VisConverter x:Key="maxR2VisConv"/>
            <local:Id2VisConverter x:Key="id2VisConv"/>
        </ResourceDictionary>

    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid x:Name="grid_viewModel"/>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}" >
            <Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <TextBlock Style="{StaticResource Styles.TitleBar.Text}"  Text="自动风环"/>
                <TextBlock Style="{StaticResource Styles.TitleBar.Text.Sub}" Text="自控设置" />
            </StackPanel>

        </StackPanel>
        

        <ScrollViewer Grid.Row="1" PanningMode="Both" Background="{StaticResource Brushes.Card.Background}">
            <StackPanel>
                <Border Style="{StaticResource Styles.Card.Border}">

                    <StackPanel >
                        <TextBlock Style="{StaticResource Styles.Card.Title}"  Text="常用参数"/>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="不总体调整" />
                                <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding IsForbidUpDown}"/>
                            </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 CtrlLine}"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" >
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="Kp" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding Kp, StringFormat={}{0:F1}}"/>
                                    <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 ThresholdHeatSigma, StringFormat={}{0:F1}}" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatCell}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="当前平滑值" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding MaxHeatSigma, StringFormat={}{0:F1}}"  HorizontalAlignment="Left"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel >
                    </StackPanel>

                </Border>

                <Border Style="{StaticResource Styles.Card.Border}">

                    <StackPanel >
                        <TextBlock Style="{StaticResource Styles.Card.Title}"  Text="参数"/>
                        <StackPanel Orientation="Horizontal" >
                            <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 MaxHeat}"/>
                                    <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 Step}"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="%" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="检测线速度" />
                                <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding HasCheckFilmVelocity}"/>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="电流检测功能" />
                                <ToggleButton Style="{StaticResource Styles.ToggleButton.YESNO}" IsChecked="{Binding HasCheck}"/>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding Feedback}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="电流" />
                                <TextBlock>
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource Text.FieldContent}">
                                            <Setter Property="Text" Value="Off"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding HasElectricity}" Value="True">
                                                    <Setter Property="Text" Value="On"/>
                                                    <Setter Property="Background" Value="Yellow"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding Feedback}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="风机" />
                                <TextBlock>
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource Text.FieldContent}">
                                            <Setter Property="Text" Value="Off"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding HasFan}" Value="True">
                                                    <Setter Property="Text" Value="On"/>
                                                    <Setter Property="Background" Value="Yellow"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                            </StackPanel>
                        </StackPanel >
                        <StackPanel Orientation="Horizontal" >
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="测量时间" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Text.FieldContent}" Text="{Binding CurrTime,StringFormat={}{0:HH:mm:ss}}" />
                                </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 Delay}"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="秒" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="总起效时间" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Text.FieldContent}" Text="{Binding Delay, Converter={StaticResource ts2secconv}}"/>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="秒" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding Feedback}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="加热修改时间" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Text.FieldContent}" Text="{Binding LastChangedTime,StringFormat={}{0:HH:mm:ss}}" />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal" >
                                <StackPanel Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="异常2σ" />
                                    <TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ThresholdSigmaMax, StringFormat={}{0:F1}}" />


                                </StackPanel>
                                <StackPanel Margin="{StaticResource ControlMargin}" DataContext="{Binding HeatBuf}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="2σ当前值" />
                                    <TextBlock Style="{StaticResource Text.FieldContent}" Text="{Binding Curr2Sigma, StringFormat={}{0:F1}}"/>
                                </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 StableRange}"/>
                                        <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 HeatEffectCurve,Converter={StaticResource heconv}}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" DataContext="{Binding HeatBuf}">
                            <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 ThresholdR,StringFormat={}{0:F2}}"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定性" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Text.FieldContent}" Text="{Binding CurrR, StringFormat={}{0:F2}}" />
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Margin="{StaticResource ControlMargin}">
                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="稳定状态" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource Text.FieldContent}"  Text="{Binding Stability, Converter={StaticResource stableconv}}"  />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>


                    </StackPanel>
                </Border>



            </StackPanel>
        </ScrollViewer>
        <Button Style="{StaticResource Styles.Button.Apply}" Margin="0,20,20,0" 
                    Command="{Binding ApplyCmd}"/>
    </Grid>
</Page>

