<UserControl x:Class="FLY.FeedbackRenZiJia.UI.Client.UiModule.AirRingGraph"
      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.FeedbackRenZiJia.UI.Client.UiModule"
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" 
    xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" 
    xmlns:lvc1="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Feng.Wpf"
      mc:Ignorable="d" 
      d:DesignHeight="400" d:DesignWidth="980"
	 >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.FeedbackRenZiJia.UI.Client;component/Themes/Colors.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.FeedbackRenZiJia.UI.Client;component/Themes/Styles.xaml"/>
                
            </ResourceDictionary.MergedDictionaries>
            <ControlTemplate x:Key="picture_button" TargetType="Button">
                <Border Name="border" BorderThickness="1" CornerRadius="5">
                    <ContentPresenter Content="{TemplateBinding Content}"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter TargetName="border" Property="BorderBrush" Value="LightBlue"/>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter TargetName="border" Property="Background" Value="LightGray"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style x:Key="AxisSectionStyle" TargetType="lvc:AxisSection" >
                <Setter Property="StrokeThickness" Value=".5"/>
                <Setter Property="DataLabel" Value="True"/>
                <Setter Property="DisableAnimations" Value="True"/>
                <Setter Property="DataLabelForeground" Value="White"/>
                <Setter Property="Panel.ZIndex" Value="1"/>
                <Setter Property="SectionOffset" Value="-0.5"/>
                <Setter Property="Fill" Value="{StaticResource Brushes.SelectBoltNo}"/>
                <Setter Property="Stroke" Value="{StaticResource Brushes.SelectBoltNo2}"/>
                <Setter Property="DataLabel" Value="False"/>
            </Style>
            <local:AirRingGraphVmUt x:Key="viewModel"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Style="{StaticResource BorderStyle_module}" >
        <Grid Name="grid" d:DataContext="{StaticResource viewModel}">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="258*" />
            </Grid.RowDefinitions>
            <Border Background="#F0579aab" Height="20" VerticalAlignment="Top" CornerRadius="3,3,0,0"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="204*" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <ResourceDictionary>
                        <Style TargetType="Button" BasedOn="{StaticResource ButtonStyle_empty}">
                            <Setter Property="Width" Value="50"/>
                            <Setter Property="Margin" Value="2"/>
                        </Style>
                        <Style TargetType="Image" x:Key="ImageStyle">
                            <Setter Property="Height" Value="50"/>
                        </Style>
                        <Style TargetType="Image" BasedOn="{StaticResource ImageStyle}"/>

                        <Style TargetType="TextBlock" x:Key="TitleStyle">
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Setter Property="FontFamily" Value="YouYuan"/>
                            <Setter Property="HorizontalAlignment" Value="Center"/>
                        </Style>
                        <Style TargetType="TextBlock" BasedOn="{StaticResource TitleStyle}"/>

                    </ResourceDictionary>
                </Grid.Resources>

                <Button Click="btnInfoClick">
                    <StackPanel>
                        <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/info.png" />
                        <TextBlock Text="设置" />
                    </StackPanel>
                </Button>
                <!--正在检测时,把手动按钮全部隐藏-->
                <StackPanel Orientation="Horizontal" Grid.Column="1" Visibility="{Binding FeedbackHeat.CheckEnable, Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}" >
                    <Button Command="{Binding BaseUpCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/up.png"/>
                            <TextBlock Text="上升" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding BaseDownCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/down.png" />
                            <TextBlock Text="下降" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding AddCmd}">
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/add.png" />
                            <TextBlock Text="加热" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding SubCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/cancel.png" />
                            <TextBlock Text="降温" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding SmoothCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/apache_server.png" />
                            <TextBlock Text="平滑" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding CalCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/aim.png" />
                            <TextBlock Text="计算" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding ApplyCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/checkmark.png" />
                            <TextBlock Text="应用" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding UndoCmd}" >
                        <StackPanel DataContext="{Binding FeedbackHeat}">
                            <Grid>
                                <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/previous.png" />
                                <Grid HorizontalAlignment="Left" VerticalAlignment="Bottom" >
                                    <Ellipse Fill="#FF2F5070" Width="25" Height="25" Opacity="0.8"/>
                                    <TextBlock Text="{Binding UndoIdx}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"  FontFamily="Arial" FontSize="10"/>
                                </Grid>
                            </Grid>
                            <TextBlock >
                                <TextBlock.Style>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource TitleStyle}">
                                        <Setter Property="Text" Value="撤销"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding IsInUndo}" Value="True">
                                                <Setter Property="Text" Value="{Binding UndoTime,StringFormat={}{0:HH:mm}}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                        </StackPanel>
                    </Button>
                    <Button x:Name="btnClearH" Command="{Binding ClearCmd}" Template="{StaticResource picture_button}" >
                        <StackPanel>
                            <Grid>
                                <Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/close.png" />
                                <Grid DataContext="{Binding LPress}" 
                                  HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding IsRunning,Converter={StaticResource visbilityconv}}">
                                    <ed:Arc Width="45" Height="45" Opacity="0.9" 
                                        ArcThickness="4" 
                                        ArcThicknessUnit="Pixel" 
                                        StartAngle="0" EndAngle="360" 
                                        Fill="#FFF1F1F1" Stretch="None" Stroke="#FF988585" />
                                    <ed:Arc Width="45" Height="45"
                                    ArcThickness="4" 
                                    ArcThicknessUnit="Pixel"
                                    StartAngle="0" 
                                        EndAngle="{Binding Progress}"  
                                    Fill="#FF5C7AA0" Stretch="None" Stroke="#FF988585" Opacity="0.9" >
                                    </ed:Arc>
                                </Grid>
                            </Grid>
                            <TextBlock Text="清除" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding SaveCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/diskette.png" />
                            <TextBlock Text="保存" />
                        </StackPanel>
                    </Button>
                    <Button Command="{Binding LoadCmd}" >
                        <StackPanel>
                            <Image Source="/FLY.FeedbackRenZiJia.UI.Client;component/Images/open_folder.png" />
                            <TextBlock Text="读取" />
                        </StackPanel>
                    </Button>

                </StackPanel>

                <StackPanel Orientation="Horizontal" Grid.Column="3">

                    <StackPanel Orientation="Horizontal">
                        <Button Command="{Binding CheckCmd}" Visibility="{Binding FeedbackHeat.HasCheck, Converter={StaticResource visbilityconv}}" >
                            <StackPanel DataContext="{Binding FeedbackHeat}">
                                <Grid >
                                    <Rectangle Fill="Yellow" RadiusX="5" RadiusY="5" Visibility="{Binding HasElectricity, Converter={StaticResource visbilityconv}}"/>
                                    <Image>
                                        <Image.Style>
                                            <Style TargetType="Image" BasedOn="{StaticResource ImageStyle}">
                                                <Setter Property="Source" Value="/FLY.FeedbackRenZiJia.UI.Client;component/Images/nurse.png"/>
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding CheckEnable}" Value="False">
                                                        <Setter Property="Source" Value="/FLY.FeedbackRenZiJia.UI.Client;component/Images/nurse_gray.png"/>
                                                        <Setter Property="Opacity" Value="0.7"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Image.Style>
                                    </Image>
                                </Grid>
                                <TextBlock Style="{StaticResource TitleStyle}" Text="检查" />
                            </StackPanel>
                        </Button>
                        <Button Command="{Binding EnableCmd}"   >
                            <StackPanel DataContext="{Binding FeedbackHeat}">
                                <Image>
                                    <Image.Style>
                                        <Style TargetType="Image">
                                            <Setter Property="Source" Value="/FLY.FeedbackRenZiJia.UI.Client;component/Images/ligthbulb_on.png"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding IsAuto}" Value="False">
                                                    <Setter Property="Source" Value="/FLY.FeedbackRenZiJia.UI.Client;component/Images/ligthbulb_off.png"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                                <TextBlock >
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource TitleStyle}">
                                            <Setter Property="Text" Value="自动"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding IsAuto}" Value="False">
                                                    <Setter Property="Text" Value="手动"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                            </StackPanel>
                        </Button>
                    </StackPanel>
                </StackPanel>
            </Grid>
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <lvc:CartesianChart Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2"
                                MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp">
                    <lvc:CartesianChart.Series>
                        <lvc1:Column2Series 
                        PointGeometry="{x:Null}"
                        StrokeThickness ="1"
                        Stroke="Black"
                        Fill="{StaticResource Brushes.PreHeat}"
                        Values="{Binding HeatOffsets}"
                        Configuration="{Binding Mapper}"/>
                        <lvc:LineSeries 
                        PointGeometry="{x:Null}"
                        StrokeThickness ="3"
                        Stroke="{StaticResource Brushes.Thick}"
                        Fill="Transparent"
                        Values="{Binding ThickPercents}"
                        Configuration="{Binding MapperThickPercents}"/>
                    </lvc:CartesianChart.Series>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" 
                              MinValue="0" MaxValue="{Binding XMax}"
                              >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step ="5"/>
                            </lvc:Axis.Separator>
                            <lvc:Axis.Sections>
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" 
                                Value="{Binding SelectBoltNo}" SectionWidth="{Binding SelectBoltNoWidth}"
                            />
                            </lvc:Axis.Sections>
                        </lvc:Axis>

                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" 
                              LabelFormatter="{Binding YFormatter}"  
                              MinValue="{Binding OffsetGraphYMin}" MaxValue="{Binding OffsetGraphYMax}" FontFamily="Courier New" >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step="{Binding OffsetGraphStep}"/>
                            </lvc:Axis.Separator>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                </lvc:CartesianChart>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="400*"/>
                        <ColumnDefinition Width="280*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="2" Grid.RowSpan="2" Panel.ZIndex="1" 
                  Margin="10,0" VerticalAlignment="Top" HorizontalAlignment="Right">
                        <Viewbox MaxHeight="25">
                            <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 CurrMix,Mode=OneWay}" 
                                           />
                                        </StackPanel>
                                    </Viewbox>
                                    <Viewbox>
                                        <StackPanel Orientation="Horizontal" >
                                            <TextBlock Style="{StaticResource TitleStyle}" 
                                               Foreground="{StaticResource WhiteBrush}"
                                            Background="{StaticResource TextBrush}"
                                           Text="  2σ: " 
                                           />
                                            <TextBlock Style="{StaticResource ValueStyle}" 
                                           Foreground="{StaticResource WhiteBrush}"
                                           Background="{StaticResource TextBrush}"
                                           >
                                                <Run Text="{Binding CurrSigma2,Mode=OneWay, StringFormat={}{0:F1}}"/>%
                                            </TextBlock>
                                        </StackPanel>
                                    </Viewbox>
                                </StackPanel>

                            </StackPanel>
                        </Viewbox>

                    </Grid>
                </Grid>
                <lvc:CartesianChart Grid.Row="1" Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="5,2,2,2"
                                MouseMove="UIElement_OnMouseMove" MouseDown="UIElement_MouseDown" MouseUp="UIElement_MouseUp">
                    <lvc:CartesianChart.Series>
                        <lvc1:Column2Series 
                        PointGeometry="{x:Null}"
                        StrokeThickness ="1"
                        Stroke="Black"
                        Fill="{StaticResource Brushes.PreHeat}"
                        Values="{Binding PreHeats}"
                        Configuration="{Binding MapperPreHeats}"/>
                        <lvc:LineSeries 
                        PointGeometry="{x:Null}"
                        StrokeThickness ="3"
                        Stroke="{StaticResource Brushes.Heat}"
                        Fill="Transparent"
                        Values="{Binding Heats}"
                        Configuration="{Binding Mapper}"/>
                    </lvc:CartesianChart.Series>
                    <lvc:CartesianChart.AxisX>
                        <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" 
                              MinValue="0" MaxValue="{Binding XMax}"
                              >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step ="5"/>
                            </lvc:Axis.Separator>
                            <lvc:Axis.Sections>
                                <lvc:AxisSection Style="{StaticResource AxisSectionStyle}" 
                                Value="{Binding SelectBoltNo}" 
                                 SectionWidth="{Binding SelectBoltNoWidth}"
                                             
                            />
                            </lvc:Axis.Sections>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisX>
                    <lvc:CartesianChart.AxisY>
                        <lvc:Axis Foreground="{StaticResource Brushes.AxisLabel}" 
                              LabelFormatter="{Binding YFormatter}"  
                              MinValue="0" MaxValue="100" FontFamily="Courier New" >
                            <lvc:Axis.Separator>
                                <lvc:Separator Stroke="{StaticResource Brushes.AxisSeparator}" Step="10"/>
                            </lvc:Axis.Separator>
                        </lvc:Axis>
                    </lvc:CartesianChart.AxisY>
                </lvc:CartesianChart>
            </Grid>
        </Grid>
    </Border>
</UserControl>