<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" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             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 Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/GraphStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <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="280*"/>
            </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" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="{StaticResource ControlMargin}">
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2">
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Style="{StaticResource TitleStyle}" Text="AD值" Foreground="{StaticResource Brushes.Highlight}" Visibility="{Binding IsADMode,Converter={StaticResource visbilityconv}}"/>
                            <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Time,StringFormat={}{0:HH:mm:ss}}"/>
                        </StackPanel>
                    </Viewbox>
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                        Background="{StaticResource SemiTransparentGreyBrush2}">
                                <TextBlock Style="{StaticResource TitleStyle}" Text="间隔:" />
                                <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Intervalms}"/>
                                <TextBlock Style="{StaticResource UnitStyle}" Text="ms" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                        Background="{StaticResource SemiTransparentGreyBrush2}">
                                <TextBlock Style="{StaticResource TitleStyle}" Text="混合:" />
                                <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Mix}"/>
                            </StackPanel>
                        </StackPanel>
                    </Viewbox>
                </StackPanel>

                <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Column="2" Grid.RowSpan="2">
                    <Button Click="button_pause_Click"  >
                        <Button.Style>
                            <Style TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon.Rectangle}">
                                <Setter Property="Background" Value="{StaticResource Brushes.Activity}"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsPaused}" Value="True">
                                        <Setter Property="Background" Value="{StaticResource Brushes.NoAct}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                        <iconPacks:PackIconMaterial >
                            <iconPacks:PackIconMaterial.Style>
                                <Style TargetType="iconPacks:PackIconMaterial" BasedOn="{StaticResource Styles.Icon.Rectangle}">
                                    <Setter Property="Kind" Value="Stop"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsPaused}" Value="True">
                                            <Setter Property="Kind" Value="Play"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </iconPacks:PackIconMaterial.Style>
                        </iconPacks:PackIconMaterial>
                    </Button>
                    <Button Click="button_save_Click" IsEnabled="{Binding IsPaused}" >
                        <Button.Style>
                            <Style TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon.Rectangle}">
                                <Setter Property="Background" Value="{StaticResource Brushes.NoAct}"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsPaused}" Value="True">
                                        <Setter Property="Background" Value="{StaticResource Brushes.Activity}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                        <iconPacks:PackIconMaterial Kind="Floppy" />
                    </Button>
                    <Button Click="button_analyze_Click" IsEnabled="{Binding IsPaused}" >
                        <Button.Style>
                            <Style TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon.Rectangle}">
                                <Setter Property="Background" Value="{StaticResource Brushes.NoAct}"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsPaused}" Value="True">
                                        <Setter Property="Background" Value="{StaticResource Brushes.Activity}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                        <iconPacks:PackIconMaterial Kind="ChartLine" />
                    </Button>
                </StackPanel>
            </Grid>

            <Grid Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1" 
                  Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right"
                  Background="{StaticResource SemiTransparentGreyBrush}" >
                <Viewbox MaxHeight="50">
                    <StackPanel Margin="{StaticResource ControlMargin}">
                        <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="{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="{StaticResource WhiteBrush}"
                                           Background="{StaticResource TextBrush}"
                                           Opacity="0.8"
                                           Text="3σ: " 
                                           />
                                    <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Background="{StaticResource TextBrush}"
                                           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>
