<UserControl x:Class="HistoryView.Views.Regions.SettingSubs.ChannelSummary"
             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:HistoryView.Views.Regions.SettingSubs"
             xmlns:controls="clr-namespace:HistoryView.Controls"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"        
             xmlns:resource="clr-namespace:HistoryView.Resources"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="8"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <!--<Border BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="0" Margin="8">
            <Grid Margin="4,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="0"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Height="auto"/>
                    --><!--<RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>--><!--
                </Grid.RowDefinitions>
                <TextBlock FontSize="14" FontWeight="Bold" Text="{DynamicResource ChannelDisplayFilter}"/>
                <Border Grid.Row="2"  BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="1">
                    <ScrollViewer  VerticalScrollBarVisibility="Hidden" Margin="8" VerticalAlignment="Top">
                        <ItemsControl ItemsSource="{Binding Display}" >
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Style="{StaticResource ThemeCheckBox}" IsChecked="{Binding Value.IsDisplay}" 
                                          Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor ,AncestorType=local:ChannelSummary}, Path=DataContext.SelectCommand}" Margin="2">
                                        <TextBlock Text="{Binding Key.Name}" Foreground="{StaticResource TextColor}"/>
                                    </CheckBox>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <UniformGrid Columns="1"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </ScrollViewer>
                </Border>

                <Button Grid.Row="6" Style="{StaticResource FunctionButton}" Command="{Binding RefreshDisplayCommand}" CommandParameter="All" Height="28" Content="{DynamicResource SelectAll}"/>
                <Button Grid.Row="8" Style="{StaticResource FunctionButton}" Command="{Binding RefreshDisplayCommand}" CommandParameter="None" Background="{StaticResource BackgroundDarkColor}" Height="28" Content="{DynamicResource SelectNone}"/>
   
            </Grid>

        </Border>-->
        <Border Grid.Column="2" BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="2" Margin="8">

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Grid TextElement.FontSize="12">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="*"/>
                        <!--<ColumnDefinition/>-->
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6" Text="Mini8"/>
                    <TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Text="Channel"/>
                    <TextBlock Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Center" Text="SensorBreak"/>
                    <TextBlock Grid.Column="6" VerticalAlignment="Center" HorizontalAlignment="Center" Text="PV"/>
                    <TextBlock Grid.Column="8" VerticalAlignment="Center" HorizontalAlignment="Center" Text="SetPoint"/>
                    <TextBlock Grid.Column="10" VerticalAlignment="Center" HorizontalAlignment="Center" Text="Output"/>
                    <TextBlock Grid.Column="12" VerticalAlignment="Center" HorizontalAlignment="Center" Text="AutoTune"/>
                    <TextBlock Grid.Column="14" VerticalAlignment="Center" HorizontalAlignment="Center" Text="UpRate"/>
                    <TextBlock Grid.Column="16" VerticalAlignment="Center" HorizontalAlignment="Center" Text="DownRate"/>
                    <TextBlock Grid.Column="18" VerticalAlignment="Center" HorizontalAlignment="Center" Text="Inhibit"/>
                    <TextBlock Grid.Column="20" VerticalAlignment="Center" HorizontalAlignment="Center" Text="P"/>
                    <TextBlock Grid.Column="22" VerticalAlignment="Center" HorizontalAlignment="Center" Text="I"/>
                    <TextBlock Grid.Column="24" VerticalAlignment="Center" HorizontalAlignment="Center" Text="D"/>
                    <TextBlock Grid.Column="26" VerticalAlignment="Center" HorizontalAlignment="Center" Text="Mode"/>
                </Grid>

                <resource:TouchableScrollViewer VerticalScrollBarVisibility="Hidden" Grid.Row="2" TextElement.FontSize="12">
                    <ItemsControl ItemsSource="{Binding Channels}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border  BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="0,0,0,0">
                                    <Grid >
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="60"/>
                                            <ColumnDefinition Width="0"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Border  BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="0,0.5,1,0.5">
                                            <TextBlock Text="{Binding Key.Name}" TextWrapping="WrapWithOverflow" Block.TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                        </Border>
                                        <Grid Grid.Column="2">
                                            <ItemsControl ItemsSource="{Binding Value}">
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <Border Background="Transparent" BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="0,0.5">
                                                            <Grid >
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="40"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="40"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="40"/>
                                                                    <ColumnDefinition Width="0"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                </Grid.ColumnDefinitions>
                                                                <TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,8" TextWrapping="WrapWithOverflow" Block.TextAlignment="Center" Text="{Binding Name}"/>
                                                                <TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SensorBreakAlarm}"/>
                                                                <TextBlock Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding PV, StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="6" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SetPoint, StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="8" VerticalAlignment="Center" HorizontalAlignment="Center">
                                                                    <Run Text="{Binding WorkingOutput, StringFormat=0.00}"/>
                                                                    <Run> %</Run>
                                                                </TextBlock>
                                                                <TextBlock Grid.Column="10" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding AutoTuneStatus}"/>
                                                                <TextBlock Grid.Column="12" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SetpointUpRate, StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="14" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding SetpointDownRate, StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="16" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Inhibit}"/>
                                                                <TextBlock Grid.Column="18" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Running_P,StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="20" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Running_I,StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="22" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Running_D,StringFormat=0.0}"/>
                                                                <TextBlock Grid.Column="24" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding ChannelMode}"/>

                                                            </Grid>
                                                        </Border>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </Grid>
                                    </Grid>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </resource:TouchableScrollViewer>

            </Grid>
        </Border>
    </Grid>
</UserControl>