<UserControl x:Class="ProximaAnalizer.Views.DBInfoAlarm"
             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:ProximaAnalizer.Views"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:controls="clr-namespace:ProximaAnalizer.Controls"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <!--<ResourceDictionary Source="/UICommon;component/Resources.xaml"/>-->
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Margin="4">

        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="4"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Margin="4">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="4"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="360"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition />
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="540"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="104"/>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <GroupBox Header="基本信息">
                <Grid Margin="8" VerticalAlignment="Top">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="8"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="8"/>
                        <RowDefinition Height="auto"/>
                        <!--<RowDefinition Height="8"/>
                        <RowDefinition Height="48"/>-->
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0" Grid.Row="0" VerticalAlignment="Center">配方名称：</TextBlock>
                    <TextBlock Grid.Column="2" Grid.Row="0" VerticalAlignment="Center" Text="{Binding RecipeName}" ToolTip="{Binding RecipeName}"/>

                    <TextBlock Grid.Column="0" Grid.Row="2" VerticalAlignment="Center">所属步法：</TextBlock>
                    <TextBlock Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" Text="{Binding CurrentRecipeStep.Step_Name}"/>

                    <TextBlock Grid.Column="0" Grid.Row="4" VerticalAlignment="Center">日期时间：</TextBlock>
                    <TextBlock Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" Text="{Binding Current, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                </Grid>
            </GroupBox>
            <GroupBox Grid.Column="2" Header="报警信息">
                <controls:AlarmPicker Margin="8" AlarmSource="{Binding Alarms}" SelectedAlarm="{Binding SelectedAlarm, Mode=TwoWay}"/>
            </GroupBox>

            <GroupBox Header="时间轴" Grid.Column="4">
                <Grid Margin="8" VerticalAlignment="Top">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="8"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="2"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="Prev Alarm" Command="{Binding TimeOperaCommand}" CommandParameter="---"/>
                        <Button Grid.Column="2" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="-1 min" Command="{Binding TimeOperaCommand}" CommandParameter="--"/>
                        <Button Grid.Column="4" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="-1s" Command="{Binding TimeOperaCommand}" CommandParameter="-"/>

                        <StackPanel Grid.Column="5" Orientation="Horizontal" HorizontalAlignment="Center">
                            <Button Margin="4,0" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Visibility="{Binding PlayVis}" Command="{Binding PlayCommand}" CommandParameter="play">
                                <Image Source="{StaticResource Icon_Start}" Height="16"/>
                            </Button>
                            <Button Margin="4,0" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Visibility="{Binding StopVis}" Command="{Binding PlayCommand}" CommandParameter="stop">
                                <Image Source="{StaticResource Icon_Pause}" Height="16"/>
                            </Button>
                        </StackPanel>

                        <Button Grid.Column="6" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="+1s" Command="{Binding TimeOperaCommand}" CommandParameter="+" />
                        <Button Grid.Column="8" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="+1 min" Command="{Binding TimeOperaCommand}" CommandParameter="++"/>
                        <Button Grid.Column="10" VerticalAlignment="Center" Style="{StaticResource FunctionButton}" Content="Next Alarm" Command="{Binding TimeOperaCommand}" CommandParameter="+++"/>
                    </Grid>

                    <Slider Grid.Row="2" Grid.ColumnSpan="5" Style="{StaticResource MySliderStyle}" Minimum="{Binding Start.Ticks}" Maximum="{Binding End.Ticks}" TickFrequency="10000000" Value="{Binding CurrentLong, Mode=TwoWay}"/>

                    <Grid Grid.Row="4">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" VerticalAlignment="Top" Text="{Binding Start, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                        <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Current, StringFormat=HH:mm:ss}"/>

                        <TextBlock Grid.Column="2" VerticalAlignment="Top" Text="{Binding End, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                    </Grid>
                </Grid>
            </GroupBox>

            <GroupBox Grid.Column="6" Header="趋势图">
                <Button Grid.Row="0" Background="Transparent" BorderThickness="0" Command="{Binding SingleTraceCommand}">
                    <Grid TextElement.Foreground="Black">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="24"/>
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <Image Source="{StaticResource Icon_HistoryPlot}" VerticalAlignment="Center" Height="32"/>
                            <TextBlock VerticalAlignment="Center">~1min</TextBlock>
                        </StackPanel>
                        <TextBlock Grid.Row="2" Text="{Binding Selected.Key}" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center"/>
                    </Grid>
                </Button>
            </GroupBox>
            <GroupBox Grid.Column="8" Header="导航">
                <Grid Grid.Column="6" Margin="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="2"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Button Grid.Row="0" Style="{StaticResource FunctionButton}" Command="{Binding ReturnCommand}" Background="{StaticResource WarningColor}">返回</Button>
                    <Button Grid.Row="2" Style="{StaticResource FunctionButton}" Command="{Binding NaviCommand}" CommandParameter="AlarmData">数据</Button>
                    <Button Grid.Row="4" Style="{StaticResource FunctionButton}" Command="{Binding NaviCommand}" CommandParameter="AlarmGasPanel">气路图</Button>
                </Grid>
            </GroupBox>
        </Grid>

        <ContentControl Grid.Row="2" prism:RegionManager.RegionName="AlarmRegion"/>

    </Grid>

</UserControl>
