<UserControl x:Class="FLY.Thick.FilmCasting.UI.UiModule.TrendGraph2"
             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.UiModule"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" 
             xmlns:lvc1="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Feng.Wpf"
             mc:Ignorable="d" 
             d:DesignHeight="600" 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 Source="pack://application:,,,/FLY.Thick.FilmCasting.UI;component/Themes/Colors.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <local:TrendGraphVmUt x:Key="trendVm"/>
            <local:ScanGraphVmUt x:Key="scanGraphVm"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="170*"/>
            <RowDefinition Height="100*"/>
        </Grid.RowDefinitions>
        <Border Style="{StaticResource Styles.Module.Border}" >
            <Grid x:Name="grid_trend" d:DataContext="{StaticResource trendVm}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="100*"/>
                    <RowDefinition Height="70*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="400*"/>
                    <ColumnDefinition Width="280*"/>
                </Grid.ColumnDefinitions>
                <lvc:CartesianChart Grid.Row="1" Grid.ColumnSpan="3" 
                                Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,-5,2,2"
                                    MouseDown="UIElement_MouseDown">
                    <lvc:CartesianChart.Resources>
                        <Style TargetType="lvc1:Column2Series">
                            <Setter Property="PointGeometry" Value="{x:Null}"/>
                            <Setter Property="StrokeThickness" Value="0" />
                        </Style>
                    </lvc:CartesianChart.Resources>
                    <lvc:CartesianChart.Series>
                        <lvc1:Column2Series 
                        Values="{Binding Values}"
                        Configuration="{Binding MapperPositive}"/>
                        <lvc1:Column2Series  
                        Values="{Binding Values}"
                        Configuration="{Binding MapperNegative}"/>
                    </lvc:CartesianChart.Series>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Foreground="Black" 
                              LabelFormatter="{Binding XFormatter}" 
                              MinValue="0" MaxValue="{Binding XMax}"
                              >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.ChartSeparator}" Step ="10"/>
                            </lvc:Axis.Separator>
                            <lvc:Axis.Sections>
                                <lvc:AxisSection Style="{StaticResource Styles.Axis.Section.Selected}" DataLabel="True" Value="{Binding SelectedIndex}" />
                            </lvc:Axis.Sections>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis LabelFormatter="{Binding YFormatter}"  Foreground="Transparent" 
                              MinValue="{Binding YMin}" MaxValue="{Binding YMax}" 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="0" Stroke="{StaticResource Brushes.ChartAxisLabel0}" />
                            </lvc:Axis.Sections>
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="Transparent" />
                            </lvc:Axis.Separator>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                </lvc:CartesianChart>
                <lvc:CartesianChart Grid.Row="2" Grid.ColumnSpan="3" 
                                Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,-5,2,2"
                                    MouseDown="UIElement_MouseDown">
                    <lvc:CartesianChart.Resources>
                        <Style TargetType="lvc:LineSeries">
                            <Setter Property="StrokeThickness" Value="3" />
                            <Setter Property="Fill" Value="{StaticResource Brushes.ChartArea4}"/>
                            <Setter Property="Stroke" Value="{StaticResource Brushes.ChartArea0}"/>
                        </Style>
                    </lvc:CartesianChart.Resources>
                    <lvc:CartesianChart.Series>
                        <lvc:LineSeries 
                        Values="{Binding Values}"
                        Configuration="{Binding MapperValue}"/>
                    </lvc:CartesianChart.Series>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Foreground="{StaticResource Brushes.ChartAxisLabel}" 
                              LabelFormatter="{Binding XFormatter}" 
                              MinValue="0" MaxValue="{Binding XMax}"
                              >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.ChartSeparator}" Step ="10"/>
                            </lvc:Axis.Separator>
                            <lvc:Axis.Sections>
                                <lvc:AxisSection Style="{StaticResource Styles.Axis.Section.Selected}" Value="{Binding SelectedIndex}" />
                            </lvc:Axis.Sections>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis LabelFormatter="{Binding YFormatter2}"  Foreground="{StaticResource Brushes.ChartAxisLabel}" MinRange="1" 
                              FontFamily="Courier New" >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.ChartSeparator}" />
                            </lvc:Axis.Separator>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                </lvc:CartesianChart>
                <Button Style="{StaticResource Styles.Button.Icon}" Margin="48,0,0,-20"
                        Click="btnTrendInfoClick" >
                    <Grid Style="{StaticResource Styles.Shadow}" >
                        <TextBlock  Padding="10,5" VerticalAlignment="Top"
                                    FontSize="24" Foreground="White" Background="{StaticResource Brushes.Activity}" 
                                    Text="趋势图" />
                    </Grid>
                </Button>
                <StackPanel Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2" VerticalAlignment="Top" HorizontalAlignment="Left" 
                        Margin="{StaticResource ControlMargin}">
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" >
                            <TextBlock Style="{StaticResource ValueStyle}" >
                                <Run Text="{Binding BeginTime,Mode=OneWay,StringFormat={}{0:MM-dd HH:mm}}"/>
                                至
                                <Run Text="{Binding EndTime,Mode=OneWay,StringFormat={}{0:MM-dd HH:mm}}"/>
                            </TextBlock>
                        </StackPanel>
                    </Viewbox>
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2">
                        <StackPanel Orientation="Horizontal" Margin="{StaticResource Margin.Text}"
                                Background="{StaticResource SemiTransparentGreyBrush2}">
                            <TextBlock Style="{StaticResource TitleStyle}" Text="ID:" />
                            <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Id}"/>
                        </StackPanel>
                    </Viewbox>
                </StackPanel>
                <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="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}" 
                                           Foreground="{StaticResource  WhiteBrush}"
                                           Background="{StaticResource  TextBrush}"
                                           Opacity="0.8"
                                           Text="平均: "
                                           />
                                        <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource  WhiteBrush}"
                                           Background="{StaticResource  TextBrush}"
                                           Text="{Binding Average,Mode=OneWay,StringFormat={}{0:P1}}"
                                           >
                                        </TextBlock>
                                    </StackPanel>
                                </Viewbox>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <Viewbox >
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Style="{StaticResource TitleStyle}" Text="最大: "/>
                                        <TextBlock Style="{StaticResource ValueStyle}" 
                                               Text="{Binding Max,Mode=OneWay,StringFormat={}{0:P1}}"/>
                                    </StackPanel>
                                </Viewbox>
                                <Viewbox >
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock Style="{StaticResource TitleStyle}" 
                                               Text="最小: " />
                                        <TextBlock Style="{StaticResource ValueStyle}" 
                                               Text="{Binding Min,Mode=OneWay,StringFormat={}{0:P1}}"/>
                                    </StackPanel>
                                </Viewbox>
                            </StackPanel>

                        </StackPanel>
                    </Viewbox>
                </Grid>
            </Grid>
        </Border>
        <Border Grid.Row="1" Style="{StaticResource Styles.Module.Border}" >
            <Grid x:Name="grid_scan" d:DataContext="{StaticResource scanGraphVm}">
                <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="3" 
                                Series="{Binding Series}" Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,-5,2,2">
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis 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.Sections>
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" StrokeThickness="1" Stroke="{StaticResource Brushes.Activity}"
                                Value="{Binding DataBeginOfBoltNo}" 
                            />
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" StrokeThickness="1" Stroke="{StaticResource Brushes.Activity}"
                                Value="{Binding DataEndOfBoltNo}" 
                            />
                            </lvc:Axis.Sections>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis 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>

                <Button Style="{StaticResource Styles.Button.Icon}" Margin="48,0,0,-20"
                        Click="btnScanInfoClick" >
                    <Grid Style="{StaticResource Styles.Shadow}" >
                        <TextBlock  Padding="10,5" VerticalAlignment="Top"
                                    FontSize="24" Foreground="{StaticResource Brushes.ThemeBackground}" Background="{StaticResource Brushes.Activity}" 
                                    Text="扫描图" />
                    </Grid>
                </Button>
                <StackPanel Grid.Column="1" Grid.RowSpan="2" Panel.ZIndex="2" VerticalAlignment="Top" HorizontalAlignment="Left" 
                        Margin="{StaticResource ControlMargin}">
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2">
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Style="{StaticResource ValueStyle}" >
                                    <Run Text="{Binding Time,Mode=OneWay,StringFormat={}{0:MM-dd HH:mm:ss}}"/>
                                    ~
                                    <Run Text="{Binding EndTime,Mode=OneWay,StringFormat={}{0:HH:mm:ss}}"/>
                            </TextBlock>
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}">
                                <TextBlock Style="{StaticResource TitleStyle}" Text="ID:" />
                                <TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Id,Mode=OneWay}"/>
                            </StackPanel>
                        </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 Mix,Mode=OneWay}" 
                                                    />
                                <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="幅" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                    Background="{StaticResource SemiTransparentGreyBrush2}" >
                                <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 Orientation="Horizontal" Margin="{StaticResource TextMargin}" 
                                    Background="{StaticResource SemiTransparentGreyBrush2}" 
                                    Visibility="{Binding HasVBeforeStretching,Converter={StaticResource visbilityconv},ConverterParameter=CollapsedWhenTrue}">
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Velocity,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m/min" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                    Background="{StaticResource SemiTransparentGreyBrush2}" >
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Position,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m" />
                            </StackPanel>
                        </StackPanel>
                    </Viewbox>
                    <Viewbox MaxHeight="{StaticResource FontSize.Value}" HorizontalAlignment="Left" Margin="2" Visibility="{Binding HasVBeforeStretching,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
                        <StackPanel Orientation="Horizontal">
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                    Background="{StaticResource SemiTransparentGreyBrush2}">
                                <TextBlock Style="{StaticResource TitleStyle}" 
                                                   Text="拉伸前:" />
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding VelocityBeforeStretching,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m/min" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="{StaticResource TextMargin}"
                                    Background="{StaticResource SemiTransparentGreyBrush2}" >
                                <TextBlock Style="{StaticResource TitleStyle}" 
                                                   Text="拉伸后:" />
                                <TextBlock Style="{StaticResource ValueStyle}" 
                                                   Text="{Binding Velocity,StringFormat={}{0:F1},Mode=OneWay}" 
                                                    />
                                <TextBlock Style="{StaticResource UnitStyle}" 
                                                   Text="m/min" />
                            </StackPanel>
                        </StackPanel>
                    </Viewbox>
                </StackPanel>

                <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},Mode=OneWay}" 
                                           />
                                    </StackPanel>
                                </Viewbox>
                                <Viewbox>
                                    <StackPanel Orientation="Horizontal" Background="#99000000">
                                        <TextBlock Style="{StaticResource TitleStyle}" Foreground="White"
                                           Text="  2σ: " 
                                           />
                                        <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Background="{StaticResource TextBrush}"
                                           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>
        </Border>
    </Grid>

</UserControl>
