<UserControl x:Class="FLY.Thick.FilmCasting.UI.Server.ScanGraph"
             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.FilmCasting.UI.Server"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:lvc2="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Feng.Wpf"
            xmlns:misc="clr-namespace:Misc;assembly=MISC" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800" >
    <UserControl.Resources>


        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.FilmCasting.UI.Server;component/Themes/Styles.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.FilmCasting.UI.Server;component/Themes/Colors.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="TitleStyle" TargetType="TextBlock">
                <Setter Property="Width" Value="50"/>
                <Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Gray2}"/>
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="TextAlignment" Value="Right"/>
            </Style>
            <Style x:Key="ValueStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Gray1}"/>
                <Setter Property="FontSize" Value="20"/>
                <Setter Property="Padding" Value="5,0"/>
            </Style>
            <Style x:Key="UnitStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Gray2}"/>
                <Setter Property="FontSize" Value="15"/>
                <Setter Property="VerticalAlignment" Value="Bottom"/>
            </Style>


            <local:ScanGraphVmUt x:Key="viewmodel"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Background="White">
        <Grid d:DataContext="{StaticResource viewmodel}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="45"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                
                <lvc:CartesianChart x:Name="chart" Grid.Row="1" 
                                 Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="{StaticResource ControlMargin}">
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis x:Name="axisX_0" LabelFormatter="{Binding XFormatter}" 
                              Foreground="{StaticResource Brushes.ChartAxisLabel}"
                              MaxValue="{Binding XMax}" MinValue="{Binding XMin}"
                              >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.ChartSeparator}" Step ="{Binding XStep}"/>
                            </lvc:Axis.Separator>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis x:Name="axisY_0"  LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Transparent" FontFamily="Courier New">
                            <lvc:Axis.Sections>
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding YMax}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel3}"
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding YMin}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel3}"
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding Tolerance2YMax}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel2}"
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding Tolerance2YMin}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel2}"
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding ToleranceYMax}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel1}"
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                            Value="{Binding ToleranceYMin}"  
                            Stroke="{StaticResource Brushes.ChartAxisLabel1}"
                            />

                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
                                Value="{Binding Target}" 
                                Stroke="{StaticResource Brushes.ChartAxisLabel0}"
                            />
                            </lvc:Axis.Sections>
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="Transparent" />
                            </lvc:Axis.Separator>
                        </lvc:Axis>

                    </lvc:CartesianChart.AxisY>
                    <lvc:CartesianChart.Series>
                        <lvc2:Column2Series  x:Name="series_0" 
                            YAxisCrossing="{Binding Target}" 
                            Values="{Binding Values}"
                            Stroke = "Black"
                            StrokeThickness = "1"
                            PointGeometry = "{x:Null}"
                            Configuration = "{Binding Mapper}"
                            >

                        </lvc2:Column2Series>
                    </lvc:CartesianChart.Series>
                </lvc:CartesianChart>
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>
                <Grid Panel.ZIndex="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="48,0,0,0" >
                    <Viewbox MaxHeight="75">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel>
                                <Grid Background="{StaticResource MahApps.Brushes.Gray10}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Title}" />
                                    <TextBlock Grid.Column="1" Text="厚度报警" FontSize="20" Foreground="{StaticResource  MahApps.Brushes.Validation5}"  Margin="10,1"
                                               Visibility="{Binding IsWarning,Converter={StaticResource visbilityconv}}"/>
                                </Grid>
                                <StackPanel Orientation="Horizontal" >
                                    
                                </StackPanel>
                                
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="{StaticResource ControlMargin}">

                                    <TextBlock Style="{StaticResource ValueStyle}">
                                    <Run Text="{Binding Time,Mode=OneWay,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"/>
                                    ~
                                    <Run Text="{Binding EndTime,Mode=OneWay,StringFormat={}{0:HH:mm:ss}}"/>
                                    </TextBlock>
                                    <StackPanel Orientation="Horizontal" Margin="5,0">
                                        <TextBlock Style="{StaticResource TitleStyle}" Text="ID:" />
                                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Id,Mode=OneWay}"/>
                                    </StackPanel>

                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Orientation="Horizontal" Background="#99FFFFFF">
                                        <StackPanel Orientation="Horizontal" Margin="5,0">
                                            <TextBlock Style="{StaticResource TitleStyle}" 
                                                   Text="混合:" />
                                            <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Mix,Mode=OneWay}" 
                                                    />
                                            <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="幅" />
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Background="#99FFFFFF">
                                        <StackPanel Orientation="Horizontal" Margin="5,0">
                                            <TextBlock Style="{StaticResource TitleStyle}" 
                                                   Text="膜宽:" />
                                            <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding FilmWidth,StringFormat={}{0:F0},Mode=OneWay}" 
                                                    />
                                            <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="mm" />
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Background="#99FFFFFF">
                                        <StackPanel Orientation="Horizontal" Margin="5,0">
                                            <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Velocity,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                            <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m/min" />
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal" Background="#99FFFFFF">
                                        <StackPanel Orientation="Horizontal" Margin="5,0">
                                            <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Position,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                            <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m" />
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>


                        </StackPanel>
                    </Viewbox>
                </Grid>
                <Grid Grid.Column="1" Panel.ZIndex="1" 
                  Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right"
                  Background="{StaticResource MahApps.Brushes.Gray10}" >
                    <Viewbox MaxHeight="50">
                        <StackPanel Margin="5">
                            <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}" Text="平均: "/>
                                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Average,StringFormat={}{0:F1},Mode=OneWay}" />
                                    </StackPanel>
                                </Viewbox>
                                <Viewbox>
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock Style="{StaticResource TitleStyle}" Text="  2σ: " />
                                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Sigma2Text}" />
                                    </StackPanel>
                                </Viewbox>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <Viewbox >
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Style="{StaticResource TitleStyle}" Text="最大: "/>
                                        <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding MaxText}"/>
                                    </StackPanel>
                                </Viewbox>
                                <Viewbox >
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock Style="{StaticResource TitleStyle}" 
                                               Text="最小: " />
                                        <TextBlock Style="{StaticResource ValueStyle}" 
                                               Text="{Binding MinText}"/>
                                    </StackPanel>
                                </Viewbox>
                            </StackPanel>

                        </StackPanel>
                    </Viewbox>
                </Grid>
            </Grid>

        </Grid>
    </Border>
</UserControl>
