using System.Windows;
using System.Windows.Input;
namespace BPA.UIControl
{
///
/// MessageBoxWindow.xaml 的交互逻辑
///
public partial class MessageBoxWindow : Window
{
///
/// 消息框结果
///
public MessageBoxResult MessageBoxResult { get; set; }
///
/// Initializes a new instance of the class.
///
public MessageBoxWindow()
{
InitializeComponent();
}
///
/// 添加消息框
///
/// 消息框卡片
internal void AddMessageBoxCard(MessageBoxCard card)
{
card.ReturnResult += Card_ReturnResult;
card.Closed += Card_Close;
messageBoxPanel.Child = card;
}
private void Card_ReturnResult(object sender, MessageBoxResultRoutedEventArgs e)
{
MessageBoxResult = e.Result;
}
private void Card_Close(object sender, RoutedEventArgs e)
{
messageBoxPanel.Child = null;
DialogResult = true;
}
private void Window_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
_ = Focus();
}
private void Window_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
if (e.NewFocus != null)
{
e.Handled = true;
}
}
}
}