<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory.ProcessHistoryView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:control="clr-namespace:Aitex.Core.UI.Control;assembly=MECF.Framework.UI.Core"
    xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
    xmlns:converters="clr-namespace:Aitex.Core.UI.Converters;assembly=MECF.Framework.UI.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    xmlns:sciChart="http://schemas.abtsoftware.co.uk/scichart"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    d:DesignHeight="450"
    d:DesignWidth="1800"
    mc:Ignorable="d">
    <UserControl.Resources>
        <converters:LineColorConverter x:Key="colorConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="5" />
            <RowDefinition Height="200" />
        </Grid.RowDefinitions>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid>
                <sciChart:SciChartSurface
                    Name="sciChart"
                    Padding="0,0,0,0"
                    sciChart:ThemeManager.Theme="ExpressionLight"
                    BorderBrush="Gray"
                    DebugWhyDoesntSciChartRender="False"
                    Focusable="False"
                    IsTabStop="False"
                    RenderableSeries="{Binding SelectedData}">
                    <sciChart:SciChartSurface.Resources>
                        <!--  This is the style for the control that hosts the Axis Label  -->
                        <Style x:Key="CursorModAxisLabelStyle" TargetType="sciChart:AxisLabelControl">
                            <Setter Property="Background" Value="#AAFF6600" />
                            <Setter Property="BorderBrush" Value="#FFFF6600" />
                            <Setter Property="BorderThickness" Value="1" />
                            <Setter Property="Foreground" Value="White" />
                            <Setter Property="FontSize" Value="25" />
                        </Style>

                        <Style x:Key="CursorTooltipStyle" TargetType="sciChart:CursorLabelControl">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="sciChart:CursorLabelControl">
                                        <Border
                                            Padding="2.5"
                                            Background="#AAFF6600"
                                            BorderBrush="#FFFF6600"
                                            BorderThickness="2"
                                            Opacity="0.7">
                                            <!--<ItemsControl ItemsSource="{Binding DataContext.SeriesData.SeriesInfo, RelativeSource={RelativeSource TemplatedParent}}">
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate DataType="s:SeriesInfo">
                                                    <ContentControl Content="{Binding}" ContentTemplate="{Binding Path=RenderableSeries.(s:CursorModifier.TooltipTemplate)}" />
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>-->
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </sciChart:SciChartSurface.Resources>

                    <sciChart:SciChartSurface.XAxis>
                        <sciChart:DateTimeAxis
                            Margin="0,0,0,0"
                            sciChart:CursorModifier.AxisLabelContainerStyle="{StaticResource CursorModAxisLabelStyle}"
                            AutoRange="{Binding AutoRangeX}"
                            DrawMinorGridLines="True"
                            DrawMinorTicks="True"
                            Id="DefaultAxisId"
                            SubDayTextFormatting="MM/dd HH:mm:ss"
                            TextFormatting="yyyy/MM/dd HH:mm:ss"
                            TitleFontSize="10"
                            VisibleRange="{Binding TimeRange, Mode=TwoWay}" />
                    </sciChart:SciChartSurface.XAxis>

                    <!--  Create a Y Axis  -->
                    <sciChart:SciChartSurface.YAxis>
                        <sciChart:NumericAxis
                            AutoRange="{Binding AutoRangeY}"
                            AxisAlignment="Right"
                            DrawMinorGridLines="True"
                            DrawMinorTicks="True"
                            Id="DefaultAxisId"
                            VisibleRange="{Binding ValueRange, Mode=TwoWay}">
                            <sciChart:NumericAxis.GrowBy>
                                <sciChart:DoubleRange Max="0.1" Min="0.1" />
                            </sciChart:NumericAxis.GrowBy>
                        </sciChart:NumericAxis>
                    </sciChart:SciChartSurface.YAxis>

                    <sciChart:SciChartSurface.ChartModifier>
                        <sciChart:ModifierGroup ExecuteOn="MouseDoubleClick">
                            <sciChart:RubberBandXyZoomModifier
                                x:Name="rubberBandZoomModifier"
                                ExecuteOn="MouseLeftButton"
                                IsAnimated="True"
                                IsEnabled="True"
                                IsXAxisOnly="False"
                                ReceiveHandledEvents="True"
                                ZoomExtentsY="False" />
                            <sciChart:SeriesSelectionModifier ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True">
                                <sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
                                    <Style TargetType="sciChart:BaseRenderableSeries">
                                        <Setter Property="Stroke" Value="Red" />
                                        <Setter Property="StrokeThickness" Value="3" />
                                        <Setter Property="PointMarkerTemplate">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <sciChart:EllipsePointMarker
                                                        Width="7"
                                                        Height="7"
                                                        Fill="#FF00DC"
                                                        Stroke="White" />
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>

                                </sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
                            </sciChart:SeriesSelectionModifier>

                            <sciChart:ZoomExtentsModifier
                                x:Name="zoomExtentsModifier"
                                ExecuteOn="MouseDoubleClick"
                                ReceiveHandledEvents="True"
                                XyDirection="XYDirection" />

                            <sciChart:CursorModifier
                                IsEnabled="True"
                                ShowAxisLabels="True"
                                ShowTooltip="False"
                                ShowTooltipOn="MouseOver"
                                SourceMode="AllSeries" />

                            <!--  自由平移  -->
                            <sciChart:ZoomPanModifier
                                x:Name="zoomPanModifier"
                                ClipModeX="None"
                                ExecuteOn="MouseRightButton"
                                IsEnabled="True"
                                ReceiveHandledEvents="True"
                                XyDirection="XYDirection" />

                            <sciChart:LegendModifier
                                Margin="10"
                                HorizontalAlignment="Right"
                                GetLegendDataFor="AllSeries"
                                LegendPlacement="Inside"
                                Orientation="Horizontal"
                                ShowLegend="False"
                                ShowVisibilityCheckboxes="False" />

                            <sciChart:RolloverModifier
                                x:Name="rolloverModifier"
                                DrawVerticalLine="False"
                                FontFamily="Arial,SimSun"
                                FontSize="9"
                                IsEnabled="True"
                                ShowAxisLabels="False"
                                SnapsToDevicePixels="False"
                                UseInterpolation="False" />

                            <sciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" XyDirection="XYDirection" />

                        </sciChart:ModifierGroup>

                    </sciChart:SciChartSurface.ChartModifier>
                </sciChart:SciChartSurface>

            </Grid>

            <Button
                Grid.Row="1"
                Width="100"
                Height="30"
                Margin="0,5"
                HorizontalAlignment="Left"
                Content="Select Data"
                IsEnabled="{Binding IsPermission}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <micro:ActionMessage MethodName="SelectData" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

        </Grid>

        <GridSplitter
            Grid.Row="1"
            Height="5"
            Margin="0"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Center"
            Background="LightBlue" />
        <DataGrid
            Grid.Row="2"
            Margin="5,0,0,0"
            AlternationCount="2"
            AutoGenerateColumns="False"
            CanUserAddRows="False"
            CanUserResizeColumns="True"
            CanUserResizeRows="False"
            ColumnHeaderHeight="30"
            FontFamily="Arial"
            FontSize="14"
            IsEnabled="{Binding IsPermission}"
            ItemsSource="{Binding SelectedData}">
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <StackPanel
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Orientation="Horizontal">
                                <!--<CheckBox Foreground="{DynamicResource FG_White}" VerticalAlignment="Center">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <cal:ActionMessage MethodName="VisibleCheckAll">
                                            </cal:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>-->
                                <TextBlock
                                    Margin="3,0,0,0"
                                    VerticalAlignment="Bottom"
                                    Text="Visible" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <!--<i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="VisibleCheck">
                                            <cal:Parameter Value="{Binding }"/>
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>-->
                            </CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="200" Header="Source">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock
                                Margin="5,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{Binding DataSource}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="150" Header="Name">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock
                                Margin="5,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{Binding DataName}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="100" Header="Color">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                Width="50"
                                HorizontalAlignment="Stretch"
                                Background="{Binding Stroke, Converter={StaticResource colorConverter}}"
                                Style="{DynamicResource Color_Button}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="SelectColor">
                                            <micro:Parameter Value="{Binding}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="100" Header="Factor">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:TextBoxEx
                                Width="80"
                                Margin="5,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                AllowBackgroundChange="False"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{Binding DataFactor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <!--<i:Interaction.Triggers>
                                    <i:EventTrigger EventName="LostFocus">
                                        <cal:ActionMessage MethodName="FactorLostFocus">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="KeyDown">
                                        <cal:ActionMessage MethodName="FactorKeyDown">
                                            <cal:Parameter Value="$eventargs" />
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>-->
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="100" Header="Offset">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:TextBoxEx
                                Width="80"
                                Margin="5,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                AllowBackgroundChange="False"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{Binding DataOffset, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <!--<i:Interaction.Triggers>
                                    <i:EventTrigger EventName="LostFocus">
                                        <cal:ActionMessage MethodName="OffsetLostFocus">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="KeyDown">
                                        <cal:ActionMessage MethodName="OffsetKeyDown">
                                            <cal:Parameter Value="$eventargs" />
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>-->
                            </controls:TextBoxEx>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn MinWidth="60" Header="Width">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <controls:TextBoxEx
                                Width="80"
                                Margin="5,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                AllowBackgroundChange="False"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{Binding LineThickness, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <!--<i:Interaction.Triggers>
                                    <i:EventTrigger EventName="LostFocus">
                                        <cal:ActionMessage MethodName="WidthLostFocus">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="KeyDown">
                                        <cal:ActionMessage MethodName="WidthKeyDown">
                                            <cal:Parameter Value="$eventargs" />
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>-->
                            </controls:TextBoxEx>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="120">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <Button
                                Width="85"
                                Height="25"
                                Content="Export All">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="ExportAll" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                Width="65"
                                Height="25"
                                Content="Export">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="Export">
                                            <micro:Parameter Value="{Binding}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Width="120">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <Button
                                Width="85"
                                Height="25"
                                Content="Delete All">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="DeleteAll" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                Width="65"
                                Height="25"
                                Content="Delete">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="Delete">
                                            <micro:Parameter Value="{Binding}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
