using System.Windows;
namespace BPA.UIControl
{
///
/// MessageWindow.xaml 的交互逻辑
///
public partial class MessageWindow : Window
{
///
/// 单例消息窗体
///
private static MessageWindow messageWindow = null;
private MessageWindow()
{
InitializeComponent();
Application.Current.MainWindow.Closed += (sender, e) =>
{
Close();
};
}
///
/// 获取实例
///
/// MessageWindow 实例
public static MessageWindow GetInstance()
{
if (messageWindow is null || !messageWindow.IsLoaded)
{
messageWindow = new MessageWindow();
}
return messageWindow;
}
///
/// 添加消息卡片
///
/// 消息卡片
internal void AddMessageCard(MessageCard messageCard)
{
messageStackPanel.Children.Add(messageCard);
}
///
/// 移除消息卡片
///
/// 消息卡片
internal void RemoveMessageCard(MessageCard messageCard)
{
messageStackPanel.Children.Remove(messageCard);
if (messageStackPanel.Children.Count == 0)
{
Close();
}
}
}
}