<UserControl x:Class="DMS.WPF.Views.EmailManagementView"
             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:vm="clr-namespace:DMS.WPF.ViewModels"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=vm:EmailManagementViewModel}"
             d:DesignHeight="600" d:DesignWidth="800">
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- 工具栏 -->
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,10">
            <Button Content="刷新" Command="{Binding LoadDataCommand}" Margin="0,0,10,0"/>
            <Button Content="添加账户" Command="{Binding AddEmailAccountCommand}" Margin="0,0,10,0"/>
            <Button Content="编辑账户" Command="{Binding EditEmailAccountCommand}" Margin="0,0,10,0"/>
            <Button Content="删除账户" Command="{Binding DeleteEmailAccountCommand}" Margin="0,0,10,0"/>
            <Button Content="测试连接" Command="{Binding TestEmailAccountCommand}" Margin="0,0,10,0"/>
            <Button Content="添加模板" Command="{Binding AddEmailTemplateCommand}" Margin="0,0,10,0"/>
            <Button Content="编辑模板" Command="{Binding EditEmailTemplateCommand}" Margin="0,0,10,0"/>
            <Button Content="删除模板" Command="{Binding DeleteEmailTemplateCommand}"/>
        </StackPanel>

        <!-- 主内容区域 -->
        <TabControl Grid.Row="1">
            <!-- 邮件账户标签页 -->
            <TabItem Header="邮件账户">
                <DataGrid ItemsSource="{Binding EmailAccounts}" 
                          SelectedItem="{Binding SelectedEmailAccount}"
                          AutoGenerateColumns="False"
                          IsReadOnly="True"
                          Margin="0,10,0,0">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50"/>
                        <DataGridTextColumn Header="名称" Binding="{Binding Name}" Width="150"/>
                        <DataGridTextColumn Header="邮箱地址" Binding="{Binding EmailAddress}" Width="200"/>
                        <DataGridTextColumn Header="SMTP服务器" Binding="{Binding SmtpServer}" Width="150"/>
                        <DataGridTextColumn Header="用户名" Binding="{Binding Username}" Width="150"/>
                        <DataGridTextColumn Header="默认账户" Binding="{Binding IsDefault}" Width="80"/>
                        <DataGridTextColumn Header="启用" Binding="{Binding IsActive}" Width="60"/>
                    </DataGrid.Columns>
                </DataGrid>
            </TabItem>

            <!-- 邮件模板标签页 -->
            <TabItem Header="邮件模板">
                <DataGrid ItemsSource="{Binding EmailTemplates}" 
                          SelectedItem="{Binding SelectedEmailTemplate}"
                          AutoGenerateColumns="False"
                          IsReadOnly="True"
                          Margin="0,10,0,0">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50"/>
                        <DataGridTextColumn Header="名称" Binding="{Binding Name}" Width="150"/>
                        <DataGridTextColumn Header="代码" Binding="{Binding Code}" Width="100"/>
                        <DataGridTextColumn Header="主题" Binding="{Binding Subject}" Width="200"/>
                        <DataGridTextColumn Header="HTML格式" Binding="{Binding IsHtml}" Width="80"/>
                        <DataGridTextColumn Header="启用" Binding="{Binding IsActive}" Width="60"/>
                    </DataGrid.Columns>
                </DataGrid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>