<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.Configs.Accounts.AccountView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    lex:LocalizeDictionary.DesignCulture=""
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_config">
    <UserControl.Resources>
        <Style
            x:Key="ViewEnabledBtn"
            BasedOn="{StaticResource ResourceKey={x:Type Button}}"
            TargetType="{x:Type Button}">
            <Setter Property="Button.IsEnabled" Value="False" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Permission}" Value="2" />
                        <Condition Binding="{Binding ControlMode}" Value="VIEW" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Button.IsEnabled" Value="True" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
        <Style
            x:Key="EditEnabledBtn"
            BasedOn="{StaticResource ResourceKey={x:Type Button}}"
            TargetType="{x:Type Button}">
            <Setter Property="Button.IsEnabled" Value="False" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Permission}" Value="2" />
                        <Condition Binding="{Binding ControlMode}" Value="EDIT" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Button.IsEnabled" Value="True" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid
        x:Name="MainTable">
        <Grid x:Name="MainField">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250" />
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>
            <GridSplitter
                Grid.Column="1"
                Width="5"
                HorizontalAlignment="Left"
                BorderThickness="0,8">
                <GridSplitter.Background>
                    <SolidColorBrush />
                </GridSplitter.Background>
            </GridSplitter>
            <ListView
                Name="AccountList"
                Margin="0,20,0,0"
                AlternationCount="2"
                ItemsSource="{Binding AccountList}"
                SelectedItem="{Binding TreeSelectedAccount}">
                <ListView.Style>
                    <Style BasedOn="{StaticResource ResourceKey={x:Type ListView}}" TargetType="{x:Type ListView}">
                        <Setter Property="ListView.IsEnabled" Value="False" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ControlMode}" Value="VIEW">
                                <Setter Property="ListView.IsEnabled" Value="True" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ListView.Style>
                <ListView.View>
                    <GridView>
                        <GridViewColumn
                            Width="200"
                            lex:ResxLocalizationProvider.DefaultDictionary="lang_config"
                            DisplayMemberBinding="{Binding DisplayAccountName}"
                            Header="{lex:Loc ID_TXT_Account}" />
                    </GridView>
                </ListView.View>
            </ListView>
            <Grid Grid.Column="1" Margin="10,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock
                    Margin="5,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    FontFamily="Arial"
                    FontSize="14"
                    FontWeight="Bold"
                    Foreground="{DynamicResource FG_Black}"
                    Text="{lex:Loc ID_TXT_Account_Property}"
                    TextWrapping="Wrap" />
                <Grid
                    Grid.Row="1"
                    Margin="0,0,10,0"
                    IsEnabled="{Binding IsPermission}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition Height="24" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid x:Name="GdAccountName" Grid.Row="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_Login_Name}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,1,1,1">
                            <controls:TextBoxEx
                                x:Name="TbAccountName"
                                Width="200"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                HorizontalContentAlignment="Left"
                                IsEnabled="{Binding Mode=TwoWay, Path=TreeSelectedAccount.IsEnableChangeAccountName}"
                                MaxLength="50"
                                Text="{Binding TreeSelectedAccount.DisplayAccountName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedAccount.AccountTextSaved}"
                                Validation.ErrorTemplate="{StaticResource ValidationTemplate}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <micro:ActionMessage MethodName="OnAccountChanged" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </controls:TextBoxEx>
                        </Border>
                    </Grid>
                    <Grid x:Name="GdNewPassword" Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_New_Password}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <PasswordBox
                                x:Name="pwNewPassword"
                                Width="200"
                                HorizontalAlignment="Left"
                                micro:Message.Attach="[Event PasswordChanged]=[Action OnPasswordChanged($source, $eventArgs)]"
                                MaxLength="50"
                                Tag="NewPassword" />
                        </Border>
                    </Grid>
                    <Grid x:Name="GdConfirmPassword" Grid.Row="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_Confirm_Password}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <PasswordBox
                                Name="pwConfirmPassword"
                                Width="200"
                                HorizontalAlignment="Left"
                                micro:Message.Attach="[Event PasswordChanged]=[Action OnPasswordChanged($source, $eventArgs)]"
                                MaxLength="50"
                                Tag="ConfirmPassword" />
                        </Border>
                    </Grid>
                    <Grid x:Name="GdFirstName" Grid.Row="3">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_First_Name}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <controls:TextBoxEx
                                x:Name="TbFirstName"
                                Width="200"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                HorizontalContentAlignment="Stretch"
                                MaxLength="50"
                                Text="{Binding TreeSelectedAccount.DisplayFirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedAccount.FirstNameTextSaved}"
                                Validation.ErrorTemplate="{StaticResource ValidationTemplate}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <micro:ActionMessage MethodName="OnAccountChanged" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </controls:TextBoxEx>
                        </Border>
                    </Grid>
                    <Grid x:Name="GdLastName" Grid.Row="4">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_Last_Name}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <controls:TextBoxEx
                                x:Name="TbLastName"
                                Width="200"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                HorizontalContentAlignment="Stretch"
                                MaxLength="50"
                                Text="{Binding TreeSelectedAccount.DisplayLastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedAccount.LastNameTextSaved}"
                                Validation.ErrorTemplate="{StaticResource ValidationTemplate}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <micro:ActionMessage MethodName="OnAccountChanged" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </controls:TextBoxEx>
                        </Border>
                    </Grid>
                    <Grid x:Name="GdEmail" Grid.Row="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_Email}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <controls:TextBoxEx
                                x:Name="TbEmail"
                                Width="200"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                HorizontalContentAlignment="Stretch"
                                MaxLength="50"
                                Text="{Binding TreeSelectedAccount.DisplayEmail, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedAccount.EmailTextSaved}"
                                Validation.ErrorTemplate="{StaticResource ValidationTemplate}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <micro:ActionMessage MethodName="OnAccountChanged" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </controls:TextBoxEx>
                        </Border>
                    </Grid>
                    <Grid x:Name="GdDescription" Grid.Row="6">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Border
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Title}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="1,0,1,1">
                            <TextBlock
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Foreground="{DynamicResource FG_Black}"
                                Text="{lex:Loc ID_TXT_Description}"
                                TextWrapping="Wrap" />
                        </Border>
                        <Border
                            Grid.Column="1"
                            Padding="5,1"
                            Background="{DynamicResource Table_BG_Content}"
                            BorderBrush="{DynamicResource Table_BD}"
                            BorderThickness="0,0,1,1">
                            <controls:TextBoxEx
                                x:Name="TbDescription"
                                MinWidth="200"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                HorizontalContentAlignment="Stretch"
                                MaxLength="50"
                                Text="{Binding TreeSelectedAccount.DisplayDescription, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
                                TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedAccount.DescriptionTextSaved}"
                                Validation.ErrorTemplate="{StaticResource ValidationTemplate}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="TextChanged">
                                        <micro:ActionMessage MethodName="OnAccountChanged" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </controls:TextBoxEx>
                        </Border>
                    </Grid>
                </Grid>
                <TabControl Grid.Row="2" Margin="0,10,10,0">
                    <TabItem>
                        <TabItem.Header>
                            <TextBlock FontWeight="Bold" Text="{lex:Loc ID_TXT_Role_Status}" />
                        </TabItem.Header>
                        <ListView
                            Name="RolesStatusList"
                            VerticalAlignment="Top"
                            AlternationCount="2"
                            ItemsSource="{Binding Path=TreeSelectedAccount.RoleColleciton}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn
                                        Width="250"
                                        lex:ResxLocalizationProvider.DefaultDictionary="lang_config"
                                        DisplayMemberBinding="{Binding RoleName}"
                                        Header="{lex:Loc ID_TXT_Role}" />
                                    <GridViewColumn
                                        Width="300"
                                        lex:ResxLocalizationProvider.DefaultDictionary="lang_config"
                                        Header="{lex:Loc ID_TXT_Role_Status}">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox IsChecked="{Binding DisplayRoleStatus}">
                                                    <i:Interaction.Triggers>
                                                        <i:EventTrigger EventName="Click">
                                                            <micro:ActionMessage MethodName="OnAccountChanged" />
                                                        </i:EventTrigger>
                                                    </i:Interaction.Triggers>
                                                </CheckBox>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </TabItem>
                </TabControl>
            </Grid>
            <StackPanel
                Grid.Row="1"
                Grid.ColumnSpan="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                Orientation="Horizontal">
                <!--<Button
                    Width="150"
                    Height="25"
                    Content="Change Password"
                    Margin="0 0 20 0"
                    Style="{StaticResource ViewEnabledBtn}"
                    micro:Message.Attach="ChangePassword()"/>-->

                <Button
                    x:Name="ID_BTN_Create_Content"
                    Width="80"
                    Height="25"
                    Command="{Binding BtnAddAccountCommand}"
                    Content="{lex:Loc}"
                    Style="{StaticResource ViewEnabledBtn}"
                    ToolTip="{lex:Loc}" />
                <Button
                    x:Name="ID_BTN_Delete_Content"
                    Width="80"
                    Height="25"
                    Margin="10,0,0,0"
                    Command="{Binding BtnDeleteAccountCommand}"
                    Content="{lex:Loc}"
                    Style="{StaticResource ViewEnabledBtn}"
                    ToolTip="{lex:Loc}" />
                <Button
                    x:Name="ID_BTN_Clone_Content"
                    Width="80"
                    Height="25"
                    Margin="10,0,0,0"
                    Command="{Binding BtnCloneAccountCommand}"
                    Content="{lex:Loc}"
                    Style="{StaticResource ViewEnabledBtn}"
                    ToolTip="{lex:Loc}" />
                <Button
                    x:Name="ID_BTN_Save_Content"
                    Width="80"
                    Height="25"
                    Margin="10,0,0,0"
                    Command="{Binding BtnSaveAccountCommand}"
                    Content="{lex:Loc}"
                    Style="{StaticResource EditEnabledBtn}"
                    ToolTip="{lex:Loc}" />
                <Button
                    x:Name="ID_BTN_Cancel_Content"
                    Width="80"
                    Height="25"
                    Margin="10,0,0,0"
                    Command="{Binding BtnCancelAccountCommand}"
                    Content="{lex:Loc}"
                    Style="{StaticResource EditEnabledBtn}"
                    ToolTip="{lex:Loc}" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
