<UserControl x:Class="WSDDBBrowser.Chart.ColumnRangeScanGraph"
             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:ColumnRangeScanGraphViewModel_UnitTest x:Key="viewmodel"/>-->
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="10" Panel.ZIndex="10">
            <StackPanel Margin="20, 0,10,-40" Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <TextBlock FontSize="24" Foreground="{DynamicResource TextBrush}" Text="扫描图"/>
                </StackPanel>

                <StackPanel Orientation="Horizontal">
                    <TextBlock FontSize="20" Foreground="{DynamicResource TextBrush}" Text="{Binding Time,StringFormat={}{0:HH:mm:ss}}"/>
                    <TextBlock FontSize="20" Foreground="{DynamicResource GrayBrush2}" Text="&lt;" VerticalAlignment="Center"/>
                    <TextBox FontSize="20" Text="{Binding Index}"/>
                    <TextBlock FontSize="20" Foreground="{DynamicResource GrayBrush2}" VerticalAlignment="Center">
                        <Run Text="/"/><Run Text="{Binding Count}"/><Run Text="&gt;"/>
                    </TextBlock>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock FontSize="20" Foreground="{DynamicResource GrayBrush2}" Text="纵向位置:"/>
                    <TextBlock FontSize="20" Foreground="{DynamicResource TextBrush}" Text="{Binding Position,StringFormat={}{0:F1}}"/>
                    <TextBlock Foreground="{DynamicResource GrayBrush2}" FontSize="15" VerticalAlignment="Bottom" Text="m"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock FontSize="20" Foreground="{DynamicResource GrayBrush2}" Text="涂布速度:"/>
                    <TextBlock FontSize="20" Foreground="{DynamicResource TextBrush}" Text="{Binding Velocity,StringFormat={}{0:F1}}"/>
                    <TextBlock Foreground="{DynamicResource GrayBrush2}" FontSize="15" VerticalAlignment="Bottom" Text="m/min"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="20,0">
                <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5" Click="Button_pre_click" IsEnabled="{Binding IsPreEnable}">
                    <iconPacks:PackIconMaterial Kind="ArrowLeftThick" />
                </Button>
                <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5" Click="Button_next_click" IsEnabled="{Binding IsNextEnable}">
                    <iconPacks:PackIconMaterial Kind="ArrowRightThick" />
                </Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="20,0">
                <Button  Style="{StaticResource ButtonStyle_empty}" Margin="5" Click="ButtonXlsxClick" >
                    <StackPanel VerticalAlignment="Center">
                        <iconPacks:PackIconModern Kind="OfficeExcel" Foreground="{DynamicResource AccentColorBrush}" Height="35" Width="35" HorizontalAlignment="Center"/>
                        <TextBlock Text="输出xlsx" Foreground="{DynamicResource GrayBrush2}" HorizontalAlignment="Center"/>
                    </StackPanel>
                </Button>
                <Button  Style="{StaticResource ButtonStyle_empty}" Margin="5" Click="ButtonJpgClick" >
                    <StackPanel VerticalAlignment="Center">
                        <iconPacks:PackIconFontAwesome Kind="CameraRetroSolid" Foreground="{DynamicResource AccentColorBrush}" Height="35" Width="35" HorizontalAlignment="Center"/>
                        <TextBlock Text="输出jpg" Foreground="{DynamicResource GrayBrush2}"/>
                    </StackPanel>
                </Button>
            </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 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 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>

        </Grid>

        <lvc:CartesianChart 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" MaxValue="{Binding XMax}" MinValue="{Binding XMin}">
                    <lvc:Axis.Resources>
                        <Style TargetType="lvc:AxisSection" x:Key="AxisSectionStyle">
                            <Setter Property="StrokeThickness" Value="1"/>
                            <Setter Property="DataLabel" Value="True"/>
                            <Setter Property="DisableAnimations" Value="True"/>
                            <Setter Property="DataLabelForeground" Value="White"/>
                            <Setter Property="Opacity" Value="1"/>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Stroke" Value="Orange"/>
                        </Style>
                    </lvc:Axis.Resources>
                    <lvc:Axis.Separator>
                        <lvc:Separator Step="10" Stroke="LightGray"/>
                    </lvc:Axis.Separator>
                    <lvc:Axis.Sections>
                        <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                                Value="{Binding FilmBegin}" 
                                             
                            />
                        <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                                Value="{Binding FilmEnd}" 
                            />
                    </lvc:Axis.Sections>
                </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>

    </Grid>
</UserControl>
