<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/Converters.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" Sigma2="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}"/><Run Text="{StaticResource str.Graph.FixGraph}"/>
                    </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" >
                    <Viewbox MaxHeight="{StaticResource GraphInfo2RowMaxHeight}" Margin="{StaticResource ControlMargin}">
                        <StackPanel>
                            <StackPanel Orientation="Horizontal" >
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="AD" Foreground="{StaticResource Brushes.Highlight}" Visibility="{Binding IsADMode,Converter={StaticResource visbilityconv}}"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}">
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Time,StringFormat={}{0:HH:mm:ss}}"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                        Background="{StaticResource TextTransparentBackgroundBrush}">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="{StaticResource str.Graph.Interval}" />
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Intervalms}"/>
                                    <TextBlock Style="{StaticResource UnitStyle}" Text="ms" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                        Background="{StaticResource TextTransparentBackgroundBrush}">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="{StaticResource str.Graph.Mix}" />
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Mix}"/>
                                </StackPanel>
                            </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="{StaticResource GraphInfo2RowMaxHeight}" Margin="{StaticResource ControlMargin}">
                    <UniformGrid Columns="2">
                        <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}" 
                                    Background="{StaticResource TextBrush}">
                                <TextBlock Style="{StaticResource TitleStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Text="{StaticResource str.Graph.Avg}"
                                           />
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Text="{Binding Average,StringFormat={}{0:F1}}" 
                                           />
                            </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}" 
                                    Background="{StaticResource TextBrush}">
                            <TextBlock Style="{StaticResource TitleStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Text="2σ" 
                                           />
                            <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Text="{Binding Sigma2,StringFormat={}{0:F1}}"  
                                           />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}" >
                                <TextBlock Style="{StaticResource TitleStyle}" 
                                               Text="{StaticResource str.Graph.Max}" />
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                               Text="{Binding Max,StringFormat={}{0:F1}}"/>
                            </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}" >
                            <TextBlock Style="{StaticResource TitleStyle}" 
                                               Text="{StaticResource str.Graph.Min}" />
                            <TextBlock Style="{StaticResource ValueStyle}"  
                                               Text="{Binding Min,StringFormat={}{0:F1}}"/>
                        </StackPanel>
                    </UniformGrid>
                </Viewbox>
            </Grid>
        </Grid>
    </Border>

</UserControl>
