<UserControl x:Class="FLY.Thick.Base.UI.UiModule.FixGraph"
             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.UiModule"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             
             mc:Ignorable="d" 
             
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <SolidColorBrush x:Key="TextBrush" Color="#4C4949" />
            <SolidColorBrush x:Key="GrayBrush1" Color="#FF727272"/>
            <SolidColorBrush x:Key="GrayBrush2" Color="#FF858484" />
            <SolidColorBrush x:Key="SemiTransparentGreyBrush" Color="#30909090"/>
            <SolidColorBrush x:Key="SemiTransparentActiveBrush" Color="#50008BE5"/>
            <SolidColorBrush x:Key="WhiteBrush" Color="White"/>
            <Style x:Key="TitleStyle" TargetType="TextBlock">
                <Setter Property="Width" Value="50"/>
                <Setter Property="Foreground" Value="{StaticResource GrayBrush1}"/>
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="TextAlignment" Value="Right"/>
            </Style>
            <Style x:Key="ValueStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
                <Setter Property="FontSize" Value="20"/>
                <Setter Property="Padding" Value="5,0"/>
            </Style>
            <Style x:Key="UnitStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="{StaticResource GrayBrush2}"/>
                <Setter Property="FontSize" Value="15"/>
                <Setter Property="VerticalAlignment" Value="Bottom"/>
            </Style>
            <local:FixGraphVmUt x:Key="viewModel" Max="65540" Min="655" Average="123" Sigma3="3.2"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Style="{StaticResource Styles.Module.Border}" >
        <Grid d:DataContext="{StaticResource viewModel}">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="400*"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="400*"/>
            </Grid.ColumnDefinitions>
            <lvc:CartesianChart Grid.Row="1" Grid.ColumnSpan="4" 
                                Margin="5,-5,2,2"
                                Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" >
                <lvc:CartesianChart.Series>
                    <lvc:LineSeries 
                        Values="{Binding Values}"
                        StrokeThickness = "3"
                        Stroke = "{StaticResource Brushes.Activity}"
                        
                        Fill = "Transparent"
                        PointGeometry ="{x:Null}"/>
                </lvc:CartesianChart.Series>
                <lvc:CartesianChart.AxisX>
                    <lvc:Axis LabelFormatter="{Binding XFormatter}" FontSize="16" Foreground="Black"
                          MaxValue="{Binding XMax}" MinValue="{Binding XMin}">
                        <lvc:Axis.Separator>
                            <lvc:Separator Stroke="LightGray"/>
                        </lvc:Axis.Separator>
                    </lvc:Axis>
                </lvc:CartesianChart.AxisX>
                <lvc:CartesianChart.AxisY>
                    <lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Black">
                        <lvc:Axis.Separator>
                            <lvc:Separator StrokeThickness="1" Stroke="LightGray" />
                        </lvc:Axis.Separator>
                    </lvc:Axis>
                </lvc:CartesianChart.AxisY >
            </lvc:CartesianChart>

            <Button Style="{StaticResource Styles.Button.Icon}" Margin="48,0,0,-20"
                        Click="Button_info_click" >
                <Grid Style="{StaticResource Styles.Shadow}" >
                    <TextBlock  Padding="10,5" VerticalAlignment="Top"
                                    FontSize="24" Foreground="{StaticResource Brushes.ThemeBackground}" Background="{StaticResource Brushes.Activity}" 
                                    >
                        <Run Text="{Binding InfoName}"/>定点图
                    </TextBlock>
                </Grid>
            </Button>
            <Grid Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2" 
                  VerticalAlignment="Top" HorizontalAlignment="Left" >
                <Viewbox MaxHeight="50">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="5">
                                <StackPanel Orientation="Horizontal" Visibility="{Binding IsADMode,Converter={StaticResource visbilityconv}}">
                                    <TextBlock FontSize="16" Margin="3,0" Width="auto" Text="AD值" Foreground="{StaticResource Brushes.Highlight}"/>
                                </StackPanel>
                                <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Time,StringFormat={}{0:HH:mm:ss}}"/>



                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel Orientation="Horizontal" Margin="5,0">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="间隔:" />
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Intervalms}"/>
                                    <TextBlock Style="{StaticResource UnitStyle}" Text="ms" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="5,0">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="混合:" />
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Mix}"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>


                    </StackPanel>
                </Viewbox>
            </Grid>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0,10" Grid.Column="2" Grid.RowSpan="2">
                <StackPanel.Resources>
                    <Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
                        <Setter Property="Fill" Value="{StaticResource Color_theme_activity}"/>
                        <Setter Property="Stretch" Value="Uniform"/>
                        <Setter Property="Width" Value="40"/>
                        <Setter Property="Height" Value="40"/>
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                    </Style>
                </StackPanel.Resources>
                <Button Click="button_pause_Click" Style="{StaticResource ButtonStyle_empty}" Margin="5,0">
                    <Grid Style="{StaticResource GridStyle_ButtonShadow}">
                        <Rectangle Fill="{StaticResource Color_theme_activity}" Width="40" Height="40"/>
                        <Path Fill="White" Stretch="Uniform" Width="20" Height="20">
                            <Path.Style>
                                <Style TargetType="Path" >
                                    <Setter Property="Data" Value="{StaticResource Geometry_stop}"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsPaused}" Value="True">
                                            <Setter Property="Data" Value="{StaticResource Geometry_play}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Path.Style>
                        </Path>
                    </Grid>
                </Button>
                <Button Click="button_save_Click" Style="{StaticResource ButtonStyle_empty}" Margin="5,0" IsEnabled="{Binding IsPaused}">
                    <Grid Style="{StaticResource GridStyle_ButtonShadow}">
                        <Rectangle  Width="40" Height="40">
                            <Rectangle.Style>

                                <Style TargetType="Rectangle" >
                                    <Setter Property="Fill" Value="{StaticResource Color_theme_activity}"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsPaused}" Value="false">
                                            <Setter Property="Fill" Value="{StaticResource Color_theme_noact}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Rectangle.Style>
                        </Rectangle>
                        <Path Data="{StaticResource Geometry_floppy}" Fill="White" Stretch="Uniform" Width="20" Height="20"/>
                    </Grid>
                </Button>
                <Button Click="button_analyze_Click" Style="{StaticResource ButtonStyle_empty}" Margin="5,0" IsEnabled="{Binding IsPaused}">
                    <Grid Style="{StaticResource GridStyle_ButtonShadow}">
                        <Rectangle Width="40" Height="40">
                            <Rectangle.Style>
                                <Style TargetType="Rectangle" >
                                    <Setter Property="Fill" Value="{StaticResource Color_theme_activity}"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsPaused}" Value="False">
                                            <Setter Property="Fill" Value="{StaticResource Color_theme_noact}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Rectangle.Style>
                        </Rectangle>
                        <Path Data="{StaticResource Geometry_chart-line}" Fill="White" Stretch="Uniform" Width="20" Height="20"/>
                    </Grid>
                </Button>
            </StackPanel>
            <Grid Grid.Column="3" Grid.RowSpan="2" Panel.ZIndex="1" 
                  Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right"
                  Background="{StaticResource SemiTransparentGreyBrush}" >
                <Viewbox MaxHeight="50">
                    <StackPanel Margin="5">
                        <StackPanel.Resources>
                            <Style TargetType="Viewbox">
                                <Setter Property="Height" Value="25"/>
                                <Setter Property="Width" Value="120"/>
                                <Setter Property="HorizontalAlignment" Value="Left"/>
                                <Setter Property="VerticalAlignment" Value="Top"/>
                            </Style>
                        </StackPanel.Resources>
                        <StackPanel Orientation="Horizontal">
                            <Viewbox >
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TitleStyle}" 
                                           Foreground="{DynamicResource WhiteBrush}"
                                           Background="{DynamicResource TextBrush}"
                                           Opacity="0.8"
                                           Text="平均: "
                                           />
                                    <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{DynamicResource WhiteBrush}"
                                           Background="{DynamicResource TextBrush}"
                                           Text="{Binding Average,StringFormat={}{0:F1}}" 
                                           />
                                </StackPanel>
                            </Viewbox>
                            <Viewbox>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TitleStyle}" 
                                           Foreground="Black"
                                           Background="{StaticResource WhiteBrush}" 
                                           Opacity="0.8"
                                           Text="3σ: " 
                                           />
                                    <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource TextBrush}"
                                           Background="{StaticResource WhiteBrush}"
                                           Text="{Binding Sigma3,StringFormat={}{0:F1}}"  
                                           />
                                </StackPanel>
                            </Viewbox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Viewbox >
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="最大: "/>
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Max,StringFormat={}{0:F1}}"/>
                                </StackPanel>
                            </Viewbox>
                            <Viewbox >
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Style="{StaticResource TitleStyle}" 
                                               Text="最小: " />
                                    <TextBlock Style="{StaticResource ValueStyle}" 
                                               Text="{Binding Min,StringFormat={}{0:F1}}"/>
                                </StackPanel>
                            </Viewbox>
                        </StackPanel>

                    </StackPanel>
                </Viewbox>
            </Grid>
        </Grid>
    </Border>

</UserControl>
