<UserControl x:Class="HistoryView.Views.Regions.SettingSubs.UserSetting"
             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:HistoryView.Views.Regions.SettingSubs"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True" 
             xmlns:Inputs="clr-namespace:HistoryView.Controls.Input"
             xmlns:pass="clr-namespace:HistoryView.Helper"
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:conterter="clr-namespace:HistoryView.Converters"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:data="clr-namespace:HistoryView.Data"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <conterter:RunningModeToBool x:Key="StateConvert"/>
        <conterter:SizeConvert x:Key="Size"/>
        <conterter:AuthorityToVis x:Key="Authority"/>
        <ObjectDataProvider
       x:Key="UserAuthorityEnum"
       MethodName="GetValues"
       ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="data:User"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="0"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="0"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="32"/>
        </Grid.RowDefinitions>
        <GroupBox Margin="0,0,0,32">
            <GroupBox.Header>
                <TextBlock FontSize="14" FontWeight="Bold" Text="修改密码"/>
            </GroupBox.Header>
            <Grid Margin="16">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">用户：</TextBlock>
                <ComboBox Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Width="140" SelectedItem="{Binding SelectedUser}" DisplayMemberPath="UserName"/>

                <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center">权限：</TextBlock>
                <TextBox Grid.Row="2" Grid.Column="2" BorderThickness="0" Height="24" IsReadOnly="True" Padding="2,0,0,0"
                         VerticalAlignment="Center" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="140" 
                         Text="{Binding SelectedUser.Authority}"/>

                <TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center">新密码：</TextBlock>
                <Inputs:TextboxKeyboard Grid.Row="4" Grid.Column="2" Text="{Binding ChangePassword, Mode=TwoWay}" DirectInput="True">
                    <Inputs:TextboxKeyboard.DisplayContent>
                        <PasswordBox  Height="24" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="140"  BorderBrush="Transparent" BorderThickness="0"  pass:PassWordExtensions.PassWord="{Binding ChangePassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <i:Interaction.Behaviors>
                                <pass:PasswordBehavior/>
                            </i:Interaction.Behaviors>
                        </PasswordBox>
                    </Inputs:TextboxKeyboard.DisplayContent>
                </Inputs:TextboxKeyboard>

                <TextBlock Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Center">确认密码：</TextBlock>
                <Inputs:TextboxKeyboard Grid.Row="6" Grid.Column="2" Text="{Binding ChangeComfirmPassword, Mode=TwoWay}" DirectInput="True">
                    <Inputs:TextboxKeyboard.DisplayContent>
                        <PasswordBox  Height="24" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="140"  BorderBrush="Transparent" BorderThickness="0"  pass:PassWordExtensions.PassWord="{Binding ChangeComfirmPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <i:Interaction.Behaviors>
                                <pass:PasswordBehavior/>
                            </i:Interaction.Behaviors>
                        </PasswordBox>
                    </Inputs:TextboxKeyboard.DisplayContent>
                </Inputs:TextboxKeyboard>
                <Button Grid.Row="8" Grid.ColumnSpan="6" Height="32" Style="{StaticResource FunctionButton}" Command="{Binding OperateCommand}" CommandParameter="Update">确认修改</Button>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="2" Margin="0,0,0,32"  Visibility="{Binding UserInfo.Authority, Converter={StaticResource Authority}, ConverterParameter=Engineer}">
            <GroupBox.Header>
                <TextBlock FontSize="14" FontWeight="Bold" Text="创建用户"/>
            </GroupBox.Header>
            <Grid Margin="16">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="16"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">用户名：</TextBlock>
                <Inputs:NumberKeyboard Grid.Column="2" Text="{Binding UserName, Mode=TwoWay}">
                    <Inputs:NumberKeyboard.DisplayContent>
                        <TextBox  MinWidth="100" Background="#f8f8f8"  BorderThickness="0" Height="24" Padding="2,0,0,0"
                                  VerticalContentAlignment="Center" HorizontalContentAlignment="Left" 
                                  Text="{Binding UserName, Mode=TwoWay}"/>
                    </Inputs:NumberKeyboard.DisplayContent>
                </Inputs:NumberKeyboard>

                <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center">权限：</TextBlock>
                <ComboBox Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center"  ItemsSource="{Binding Source={StaticResource UserAuthorityEnum}}" SelectedItem="{Binding UserAuthoritySetting, Mode=TwoWay}" Width="140"/>

                <TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center">密码：</TextBlock>
                <Inputs:NumberKeyboard Grid.Row="4" Grid.Column="2"  Text="{Binding Password, Mode=TwoWay}">
                    <Inputs:TextboxKeyboard Text="{Binding Password, Mode=TwoWay}" DirectInput="True">
                        <Inputs:TextboxKeyboard.DisplayContent>
                            <PasswordBox  Height="24" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="140"  BorderBrush="Transparent" BorderThickness="0"  pass:PassWordExtensions.PassWord="{Binding UserInfo.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                                <i:Interaction.Behaviors>
                                    <pass:PasswordBehavior/>
                                </i:Interaction.Behaviors>
                            </PasswordBox>
                        </Inputs:TextboxKeyboard.DisplayContent>
                    </Inputs:TextboxKeyboard>
                </Inputs:NumberKeyboard>

                <TextBlock Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Center">确认密码：</TextBlock>
                <Inputs:TextboxKeyboard Grid.Row="6" Grid.Column="2" Text="{Binding ComfirmPassword, Mode=TwoWay}" DirectInput="True">
                    <Inputs:TextboxKeyboard.DisplayContent>
                        <PasswordBox  Height="24" HorizontalAlignment="Center" VerticalContentAlignment="Center" Width="140"  BorderBrush="Transparent" BorderThickness="0" 
                                      pass:PassWordExtensions.PassWord="{Binding ComfirmPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <i:Interaction.Behaviors>
                                <pass:PasswordBehavior/>
                            </i:Interaction.Behaviors>
                        </PasswordBox>
                    </Inputs:TextboxKeyboard.DisplayContent>
                </Inputs:TextboxKeyboard>
                <Button Grid.Row="8" Grid.ColumnSpan="6" Height="32" Style="{StaticResource FunctionButton}" Command="{Binding OperateCommand}" CommandParameter="Create">确认创建</Button>
            </Grid>
        </GroupBox>
    </Grid>
</UserControl>