<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"
                          d:DesignWidth="250"
             mc:Ignorable="d" >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/DynAreaErrorStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <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:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/>
          
        </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 Orientation="Horizontal" Margin="2">
                            <TextBlock Style="{StaticResource Styles.Module.Text.ItemHeader}" Text="入"  />
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=15}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=14}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/>
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/>
                                    <TextBlock Text="13" Style="{StaticResource IOTextStyle}"/>
                                </Grid>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=11}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=10}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/>
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
                                    <TextBlock Text="9" Style="{StaticResource IOTextStyle}"/>
                                </Grid>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
                                    <TextBlock Text="5" Style="{StaticResource IOTextStyle}"/>
                                </Grid>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="4,0">
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" Style="{StaticResource IOStyle}"/>
                                <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
                                <Grid>
                                    <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
                                    <TextBlock Text="1" Style="{StaticResource IOTextStyle}"/>
                                </Grid>
                            </StackPanel>
                        </StackPanel>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                                <TextBlock Style="{StaticResource Styles.Module.Text.ItemHeader}" Text="出" />
                                <StackPanel Orientation="Horizontal" Margin="4,0">
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" Style="{StaticResource IOStyle}"/>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" Style="{StaticResource IOStyle}"/>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
                                    <Grid>
                                        <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
                                        <TextBlock Text="5" Style="{StaticResource IOTextStyle}"/>
                                    </Grid>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="4,0">
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" Style="{StaticResource IOStyle}"/>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" Style="{StaticResource IOStyle}"/>
                                    <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
                                    <Grid>
                                        <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
                                        <TextBlock Text="1" Style="{StaticResource IOTextStyle}"/>
                                    </Grid>
                                </StackPanel>
                            </StackPanel>
                            <Button Grid.Column="1" Style="{StaticResource Styles.Button.Empty}" Command="{Binding OpenAccessCmd}">
                                <StackPanel Visibility="{Binding IsForever,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}" Background="White">
                                    <TextBlock Style="{StaticResource Styles.Module.Text.ItemHeader}" Text="剩余时间" />
                                    <StackPanel Orientation="Horizontal" Background="Black" >
                                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue}" Text="{Binding Hrs}" Foreground="White" Padding="2,0"/>
                                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" Text="小时" Foreground="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>
