<UserControl x:Class="BaseModule.Views.UserManagementView"
             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:BaseModule.Views"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Txgy.EWS.Client.Assets;component/Styles/BaseResources.xaml"/>
                <ResourceDictionary Source="/Txgy.EWS.Client.Assets;component/Styles/ButtonStyles.xaml"/>
                <ResourceDictionary Source="/Txgy.EWS.Client.Assets;component/Styles/TextBoxStyle.xaml"/>

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Margin="20">
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Border BorderBrush="#DDD" BorderThickness="0,0,0,1"/>
        <TextBox Text="" VerticalAlignment="Center" Width="300" HorizontalAlignment="Left" Style="{DynamicResource SearchTextBoxStyle}"/>
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
            <Button Content="刷新" Style="{StaticResource NormalButtonStyle}" Background="#FF0ABEFF" 
                    Width="70" Margin="5,0"
                    Command="{Binding RefreshCommand}"/>
            <Button Content="添加" 
                Style="{StaticResource IconWithContentButtonStyle}" Width="100"
                Tag="&#xe603;" Background="#FFF05005"
                Command="{Binding AddCommand}"/>
        </StackPanel>


        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border Background="#EEE"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="150"/>
                </Grid.ColumnDefinitions>
                <TextBlock Text="序号" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Text="头像" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Text="用户信息" Grid.Column="2" VerticalAlignment="Center" />
                <TextBlock Text="角色" Grid.Column="3" VerticalAlignment="Center" />
                <TextBlock Text="操作" Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <!--编辑、分配权限、重置密码、删除-->
            </Grid>
            <ItemsControl Grid.Row="1" ItemsSource="{Binding Users}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Background="Transparent" Name="root">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="40"/>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="2*"/>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>
                            <Border BorderBrush="#EEE" BorderThickness="0,0,0,1" Height="1" VerticalAlignment="Bottom" Grid.ColumnSpan="10" SnapsToDevicePixels="True"/>
                            <TextBlock Text="{Binding Index}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                            <Border Grid.Column="1" Width="40" Height="40" CornerRadius="20" BorderBrush="White" BorderThickness="2">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="0" Direction="0" Color="Gray" Opacity="0.3"/>
                                </Border.Effect>
                                <Border.Background>
                                    <ImageBrush ImageSource="{Binding UserIcon}"/>
                                </Border.Background>
                            </Border>
                            <StackPanel Grid.Column="2" Margin="0,10">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding RealName}" VerticalAlignment="Center"/>
                                    <TextBlock Text="状态：有效" FontSize="11" Foreground="#888" VerticalAlignment="Center" Margin="10,0"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding UserName}" Foreground="#888"/>
                                    <TextBlock Text="{Binding Age}" Foreground="#888" Margin="10,0"/>
                                </StackPanel>
                                <TextBlock>
                                    <Run Text="["/>
                                    <Hyperlink Command="{Binding PwdCommand}" CommandParameter="{Binding}">重置密码</Hyperlink>
                                    <Run Text="]"/>
                                </TextBlock>
                            </StackPanel>

                            <StackPanel Grid.Column="3" VerticalAlignment="Center">
                                <ItemsControl ItemsSource="{Binding Roles}">
                                    <ItemsControl.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <WrapPanel/>
                                        </ItemsPanelTemplate>
                                    </ItemsControl.ItemsPanel>
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding RoleName}" Margin="3"/>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                                <TextBlock HorizontalAlignment="Left" Margin="0,5,0,0">
                                    <Run Text="["/>
                                    <Hyperlink Command="{Binding RoleCommand}" CommandParameter="{Binding}">角色分配</Hyperlink>
                                    <Run Text="]"/>
                                </TextBlock>
                            </StackPanel>

                            <StackPanel Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">
                                <TextBlock Margin="3,0">
                                    <Hyperlink Command="{Binding EditCommand}" CommandParameter="{Binding}">编辑</Hyperlink>
                                </TextBlock>
                                <TextBlock Margin="3,0">
                                    <Hyperlink Command="{Binding DeleteCommand}" CommandParameter="{Binding}">删除</Hyperlink>
                                </TextBlock>
                            </StackPanel>
                        </Grid>
                        <DataTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="root" Property="Background" Value="#F7F9FA"/>
                            </Trigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

        </Grid>
    </Grid>
</UserControl>
