<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="TempAreaPanelStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>


    <!--温度模板中的数码管 显示框 -->
    <Style TargetType="{x:Type TextBlock}" x:Key="SegTextStyle">
        <Setter Property="FontFamily" Value="NI7SEG"/>
        <Setter Property="FontSize" Value="20"/>
        <Setter Property="Background" Value="{StaticResource SegBgBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource SegGreenBrush}"/>

        <Setter Property="Margin" Value="2"/>
        <Setter Property="Padding" Value="5,2"/>
    </Style>

    <!--温度模板中的数码管 输入框 -->
    <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBoxStyle1}" x:Key="SegInputStyle">
        <Setter Property="FontFamily" Value="NI7SEG"/>
        <Setter Property="FontSize" Value="30"/>
        <Setter Property="Background" Value="{StaticResource SegBgBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource SegGreenBrush}"/>

        <Setter Property="Margin" Value="2"/>
        <Setter Property="Padding" Value="5,2"/>
    </Style>

    <!--温度控制器模板中的灯 例如Run灯 -->
    <Style x:Key="LedStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Foreground" Value="{StaticResource PrintBrush}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="IsEnabled" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <StackPanel HorizontalAlignment="Center">
                        <ContentPresenter/>
                        <iconPacks:PackIconMaterial x:Name="icon" Kind="CircleSlice8" 
                                                            Width="10" Height="{Binding Width, RelativeSource={RelativeSource Mode=Self}}" 
                                                            Foreground="{StaticResource LedRedBrush}"
                                                            HorizontalAlignment="Center"/>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="icon" Property="Foreground"  Value="{StaticResource LedGreenBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--温度控制器模板 UcTcSet.xaml是测试,用模板可以快50%-->
    <DataTemplate x:Key="TcSetTemplate">
        <Grid >
        <Border Background="{StaticResource Color_background}" >
            <Grid Margin="3">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <StackPanel>
                    <Grid Margin="2" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="PV" Style="{StaticResource Styles.Text.FieldHeader}" Margin="2"
                                   Foreground="{StaticResource Color_title}"
                                   FontSize="{StaticResource FontSize_title}"/>
                        <TextBlock Grid.Column="1" 
                                   Style="{StaticResource SegTextStyle}" Foreground="{StaticResource Color_text}" Background="{StaticResource Color_background2}"
                                   Text="{Binding TempPV,StringFormat={}{0:0.#}}" />
                    </Grid>
                    <Grid Margin="2" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="SV" Margin="2" Style="{StaticResource Styles.Text.FieldHeader.Editable}"
                                   Foreground="{StaticResource Color_title_activity}"
                                   FontSize="{StaticResource FontSize_title}"/>
                        <TextBox Grid.Column="1" 
                                   Style="{StaticResource SegInputStyle}" 
                                 Foreground="{StaticResource Color_text_activity}" 
                                 Background="{StaticResource Color_background2}"
                                   Text="{Binding TempSVSet,StringFormat={}{0:0.#}}" />
                    </Grid>
                    <Grid Margin="2,2,2,5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <ToggleButton Grid.Column="0" IsChecked="{Binding IsHeatingSet,Mode=OneWay}" Content="Run" Style="{StaticResource LedStyle}" Foreground="{StaticResource Color_text}"/>
                        <ToggleButton Grid.Column="1" IsChecked="{Binding IsHeating,Mode=OneWay}" Content="OT1" Style="{StaticResource LedStyle}" Foreground="{StaticResource Color_text}"/>
                        <ToggleButton Grid.Column="2" IsChecked="{Binding IsSelfAdjusting,Mode=OneWay}" Content="AT" Style="{StaticResource LedStyle}" Foreground="{StaticResource Color_text}"/>
                        <ToggleButton Grid.Column="3" IsChecked="{Binding IsCooling,Mode=OneWay}" Content="OT2" Style="{StaticResource LedStyle}" Foreground="{StaticResource Color_text}"/>
                    </Grid>
                    <flyctrl:ToggleButtonOnOff Style="{StaticResource ToggleButtonOnOffStyle}" HorizontalAlignment="Center" Margin="{StaticResource ControlMargin}" 
                            OnLabel="运行" OnBrush="{StaticResource Color_on}"
                            OffLabel="停止" OffBrush="{StaticResource Color_off}"
                            IsChecked="{Binding IsHeatingSet}"/>
                </StackPanel>


            </Grid>
        </Border>
        <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top"
                           Background="{StaticResource Color_badgeBg}" Foreground="{StaticResource Color_badgeText}" 
                           Padding="6,2"
                           FontSize="30"
                           Text="{Binding Number}" Margin="0,-5,-5,0"/>
    </Grid>
    </DataTemplate>

    <!--全部温度控制器模板 -->
    <DataTemplate x:Key="TcAllSetTemplate">
        <Grid >
            <Border Background="{StaticResource Color_background}" >
                <Grid Margin="3">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>

                    <StackPanel >
                        <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top"
                           Background="{StaticResource Color_badgeBg}" Foreground="{StaticResource Color_badgeText}" 
                           Padding="6,2"
                           FontSize="30"
                           Margin="0,-5,-5,0">
                        <Run Text="{Binding Number}"/><Run Text="层"/>
                        </TextBlock>
                        <StackPanel>
                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Margin="3,0"
                                   Foreground="{StaticResource Color_title_activity}"
                                   FontSize="{StaticResource FontSize_title}"
                                           Text="全部温度设定" />
                            <TextBox Style="{StaticResource SegInputStyle}" 
                                 Foreground="{StaticResource Color_text_activity}" 
                                 Background="{StaticResource Color_background2}"
                                   Text="{Binding AllTempSet,StringFormat={}{0:0.#}}" />
                        </StackPanel>
                        <Viewbox Width="150">
                            <flyctrl:ToggleButtonOnOff Style="{StaticResource ToggleButtonOnOffStyle}" 
                                                   HorizontalAlignment="Left" Margin="{StaticResource ControlMargin}" Width="170" 
                            OnLabel="全部运行" OnBrush="{StaticResource Color_on}"
                            OffLabel="全部停止" OffBrush="{StaticResource Color_off}"
                            IsChecked="{Binding IsAllTempSame}"/>
                        </Viewbox>
                    </StackPanel>
                </Grid>
            </Border>

        </Grid>
    </DataTemplate>

    <!--主界面 温度控制器模板 -->
    <DataTemplate x:Key="TcTemplate">
        <Grid >
            <Border Background="{StaticResource DashBoardBrush}" BorderBrush="{StaticResource DashBoardBorderBrush}" BorderThickness="3" CornerRadius="3">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>

                    <StackPanel>
                        <Grid Margin="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="PV" Foreground="{StaticResource PrintBrush}" Margin="2"/>
                            <TextBlock Grid.Column="1" Style="{StaticResource SegTextStyle}" 
                                   Text="{Binding TempPV,StringFormat={}{0:0.#}}" />
                        </Grid>
                        <Rectangle Height="2" Fill="{StaticResource PrintBrush}"/>
                        <Grid Margin="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="SV" Foreground="{StaticResource PrintBrush}" Margin="2"/>
                            <TextBlock Grid.Column="1" Style="{StaticResource SegTextStyle}" Foreground="{StaticResource SegOrangeBrush}"
                                   Text="{Binding TempSV,StringFormat={}{0:0.#}}" />
                        </Grid>
                        <Rectangle Height="2" Fill="{StaticResource PrintBrush}"/>
                        <UniformGrid Margin="2,2,2,5" Columns="4">
                            <ToggleButton IsChecked="{Binding IsHeatingSet,Mode=OneWay}" Content="Run" IsEnabled="False" Style="{StaticResource LedStyle}"/>
                            <ToggleButton IsChecked="{Binding IsHeating,Mode=OneWay}" Content="OT1" IsEnabled="False" Style="{StaticResource LedStyle}"/>
                            <ToggleButton IsChecked="{Binding IsSelfAdjusting,Mode=OneWay}" Content="AT" IsEnabled="False" Style="{StaticResource LedStyle}"/>
                            <ToggleButton IsChecked="{Binding IsCooling,Mode=OneWay}" Content="OT2" IsEnabled="False" Style="{StaticResource LedStyle}"/>
                        </UniformGrid>
                    </StackPanel>
                    <TextBlock Background="{StaticResource BrandBrush}" Grid.Row="1" Height="8" Text="8888888" FontWeight="Bold" Padding="1" FontSize="5" Foreground="{StaticResource PrintBrush}"/>

                </Grid>
            </Border>
            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top"
                           Background="{StaticResource Color_badgeBg}" Foreground="{StaticResource Color_badgeText}" 
                           Padding="6,2"
                           FontSize="30"
                           Text="{Binding Number}" Margin="0,-5,-5,0"/>
        </Grid>
    </DataTemplate>

    <!--主界面 熔温测量器模板 -->
    <DataTemplate x:Key="TmTemplate">
        <Grid >
            <Border Background="{StaticResource DashBoardBrush}" BorderBrush="{StaticResource DashBoardBorderBrush}" BorderThickness="3" CornerRadius="3">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>

                    <StackPanel>
                        <Grid Height="30"/>
                        <Grid Margin="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="PV" Foreground="{StaticResource PrintBrush}" Margin="2"/>
                            <TextBlock Grid.Column="1" Style="{StaticResource SegTextStyle}" 
                                   Text="{Binding MeltingTemp,StringFormat={}{0:0.#}}" />
                        </Grid>
                    </StackPanel>
                    <TextBlock Background="{StaticResource BrandBrush}" Grid.Row="1" Height="8" Text="8888888" FontWeight="Bold" Padding="1" FontSize="5" Foreground="{StaticResource PrintBrush}"/>

                </Grid>
            </Border>
            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top"
                           Background="{StaticResource Color_badgeBg}" Foreground="{StaticResource Color_badgeText}" 
                           Padding="6,2"
                           FontSize="30"
                           Text="熔温" Margin="0,-5,-5,0"/>
        </Grid>
    </DataTemplate>
</ResourceDictionary>