<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.IO3.IO3View"
             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:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
             xmlns:micro="clr-namespace:Caliburn.Micro"
             xmlns:c="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
             xmlns:lex="http://wpflocalizeextension.codeplex.com"
             mc:Ignorable="d"
             d:DesignHeight="1000" d:DesignWidth="1900"
             lex:LocalizeDictionary.DesignCulture="en"
             lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
             lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
    <UserControl.Resources>
        <c:DisplayNameConverter x:Key="DisplayConverter" />
    </UserControl.Resources>
    <Grid HorizontalAlignment="Left">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TabControl Grid.Column="0" Margin="20,0,0,0" Visibility="{Binding DIVisibility}" >
            <TabItem Header="DI">
                <ListView  ItemsSource="{Binding Path=DIsFilter}" IsEnabled="{Binding IsPermission}"
                              AlternationCount="2"
                              Name="DIListView">

                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="50"
                                            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                            Header="{lex:Loc ID_TXT_Index}"
                                            DisplayMemberBinding="{Binding Path=Index}" />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="200" Header="{lex:Loc ID_TXT_Name}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="0"
                                    Header="{lex:Loc ID_TXT_Address}"
                                    DisplayMemberBinding="{Binding Path=Address}"  />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="50" Header="{lex:Loc ID_TXT_Status}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Width="35">
                                            <controls:SwitchButton HorizontalAlignment="Center"
                                            ON="{Binding Value}"
                                            Style="{StaticResource Lamp-Button}">
                                            </controls:SwitchButton>
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                        </GridView>
                    </ListView.View>
                </ListView>
            </TabItem>
        </TabControl>
        <TabControl Grid.Column="1" Margin="10,0,0,0" Visibility="{Binding DOVisibility}">
            <TabItem Header="DO">
                <ListView ItemsSource="{Binding Path=DOsFilter}" IsEnabled="{Binding IsPermission}"
                              AlternationCount="2"
                              Name="DOListView">

                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="50"
                                            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                            Header="{lex:Loc ID_TXT_Index}"
                                            DisplayMemberBinding="{Binding Path=Index}" />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="200" Header="{lex:Loc ID_TXT_Name}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="0"
                                    Header="{lex:Loc ID_TXT_Address}"
                                    DisplayMemberBinding="{Binding Path=Address}"  />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="50" Header="{lex:Loc ID_TXT_Status}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate >
                                        <Grid Width="35">
                                            <controls:SwitchButton HorizontalAlignment="Center"
                                            ON="{Binding Value}"
                                            Style="{StaticResource Lamp-Button}">
                                            </controls:SwitchButton>
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="75" Header="{lex:Loc ID_TXT_Operation}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate >
                                        <Grid Width="45">
                                            <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>
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </TabItem>
        </TabControl>

        <TabControl Grid.Column="2" Margin="10,0,0,0" Visibility="{Binding AIVisibility}">
            <TabItem Header="AI">
                <ListView ItemsSource="{Binding Path=AIsFilter}" IsEnabled="{Binding IsPermission}"
                              AlternationCount="2"
                              Name="AIListView">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="50"
                                    Header="{lex:Loc ID_TXT_Index}"
                                    DisplayMemberBinding="{Binding Path=Index}" />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="200" Header="{lex:Loc ID_TXT_Name}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="0"
                                    Header="{lex:Loc ID_TXT_Address}"
                                    DisplayMemberBinding="{Binding Path=Address}"  />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="90"
                                    Header="{lex:Loc ID_TXT_Value}"
                                    DisplayMemberBinding="{Binding Path=Value, StringFormat={}{0:F2}}"  />

                        </GridView>
                    </ListView.View>
                </ListView>
            </TabItem>

        </TabControl>
        <TabControl Grid.Column="3" Margin="10,0,0,0" Visibility="{Binding AOVisibility}">
            <TabItem Header="AO">
                <ListView ItemsSource="{Binding Path=AOsFilter}" IsEnabled="{Binding IsPermission}"
                              AlternationCount="2"
                              Name="AOListView">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="50"
                                            lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                            Header="{lex:Loc ID_TXT_Index}"
                                            DisplayMemberBinding="{Binding Path=Index}" />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="200" Header="{lex:Loc ID_TXT_Name}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="0"
                                    Header="{lex:Loc ID_TXT_Address}"
                                    DisplayMemberBinding="{Binding Path=Address}"  />

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="90"
                                    Header="{lex:Loc ID_TXT_Value}"
                                    DisplayMemberBinding="{Binding Path=Value, StringFormat={}{0:F2}}"/>
                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="100" Header="{lex:Loc ID_TXT_NewValue}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate >
                                        <controls:TextBoxEx Text="{Binding Path=NewValue}" Width="90"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                                    Width="75" Header="{lex:Loc ID_TXT_Operation}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate >
                                        <Button Content="{lex:Loc ID_BTN_Set_Content}" FontSize="12" Height="22" Width="45">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <micro:ActionMessage MethodName="SetAO">
                                                        <micro:Parameter Value="{Binding }" />
                                                    </micro:ActionMessage>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </Button>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </TabItem>
        </TabControl>

        <Label
                Grid.Row="1"
                Margin="15,0,10,0"
                VerticalAlignment="Center"
                Content="{lex:Loc ID_TXT_Filter}"
                FontSize="16" />
        <controls:TextBoxEx
                Grid.Row="1"
                Height="26"
                Margin="65,0,50,0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Center"
                AllowBackgroundChange="False"
                Text="{Binding Path=CurrentCriteria, UpdateSourceTrigger=PropertyChanged}" />
        <Button
                Grid.Row="1"
                Width="30"
                Height="30"
                Margin="0,0,5,0"
                Padding="0"
                HorizontalAlignment="Right"
                VerticalAlignment="Center">
            <Button.Content>
                <Path
                        Width="15"
                        Height="15"
                        Margin="0,3"
                        Data="M5.5,0 L8.5,0 8.5,5.5 14,5.5 14,8.5 8.5,8.5 8.5,14 5.5,14 5.5,8.5 0,8.5 0,5.5 5.5,5.5 z"
                        Fill="Black"
                        RenderTransformOrigin="0.5,0.5"
                        Stretch="Fill"
                        StrokeThickness="3">
                </Path>
            </Button.Content>
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <micro:ActionMessage MethodName="ClearFilter" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>
