<UserControl x:Class="FLY.Thick.Base.UI.UiModule.DynAreaIO"
             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:FLY.Thick.Base.UI.UiModule" 
             xmlns:conv="clr-namespace:FLY.Thick.Base.UI.Converter"
             d:DesignWidth="250"
             mc:Ignorable="d" >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/DynAreaErrorStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <conv:IO2BitColorConverter x:Key="io2bitcolorconv" />
            <Style TargetType="Rectangle" x:Key="IOStyle">
                <Setter Property="Width"  Value="9" />
                <Setter Property="Height"  Value="20" />
                <Setter Property="Margin"  Value="1" />
            </Style>
            <Style x:Key="IOTextStyle" TargetType="TextBlock">
                <Setter Property="Foreground"  Value="{StaticResource Brushes.ThemeBackground}" />
                <Setter Property="HorizontalAlignment"  Value="Center" />
                <Setter Property="VerticalAlignment"  Value="Center" />
                <Setter Property="FontSize"  Value="9"/>
            </Style>

            <local:DynAreaIOVmUt x:Key="ioVm" />
            <local:DynAreaErrorVm2 x:Key="errorVm" IsError="False" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/>
            <local:IONumberConverter x:Key="ioNumberConv"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Height="100" >
        <Button Style="{StaticResource Styles.Button.Empty}" d:DataContext="{StaticResource ioVm}" Command="{Binding OpenIoTipCmd}">
            <Grid>
                <Border Style="{StaticResource Styles.Module.Border}" >
                    <StackPanel Margin="2">
                        <StackPanel.Resources>
                            <Style TargetType="Rectangle" BasedOn="{StaticResource IOStyle}"/>
                            <Style TargetType="TextBlock" BasedOn="{StaticResource IOTextStyle}"/>
                        </StackPanel.Resources>
                        <StackPanel Orientation="Horizontal" Margin="2">
                            <TextBlock>
                                <TextBlock.Style>
                                    <Style TargetType="TextBlock" BasedOn="{StaticResource Styles.Module.Text.ItemHeader}">
                                        <Setter Property="Text" Value="X"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding IsIOShowNo}" Value="True">
                                                <Setter Property="Text" Value="I"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Style>
                            </TextBlock>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" />
                                    <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" />
                                </Grid>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" />
                                    <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" />
                                </Grid>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" />
                                    <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=8}" />
                                </Grid>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=10}" />
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=11}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}"/>
                                    <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=12}"/>
                                </Grid>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=14}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=15}"/>
                            </StackPanel>
                        </StackPanel>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                                <TextBlock >
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock" BasedOn="{StaticResource Styles.Module.Text.ItemHeader}">
                                            <Setter Property="Text" Value="Y"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding IsIOShowNo}" Value="True">
                                                    <Setter Property="Text" Value="O"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                                <StackPanel Orientation="Horizontal" Margin="4,0">
                                    <Grid>
                                        <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" />
                                        <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" />
                                    </Grid>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" />
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" />
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="4,0">
                                    <Grid>
                                        <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" />
                                        <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" />
                                    </Grid>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" />
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" />
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" />
                                </StackPanel>
                            </StackPanel>
                            <Button Grid.Column="1" Style="{StaticResource Styles.Button.Empty}" Command="{Binding OpenAccessCmd}">
                                <StackPanel Visibility="{Binding IsForever,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}" >
                                    <TextBlock Style="{StaticResource Styles.Module.Text.ItemHeader}" Text="{StaticResource str.DynArea.RemainingTime}" />
                                    <StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.Text.Black}" >
                                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue}" Text="{Binding Hrs}" Foreground="{StaticResource Brushes.Text.White}" Padding="2,0"/>
                                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" Text="{StaticResource str.DynArea.H}" Foreground="{StaticResource Brushes.Text.White}"/>
                                    </StackPanel>
                                </StackPanel>
                            </Button>
                        </Grid>
                    </StackPanel>
                </Border>
            </Grid>
        </Button>
        <Button x:Name="grid_error" Style="{StaticResource DynAreaErrorStyle}" d:DataContext="{StaticResource errorVm}"
                Command="{Binding OpenWarningCmd}"/>
    </Grid>

</UserControl>
