<UserControl x:Class="ProximaAnalizer.Views.Dialog.SingleTracePlot"
             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.Dialog"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Background="{StaticResource BackgroundColor}">

        <Grid Margin="8" MinWidth="1200">
            <Grid.RowDefinitions>
                <RowDefinition MinHeight="480"/>
                <RowDefinition Height="0"/>
                <RowDefinition Height="auto" />
                <RowDefinition Height="0"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ContentControl Content="{Binding PlotControl, Mode=OneTime}"/>
            <TextBlock Panel.ZIndex="1" Text="{Binding Hint}" Margin="18,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
            <GroupBox Grid.Row="2" Header="Data Picker" Visibility="{Binding TabVis}" Margin="0,8,0,0">
                <ItemsControl Grid.Row="2" ItemsSource="{Binding Tabs}" Margin="8">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Button Background="Transparent" Margin="2" 
                            Command="{Binding RelativeSource={RelativeSource AncestorType=local:SingleTracePlot, Mode=FindAncestor}, Path=DataContext.SelectTabCommand}"
                            CommandParameter="{Binding}">
                                <TextBlock Text="{Binding}" Margin="0,2"/>
                            </Button>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </GroupBox>

            <GroupBox Grid.Row="4" Header="Alarms" Visibility="{Binding AlarmVis}" Margin="0,8,0,0">
                <DataGrid Grid.Row="4" ItemsSource="{Binding Events}"
                   Margin="8" MaxHeight="180"
                   IsReadOnly="True"
                   CanUserAddRows="False"
                   CanUserDeleteRows="False"
                   CanUserResizeRows="False"
                   CanUserSortColumns="False"
                   GridLinesVisibility="All"
                   HorizontalGridLinesBrush="{StaticResource DarkBorderColor}"
                   VerticalGridLinesBrush="{StaticResource DarkBorderColor}"
                   AutoGenerateColumns="False"
                   ColumnHeaderHeight="22"
                   RowHeight="22"
                   VerticalAlignment="Top"
                  BorderBrush="{StaticResource DarkBorderColor}"
                   Background="{StaticResource BackgroundColor}" >
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="Time" Width="80">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Occur_Time, StringFormat=HH:mm:ss.f}"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Source" MinWidth="64">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Source}"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Level" Width="64">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Level}"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Event Enum">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Event_Enum}" Margin="8,0"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>


                        <DataGridTemplateColumn Header="Detail" Width="auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Description}" Margin="8,0"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                    </DataGrid.Columns>
                </DataGrid>
            </GroupBox>
        </Grid>
    </Border>
</UserControl>
