<UserControl x:Class="WSDDBBrowser.Chart.TrendGraphExcel"
             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:WSDDBBrowser.Chart"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:lvc_feng="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Feng.Wpf"
            xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
            xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Background="WhiteSmoke">
    <UserControl.Resources>
        <local:TrendGraphExcelViewModel_UnitTest x:Key="viewmodel"/>
    </UserControl.Resources>
    <Grid d:DataContext="{StaticResource viewmodel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <lvc:CartesianChart x:Name="chart" Grid.Row="1"  Series="{Binding Series}" Margin="2"
                            Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" >
            <lvc:CartesianChart.AxisX>
                <lvc:Axis IsMerged="True" LabelFormatter="{Binding XFormatter}" FontSize="16" >
                    <lvc:Axis.Separator>
                        <lvc:Separator Stroke="LightGray"/>
                    </lvc:Axis.Separator>
                </lvc:Axis>
            </lvc:CartesianChart.AxisX>
            <lvc:CartesianChart.AxisY>
                <lvc:Axis IsMerged="True" LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}">
                    <lvc:Axis.Sections>
                        <lvc:AxisSection 
                            Value="{Binding Target}" 
                            DataLabel="True"
                            StrokeThickness="1" 
                            Stroke="{StaticResource AreaColors2}"
                            DisableAnimations="True"
                            DataLabelForeground="White"
                            Opacity="0.5"
                            Panel.ZIndex="1"
                            />
                        <lvc:AxisSection 
                            Value="{Binding CtrllineYMax}"  
                            DataLabel="True"
                            StrokeThickness="1" 
                            Stroke="{StaticResource AreaColors1}"
                            DisableAnimations="True"
                            DataLabelForeground="White"
                            Opacity="0.5"
                            Panel.ZIndex="1"
                            />
                        <lvc:AxisSection 
                            Value="{Binding CtrllineYMin}"  
                            DataLabel="True"
                            StrokeThickness="1" 
                            Stroke="{StaticResource AreaColors3}"
                            DisableAnimations="True"
                            DataLabelForeground="White"
                            Opacity="0.5"
                            Panel.ZIndex="1"
                            />
                        <lvc:AxisSection 
                            Value="{Binding ToleranceYMax}"  
                            DataLabel="True"
                            StrokeThickness="1" 
                            Stroke="{StaticResource AreaColors0}"
                            DisableAnimations="True"
                            DataLabelForeground="White"
                            Opacity="0.5"
                            Panel.ZIndex="1"
                            />
                        <lvc:AxisSection 
                            Value="{Binding ToleranceYMin}"  
                            DataLabel="True"
                            StrokeThickness="1" 
                            Stroke="{StaticResource AreaColors4}"
                            DisableAnimations="True"
                            DataLabelForeground="White"
                            Opacity="0.5"
                            Panel.ZIndex="1"
                            />
                    </lvc:Axis.Sections>
                    <lvc:Axis.Separator>
                        <lvc:Separator Stroke="LightGray"/>
                    </lvc:Axis.Separator>
                </lvc:Axis>

            </lvc:CartesianChart.AxisY>
        </lvc:CartesianChart>

        <StackPanel Orientation="Horizontal" Margin="10" Height="60">
            <StackPanel Margin="20,0" Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <TextBlock FontSize="24" Foreground="{DynamicResource TextBrush}" Text="趋势图"/>
                    <TextBlock FontSize="20" Foreground="{DynamicResource TextBrush}" Margin="5">
                        <Run Text="&lt;"/>
                        <Run Text="{Binding DeviceName}"/>
                        <Run Text="&gt;"/>
                    </TextBlock>
                </StackPanel>
            </StackPanel>
        </StackPanel>
        <Grid Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Right" Background="{DynamicResource SemiTransparentGreyBrush}" Margin="10,0" Panel.ZIndex="1">
            <Grid.Resources>
                <Style x:Key="TitleStyle" TargetType="TextBlock">
                    <Setter Property="Foreground" Value="{DynamicResource GrayBrush1}"/>
                    <Setter Property="FontSize" Value="16"/>
                    <Setter Property="Width" Value="50"/>
                    <Setter Property="TextAlignment" Value="Right"/>
                </Style>
                <Style x:Key="ValueStyle" TargetType="TextBlock">
                    <Setter Property="Foreground" Value="{DynamicResource TextBrush}"/>
                    <Setter Property="FontSize" Value="30"/>
                </Style>
                <Style x:Key="UnitStyle" TargetType="TextBlock">
                    <Setter Property="Foreground" Value="{DynamicResource GrayBrush2}"/>
                    <Setter Property="FontSize" Value="15"/>
                    <Setter Property="VerticalAlignment" Value="Bottom"/>
                </Style>
            </Grid.Resources>
            <StackPanel Orientation="Horizontal">
                <StackPanel Margin="10">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource TitleStyle}" Text="最大:"/>
                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Max,StringFormat={}{0:F1}}"/>
                        <TextBlock Style="{StaticResource UnitStyle}" Text="g/m²"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource TitleStyle}" Text="最小:"/>
                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Min,StringFormat={}{0:F1}}"/>
                        <TextBlock Style="{StaticResource UnitStyle}" VerticalAlignment="Bottom" Text="g/m²"/>
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="10">


                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource TitleStyle}" Text="平均:"/>
                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Average,StringFormat={}{0:F1}}"/>
                        <TextBlock Style="{StaticResource UnitStyle}" Text="g/m²"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource TitleStyle}" Text="3σ:"/>
                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Sigma3,StringFormat={}{0:F1}}"/>
                        <TextBlock Style="{StaticResource UnitStyle}" VerticalAlignment="Bottom" Text="g/m²"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>


        </Grid>


    </Grid>
</UserControl>

