<Page x:Class="FLY.IBC.UI.Client.PgTempAreaParam"
      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:ed="http://schemas.microsoft.com/expression/2010/drawing" 
      mc:Ignorable="d" 
      d:DesignHeight="1000" d:DesignWidth="964"
      Unloaded="Page_Unloaded"
      xmlns:ut="clr-namespace:FLY.IBC.UI.Client.UnitTests"
      xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
      Background="White" >
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.IBC.UI.Client;component/UnitTests/UnitTests_ibc.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ut:IbcServiceUt x:Key="viewModel"/>
        </ResourceDictionary>
    </Page.Resources>
    <Grid d:DataContext="{Binding Source={StaticResource viewModel},Path=TAreas[0]}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"  >
                <Run Text="{Binding Number}" FontFamily="Arial"/>
                <Run Text="温度设置"/>
            </TextBlock>
        </StackPanel>
        <ScrollViewer Grid.Row="1" >
            <StackPanel>
                <StackPanel Orientation="Horizontal" Margin="10">
                    <StackPanel.Resources>
                        <sys:Double x:Key="RowHeight">50</sys:Double>
                        <sys:Double x:Key="ColWidth">120</sys:Double>
                        <sys:Double x:Key="RowHeaderWidth">150</sys:Double>
                        <sys:Double x:Key="ColHeaderHeight">40</sys:Double>

                        <Style TargetType="TextBlock" x:Key="TextBlockStyle_RowHeader" BasedOn="{StaticResource TextBlockStyle_FieldHeader}">
                            <Setter Property="HorizontalAlignment" Value="Center"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Style>
                        <Style x:Key="RowHeaderBorderStyle" TargetType="Border">
                            <Setter Property="Background" Value="{StaticResource Color_theme_static}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource Color_theme_activity}"/>
                            <Setter Property="BorderThickness" Value="1"/>
                            <Setter Property="Height" Value="{StaticResource RowHeight}"/>
                            <Setter Property="Width" Value="{StaticResource RowHeaderWidth}"/>
                            <Style.Resources>
                                <ResourceDictionary>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle_RowHeader}"/>
                                </ResourceDictionary>
                            </Style.Resources>
                        </Style>

                        <Style x:Key="RowHeaderEditableBorderStyle" TargetType="Border" BasedOn="{StaticResource RowHeaderBorderStyle}">
                            <Setter Property="Background" Value="{StaticResource Color_theme_activity}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource Color_theme_static}"/>
                        </Style>

                        <Style x:Key="ColumnHeaderBorderStyle" TargetType="Border" BasedOn="{StaticResource RowHeaderBorderStyle}">
                            <Setter Property="Height" Value="{StaticResource ColHeaderHeight}"/>
                            <Setter Property="Width" Value="{StaticResource ColWidth}"/>
                        </Style>
                        <Style x:Key="ColumnHeaderEditableBorderStyle" TargetType="Border" BasedOn="{StaticResource RowHeaderEditableBorderStyle}">
                            <Setter Property="Height" Value="{StaticResource ColHeaderHeight}"/>
                            <Setter Property="Width" Value="{StaticResource ColWidth}"/>
                        </Style>

                        <Style TargetType="TextBox" x:Key="TextBoxStyle_Content" BasedOn="{StaticResource TextBoxStyle_FieldContent}">

                            <Setter Property="Background" Value="#FF80C3EE"/>
                        </Style>
                        <Style TargetType="TextBlock" x:Key="TextBlockStyle_Content" BasedOn="{StaticResource TextBlockStyle_FieldContent}">

                        </Style>


                        <Style x:Key="RowBorderStyle0" TargetType="Border">
                            <Setter Property="Height" Value="{StaticResource RowHeight}"/>
                            <Setter Property="Width" Value="{StaticResource ColWidth}"/>
                            <Style.Resources>
                                <ResourceDictionary>
                                    <Style TargetType="TextBox" BasedOn="{StaticResource TextBoxStyle_Content}"/>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle_Content}"/>
                                </ResourceDictionary>
                            </Style.Resources>
                        </Style>

                        <Style x:Key="RowBorderStyle1" TargetType="Border" BasedOn="{StaticResource RowBorderStyle0}">
                            <Setter Property="Background" Value="LightGray"/>
                        </Style>
                        <Style x:Key="ColBorderStyle" TargetType="Border">
                            <Setter Property="BorderThickness" Value="1"/>
                            <Setter Property="BorderBrush" Value="{StaticResource Color_theme_static}"/>
                        </Style>
                    </StackPanel.Resources>

                    <StackPanel >
                        <Grid Height="{StaticResource ColHeaderHeight}"/>
                        <Border Style="{StaticResource RowHeaderBorderStyle}">
                            <TextBlock Text="温度显示" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="通道设置" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="比例设定" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="积分设定" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="微分设定" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="温度修正" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="冷却设定" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderEditableBorderStyle}">
                            <TextBlock Text="自整定" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderBorderStyle}">
                            <TextBlock Text="比例显示" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderBorderStyle}">
                            <TextBlock Text="积分显示" />
                        </Border>
                        <Border Style="{StaticResource RowHeaderBorderStyle}">
                            <TextBlock Text="微分显示" />
                        </Border>
                    </StackPanel>

                    <ItemsControl ItemsSource="{Binding Temperatures}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border Style="{StaticResource ColBorderStyle}" >
                                    <StackPanel>
                                        <Border Style="{StaticResource ColumnHeaderEditableBorderStyle}">
                                            <TextBlock >
                                    <Run Text="{Binding Number}"/><Run Text="区"/>
                                            </TextBlock>
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBlock Text="{Binding TempPV}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle1}">
                                            <TextBox Text="{Binding Channel}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBox Text="{Binding PSet}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle1}">
                                            <TextBox Text="{Binding ISet}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBox Text="{Binding DSet}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle1}">
                                            <TextBox Text="{Binding TempCorr}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBox Text="{Binding CoolingSet}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle1}">
                                            <Viewbox >
                                                <flyctrl:NoToggleButton Margin="{StaticResource ControlMargin}" 
                                        OnLabel="启动" 
                                        OffLabel="关闭" 
                                        IsChecked="{Binding IsSelfAdjusting}" Click="btnATClick" Tag="{Binding .}"/>
                                            </Viewbox>
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBlock Text="{Binding P}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle1}">
                                            <TextBlock Text="{Binding I}" />
                                        </Border>
                                        <Border Style="{StaticResource RowBorderStyle0}">
                                            <TextBlock Text="{Binding D}" />
                                        </Border>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
            </StackPanel>

        </ScrollViewer>
    </Grid>
</Page>