<UserControl x:Class="HistoryUI.Views.LogTrace"
             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:HistoryUI.Views"
             mc:Ignorable="d" 
             xmlns:hc="https://handyorg.github.io/handycontrol"
             xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True">
    <Grid Background="{StaticResource BackgroundColor}">
        <!--<Grid Background="#50FFFFFF" Panel.ZIndex="1" Visibility="{Binding Loading}">
            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                <TextBlock FontSize="32">Loading Data...</TextBlock>
            </StackPanel>
        </Grid>-->
        <Grid  Margin="8">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="0"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="16"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="8"/>
            </Grid.RowDefinitions>

            <Grid Grid.Row="0" Margin="8,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"/>
                </Grid.ColumnDefinitions>
                <GroupBox Header="Start Time" BorderThickness="0">
                    <hc:DateTimePicker MinWidth="160" Height="32" SelectedDateTime="{Binding StartTime}"/>
                </GroupBox>
                <GroupBox Grid.Column="2" Header="End Time" BorderThickness="0">
                    <hc:DateTimePicker MinWidth="160" Height="32" SelectedDateTime="{Binding EndTime}"/>
                </GroupBox>
                <GroupBox Grid.Column="4" Header="Mini8" BorderThickness="0">
                    <hc:ComboBox MinWidth="160" Height="32" ItemsSource="{Binding Hardwares.Mini8s}" SelectedItem="{Binding SelectedMini8}" DisplayMemberPath="Value.Name"/>
                </GroupBox>
                <Button Grid.Column="6" Margin="0,8,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource FunctionButton}" Command="{Binding QueryCommand}" MinWidth="80" Height="32">Query</Button>
                <Button Grid.Column="8" Margin="0,8,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource FunctionButton}" Command="{Binding ExitCommand}" Background="{StaticResource EmergencyColor}" MinWidth="80" Height="32">Exit</Button>
            </Grid>

            <ContentControl Grid.Row="2" Content="{Binding PlotControl, Mode=OneTime}"/>


            <Grid Grid.Row="4">
                <ItemsControl ItemsSource="{Binding ChannelDetails}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Style="{StaticResource FunctionCheckBox}"  Content="{Binding Value.ChannelData.Name}" Background="{Binding Value.ChannelColor}" IsChecked="{Binding Value.IsSelected, Mode=TwoWay}" Width="88"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
                <StackPanel Grid.Column="4" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="20,0" Orientation="Horizontal">
                    <Button VerticalAlignment="Center" Width="48" Command="{Binding ReScaleCommand}" CommandParameter="add">↑</Button>
                    <Button VerticalAlignment="Center" Width="48" Margin="8,0" Command="{Binding ReScaleCommand}" CommandParameter="minus">↓</Button>
                    <Button VerticalAlignment="Center" Width="48" Command="{Binding ReScaleCommand}" CommandParameter="+">+</Button>
                    <Button VerticalAlignment="Center" Width="48" Margin="8,0" Command="{Binding ReScaleCommand}" CommandParameter="-">-</Button>
                    <Button VerticalAlignment="Center"  Command="{Binding ReScaleCommand}" CommandParameter="Re">AutoScale</Button>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
