初步完成邮件功能
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user