初步完成邮件功能
This commit is contained in:
100
DMS.WPF/Views/Dialogs/EmailAccountDialog.xaml
Normal file
100
DMS.WPF/Views/Dialogs/EmailAccountDialog.xaml
Normal file
@@ -0,0 +1,100 @@
|
||||
<ui:ContentDialog
|
||||
x:Class="DMS.WPF.Views.Dialogs.EmailAccountDialog"
|
||||
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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:vm="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
||||
Title="{Binding DialogTitle}"
|
||||
d:DataContext="{d:DesignInstance Type=vm:EmailAccountDialogViewModel}"
|
||||
CloseButtonCommand="{Binding CancelCommand}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonCommand="{Binding SaveCommand}"
|
||||
PrimaryButtonText="保存"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ui:ContentDialog.Resources>
|
||||
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="Margin" Value="0,0,10,0" />
|
||||
</Style>
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<ScrollViewer Margin="16">
|
||||
<StackPanel>
|
||||
<!-- 账户名称 -->
|
||||
<hc:TextBox hc:InfoElement.Title="账户名称:"
|
||||
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 邮箱地址 -->
|
||||
<hc:TextBox hc:InfoElement.Title="邮箱地址:"
|
||||
Text="{Binding EmailAddress, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- SMTP服务器 -->
|
||||
<hc:TextBox hc:InfoElement.Title="SMTP服务器:"
|
||||
Text="{Binding SmtpServer, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- SMTP端口 -->
|
||||
<Grid Margin="0,0,0,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Style="{StaticResource LabelStyle}" Text="SMTP端口:" />
|
||||
<hc:TextBox Grid.Column="1" Text="{Binding SmtpPort, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid>
|
||||
|
||||
<!-- 启用SSL -->
|
||||
<CheckBox Content="启用SSL"
|
||||
IsChecked="{Binding EnableSsl}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 用户名 -->
|
||||
<hc:TextBox hc:InfoElement.Title="用户名:"
|
||||
Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 密码 -->
|
||||
<Grid Margin="0,0,0,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Style="{StaticResource LabelStyle}" Text="密码:" />
|
||||
<PasswordBox x:Name="PasswordBox" Grid.Column="1" />
|
||||
</Grid>
|
||||
|
||||
<!-- IMAP服务器 -->
|
||||
<hc:TextBox hc:InfoElement.Title="IMAP服务器 (可选):"
|
||||
Text="{Binding ImapServer, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- IMAP端口 -->
|
||||
<Grid Margin="0,0,0,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Style="{StaticResource LabelStyle}" Text="IMAP端口:" />
|
||||
<hc:TextBox Grid.Column="1" Text="{Binding ImapPort, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid>
|
||||
|
||||
<!-- 默认账户 -->
|
||||
<CheckBox Content="默认账户"
|
||||
IsChecked="{Binding IsDefault}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 启用 -->
|
||||
<CheckBox Content="启用"
|
||||
IsChecked="{Binding IsActive}"
|
||||
Margin="0,0,0,15"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</ui:ContentDialog>
|
||||
48
DMS.WPF/Views/Dialogs/EmailAccountDialog.xaml.cs
Normal file
48
DMS.WPF/Views/Dialogs/EmailAccountDialog.xaml.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using DMS.WPF.ViewModels.Dialogs;
|
||||
using DMS.WPF.Helper;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DMS.WPF.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// EmailAccountDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class EmailAccountDialog : ContentDialog
|
||||
{
|
||||
private const int ContentAreaMaxWidth = 1000;
|
||||
private const int ContentAreaMaxHeight = 800;
|
||||
|
||||
public EmailAccountDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Opened += OnOpened;
|
||||
DataContextChanged += EmailAccountDialog_DataContextChanged;
|
||||
}
|
||||
|
||||
private void OnOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
||||
{
|
||||
// 修改对话框内容区域的最大宽度和高度
|
||||
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
|
||||
if (backgroundElementBorder != null)
|
||||
{
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
|
||||
backgroundElementBorder.MaxHeight = ContentAreaMaxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
private void EmailAccountDialog_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is EmailAccountDialogViewModel viewModel)
|
||||
{
|
||||
// 处理密码框
|
||||
PasswordBox.Password = viewModel.Password;
|
||||
PasswordBox.PasswordChanged += (s, args) =>
|
||||
{
|
||||
viewModel.Password = PasswordBox.Password;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
DMS.WPF/Views/Dialogs/EmailTemplateDialog.xaml
Normal file
63
DMS.WPF/Views/Dialogs/EmailTemplateDialog.xaml
Normal file
@@ -0,0 +1,63 @@
|
||||
<ui:ContentDialog
|
||||
x:Class="DMS.WPF.Views.Dialogs.EmailTemplateDialog"
|
||||
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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:vm="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
||||
Title="{Binding DialogTitle}"
|
||||
d:DataContext="{d:DesignInstance Type=vm:EmailTemplateDialogViewModel}"
|
||||
CloseButtonCommand="{Binding CancelCommand}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonCommand="{Binding SaveCommand}"
|
||||
PrimaryButtonText="保存"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ui:ContentDialog.Resources>
|
||||
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="Margin" Value="0,0,10,0" />
|
||||
</Style>
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<ScrollViewer Margin="16">
|
||||
<StackPanel>
|
||||
<!-- 模板名称 -->
|
||||
<hc:TextBox hc:InfoElement.Title="模板名称:"
|
||||
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 模板代码 -->
|
||||
<hc:TextBox hc:InfoElement.Title="模板代码:"
|
||||
Text="{Binding Code, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 邮件主题 -->
|
||||
<hc:TextBox hc:InfoElement.Title="邮件主题:"
|
||||
Text="{Binding Subject, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 邮件内容 -->
|
||||
<TextBlock Text="邮件内容:" Margin="0,0,0,5" />
|
||||
<hc:TextBox Text="{Binding Body, UpdateSourceTrigger=PropertyChanged}"
|
||||
AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
Height="150"
|
||||
Margin="0,0,0,15" />
|
||||
|
||||
<!-- HTML格式 -->
|
||||
<CheckBox Content="HTML格式"
|
||||
IsChecked="{Binding IsHtml}"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<!-- 启用 -->
|
||||
<CheckBox Content="启用"
|
||||
IsChecked="{Binding IsActive}"
|
||||
Margin="0,0,0,15"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</ui:ContentDialog>
|
||||
33
DMS.WPF/Views/Dialogs/EmailTemplateDialog.xaml.cs
Normal file
33
DMS.WPF/Views/Dialogs/EmailTemplateDialog.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using DMS.WPF.Helper;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DMS.WPF.Views.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// EmailTemplateDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class EmailTemplateDialog : ContentDialog
|
||||
{
|
||||
private const int ContentAreaMaxWidth = 1000;
|
||||
private const int ContentAreaMaxHeight = 800;
|
||||
|
||||
public EmailTemplateDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Opened += OnOpened;
|
||||
}
|
||||
|
||||
private void OnOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
||||
{
|
||||
// 修改对话框内容区域的最大宽度和高度
|
||||
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
|
||||
if (backgroundElementBorder != null)
|
||||
{
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
|
||||
backgroundElementBorder.MaxHeight = ContentAreaMaxHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
DMS.WPF/Views/EmailManagementView.xaml
Normal file
68
DMS.WPF/Views/EmailManagementView.xaml
Normal file
@@ -0,0 +1,68 @@
|
||||
<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>
|
||||
26
DMS.WPF/Views/EmailManagementView.xaml.cs
Normal file
26
DMS.WPF/Views/EmailManagementView.xaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using DMS.WPF.ViewModels;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DMS.WPF.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// EmailManagementView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class EmailManagementView : UserControl
|
||||
{
|
||||
public EmailManagementView()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContextChanged += EmailManagementView_DataContextChanged;
|
||||
}
|
||||
|
||||
private void EmailManagementView_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is EmailManagementViewModel viewModel)
|
||||
{
|
||||
// 加载数据
|
||||
viewModel.LoadDataCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,10 @@
|
||||
<DataTemplate DataType="{x:Type vm:LogHistoryViewModel}">
|
||||
<local:LogHistoryView />
|
||||
</DataTemplate>
|
||||
<!-- 邮件管理页 -->
|
||||
<DataTemplate DataType="{x:Type vm:EmailManagementViewModel}">
|
||||
<local:EmailManagementView />
|
||||
</DataTemplate>
|
||||
<!-- 设备详情页 -->
|
||||
<DataTemplate DataType="{x:Type vm:DeviceDetailViewModel}">
|
||||
<local:DeviceDetailView />
|
||||
|
||||
Reference in New Issue
Block a user