2025-08-23 20:52:23 +08:00
|
|
|
using DMS.WPF.Helper;
|
2025-08-23 16:01:30 +08:00
|
|
|
using DMS.WPF.ViewModels.Dialogs;
|
2025-08-23 20:52:23 +08:00
|
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
|
|
|
|
using System.Windows.Controls;
|
2025-08-23 16:01:30 +08:00
|
|
|
|
|
|
|
|
namespace DMS.WPF.Views.Dialogs;
|
|
|
|
|
|
|
|
|
|
public partial class VariableDialog
|
|
|
|
|
{
|
2025-08-24 12:25:44 +08:00
|
|
|
private const int ContentAreaMaxWidth = 1200;
|
|
|
|
|
private const int ContentAreaMaxHeight = 900;
|
2025-08-24 14:42:31 +08:00
|
|
|
|
2025-08-23 16:01:30 +08:00
|
|
|
public VariableDialog()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2025-08-23 20:52:23 +08:00
|
|
|
this.Opened += OnOpened;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
|
|
|
|
|
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
|
|
|
|
|
backgroundElementBorder.MaxWidth = ContentAreaMaxHeight;
|
2025-08-23 16:01:30 +08:00
|
|
|
}
|
2025-08-24 14:42:31 +08:00
|
|
|
|
|
|
|
|
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
// 获取ViewModel
|
|
|
|
|
if (DataContext is VariableDialogViewModel viewModel)
|
|
|
|
|
{
|
|
|
|
|
// 调用ViewModel的PrimaryButtonAsync方法
|
|
|
|
|
bool isValid = await viewModel.PrimaryButtonAsync();
|
|
|
|
|
|
|
|
|
|
// 如果验证失败,取消对话框关闭
|
|
|
|
|
if (!isValid)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-23 16:01:30 +08:00
|
|
|
}
|