<UserControl x:Class="HisDataTools.View.HisDataQueryView"
             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:HisDataTools.View"
             xmlns:res="clr-namespace:HisDataTools"
             xmlns:chart="clr-namespace:HeBianGu.WPF.EChart"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="926">
    <UserControl.Resources>
        <res:IndexConverter x:Key="ic" />
        <local:QualityValueConvert x:Key="qvc" />
        <local:ResultValueConvert x:Key="rvc" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="64"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <ComboBox VirtualizingPanel.IsVirtualizing="True" IsEditable="True" Text="{Binding SelectTag,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding TagList}"  HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="154" Grid.Column="1"/>
            <Label Content="{res:ResMarker StartTime, :}" HorizontalAlignment="Left" Margin="170,10,0,0" VerticalAlignment="Top" Grid.Column="1"/>
            <DatePicker SelectedDate="{Binding StartTime,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Margin="5,10,0,0" VerticalAlignment="Top" Width="150" Grid.Column="2"/>
            <ComboBox ItemsSource="{Binding HourItems}" SelectedIndex="{Binding StartTimeHour,UpdateSourceTrigger=PropertyChanged}" IsEditable="True"  HorizontalAlignment="Left" Margin="170,10,0,0" VerticalAlignment="Top" Width="60" Grid.Column="2"/>

            <Label Content="{res:ResMarker EndTime, :}" HorizontalAlignment="Left" Margin="240,10,0,0" VerticalAlignment="Top" Grid.Column="2"/>

            <Button Content="{res:ResMarker Query}" Command="{Binding QueryCommand}"  HorizontalAlignment="Right" Padding="2" Margin="0,10,10,0" VerticalAlignment="Top"  Width="79" Grid.Column="3"/>

            <Label Content="{res:ResMarker Tag,:}" HorizontalAlignment="Left" Margin="5,10,0,0" VerticalAlignment="Top"/>
            <DatePicker SelectedDate="{Binding EndTime,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Margin="5,10,0,0" Grid.Column="3"/>
            <ComboBox ItemsSource="{Binding HourItems}" SelectedIndex="{Binding EndTimeHour,UpdateSourceTrigger=PropertyChanged}" IsEditable="True"  HorizontalAlignment="Left" Margin="170,10,0,0" VerticalAlignment="Top" Width="60" Grid.Column="3"/>
            <Label Content="{res:ResMarker TimeSpan, :}" HorizontalAlignment="Left" Margin="5,32,0,0" VerticalAlignment="Top"/>
            <ComboBox  IsEditable="True" Text="{Binding TimeSpan,UpdateSourceTrigger=PropertyChanged}"   HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Width="154" Grid.Column="1"/>
            <CheckBox IsChecked="{Binding AllValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Content="{res:ResMarker AllValue}" Grid.Column="2" HorizontalAlignment="Left" Margin="5,42,0,0" VerticalAlignment="Top"/>
            <Label Content="{Binding OpMessage}" Grid.Column="3" Margin="0,40,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" />


        </Grid>

        <TabControl Grid.Row="1" TabStripPlacement="Bottom">
            <TabItem Header="{res:ResMarker DataTable}">
                <Grid Background="#FFE5E5E5">
                    <DataGrid IsReadOnly="True" AutoGenerateColumns="False" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.ScrollUnit="Item" CanUserAddRows="False" CanUserDeleteRows="False"  ItemsSource="{Binding Datas}"  >
                        <DataGrid.Columns>
                            <DataGridTemplateColumn   IsReadOnly="True" Width="Auto" MinWidth="30" Header="{res:ResMarker Id}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" >
                                            <TextBlock.Text>
                                                <MultiBinding Converter="{StaticResource ic}">
                                                    <Binding />
                                                    <Binding Path="ItemsSource" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}" />
                                                    <Binding Path="ItemsSource.Count" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}" />
                                                </MultiBinding>
                                            </TextBlock.Text>
                                        </TextBlock>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn  IsReadOnly="True" Width="200" MinWidth="100" Header="{res:ResMarker DateTime}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock HorizontalAlignment="Center" Text="{Binding DateTimeString}" VerticalAlignment="Center" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn  IsReadOnly="True" Width="200" MinWidth="100" Header="{res:ResMarker Value}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock HorizontalAlignment="Center" Text="{Binding Value,Converter={StaticResource rvc}}" VerticalAlignment="Center" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn  IsReadOnly="True" Width="Auto" MinWidth="30" Header="{res:ResMarker Quality}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock HorizontalAlignment="Center" Text="{Binding Quality,Converter={StaticResource qvc}}" VerticalAlignment="Center" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
            <TabItem Header="{res:ResMarker Chart}">
                <Grid Background="#FFE5E5E5">
                    <chart:StaticCurveChartPlotter DataSource="{Binding ChartSource}" SplitItemYs="{Binding YLineItems}" MaxValueX="{Binding MaxXValue}" MinValueX="{Binding MinXValue}" MaxValueY="{Binding MaxYValue}"  IsLegendVisible="True" MinValueY="{Binding MinYValue}" Background="White" FontSize="12" Foreground="Black" >
                        <!--<chart:StaticCurveChartPlotter.SplitItemYs>
                            <chart:SplitItem Color="DarkGray" Value="-1" Text="-1" />
                            <chart:SplitItem Color="DarkGray" Value="0" Text="0" />
                            <chart:SplitItem Color="DarkGray" Value="1" Text="1" />
                        </chart:StaticCurveChartPlotter.SplitItemYs>-->
                    </chart:StaticCurveChartPlotter>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>
