<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.IO1.IO1View"
             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:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
             xmlns:micro="clr-namespace:Caliburn.Micro"
             mc:Ignorable="d" >
    <UserControl.Resources>
        <DataTemplate x:Key="DOTemplate">
            <Grid Margin="-1,-1,0,0" Height="23">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50"></ColumnDefinition>
                    <ColumnDefinition Width="200"></ColumnDefinition>
                    <ColumnDefinition Width="50"></ColumnDefinition>
                    <ColumnDefinition Width="45"></ColumnDefinition>
                    <ColumnDefinition Width="45"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Index}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <controls:SwitchButton ON="{Binding Value}" Style="{StaticResource Lamp-Button}" HorizontalAlignment="Center" />
                </Border>
                <Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <controls:SwitchButton ON="{Binding Value}" Style="{StaticResource OperationButton}" HorizontalAlignment="Center">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="SetDO">
                                    <micro:Parameter Value="{Binding }" />
                                </micro:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </controls:SwitchButton>
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="DITemplate">
            <Grid Margin="-1,-1,0,0" Height="23">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50"></ColumnDefinition>
                    <ColumnDefinition Width="200"></ColumnDefinition>
                    <ColumnDefinition Width="50"></ColumnDefinition>
                    <ColumnDefinition Width="45"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Index}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                </Border>
                <Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
                    <controls:SwitchButton ON="{Binding Value}" Style="{StaticResource Lamp-Button}" HorizontalAlignment="Center" />
                </Border>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding DIWidth}"></ColumnDefinition>
            <ColumnDefinition Width="{Binding DOWidth}"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TabControl>
            <TabItem Header="DI">
                <ListBox ItemsSource="{Binding DIs}" 
                         ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" 
                         AlternationCount="2" ItemTemplate="{StaticResource DITemplate}" 
                         ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                         Width="{Binding DIWidth}"
                         BorderThickness="0" Margin="5,0" HorizontalAlignment="Left" IsEnabled="{Binding IsPermission}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>
            </TabItem>
        </TabControl>

        <TabControl Grid.Column="1" Margin="5,0,0,0">
            <TabItem Header="DO">
                <ListBox ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" ItemsSource="{Binding DOs}" AlternationCount="2" ItemTemplate="{StaticResource DOTemplate}" IsEnabled="{Binding IsPermission}"
                         ScrollViewer.VerticalScrollBarVisibility="Disabled"  BorderThickness="0"  Margin="5,0" HorizontalAlignment="Left">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.Style>
                        <Style>
                            <Setter Property="ListBox.Width" Value="850"></Setter>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding TwoColumnMode}" Value="False">
                                    <Setter Property="ListBox.Width" Value="450"></Setter>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ListBox.Style>
                </ListBox>
            </TabItem>
        </TabControl>

    </Grid>
</UserControl>
