<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:FixGraphViewModel_UnitTest x:Key="viewModel" Max="65540" Min="655" Average="123" Sigma3="3.2"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Style="{StaticResource BorderStyle_module}" >
        <Grid d:DataContext="{StaticResource viewModel}">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="453"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <lvc:CartesianChart Grid.Row="1" Grid.ColumnSpan="2" Margin="5,-5,2,2"
                                Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" >
                <lvc:CartesianChart.Series>
                    <lvc:LineSeries 
                        Values="{Binding Values}"
                        StrokeThickness = "3"
                        Stroke = "{StaticResource Color_theme_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>
            <Viewbox >
                <StackPanel Orientation="Horizontal" Margin="5">
                    <Button Width="40" Height="40" VerticalAlignment="Top" Style="{StaticResource ButtonStyle_empty}" 
                        Click="Button_info_click" Margin="5">
                        <Grid Style="{StaticResource GridStyle_ButtonShadow}">
                            <Ellipse Fill="{StaticResource Color_theme_activity}"/>
                            <Path Width="20" Height="20" Stretch="Uniform" Fill="White" Data="{StaticResource geometry_i}"/>
                        </Grid>
                    </Button>
                    <Grid Grid.Column="1" Margin="10,0" >
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontSize="24" Foreground="{StaticResource Color_theme_activity}" Text="定点图"/>
                                <StackPanel Orientation="Horizontal" Visibility="{Binding IsADMode,Converter={StaticResource visbilityconv}}">
                                    <TextBlock FontSize="16" Margin="3,0" Width="auto" Text="AD值"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="5">
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Time,StringFormat={}{0:HH:mm:ss}}"/>

                                </StackPanel>
                            </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>
                    </Grid>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0,10">
                        <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>
                </StackPanel>
            </Viewbox>

            <Grid Grid.Column="1" Grid.RowSpan="2" Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Panel.ZIndex="1" 
                  Background="{StaticResource SemiTransparentGreyBrush}" >
                <WrapPanel Orientation="Horizontal" Margin="10">
                    <WrapPanel.Resources>
                        <Style TargetType="Viewbox">
                            <Setter Property="Height" Value="25"/>
                            <Setter Property="Width" Value="130"/>
                            <Setter Property="HorizontalAlignment" Value="Left"/>
                            <Setter Property="VerticalAlignment" Value="Top"/>
                        </Style>
                    </WrapPanel.Resources>
                    <StackPanel>
                        <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 >
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Style="{StaticResource TitleStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Background="{StaticResource TextBrush}"
                                           Opacity="0.8"
                                           Text="平均: "
                                           />
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Background="{StaticResource 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>
                </WrapPanel>
            </Grid>

        </Grid>
    </Border>

</UserControl>
