using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace SparkClient.Views.Dialog
{
///
/// MsgDialog.xaml 的交互逻辑
///
public partial class MsgDialog : Window, INotifyPropertyChanged
{
private string _errorMessage;
public string ErrorMessage
{
get { return _errorMessage; }
set
{
if (_errorMessage != value)
{
_errorMessage = value;
OnPropertyChanged(nameof(ErrorMessage));
}
}
}
public MsgDialog()
{
InitializeComponent();
this.Loaded += (s, e) => ApplyCornerRadiusClip();
this.SizeChanged += (s, e) => ApplyCornerRadiusClip();
this.DataContext = this; // 设置 DataContext 以便绑定
}
///
/// 关闭按钮点击事件
///
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
///
/// 跳过按钮点击事件
///
private void Skip_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
///
/// 窗口圆角裁剪
///
private void ApplyCornerRadiusClip()
{
if (this.ActualWidth > 0 && this.ActualHeight > 0)
{
this.Clip = new RectangleGeometry
{
Rect = new Rect(0, 0, this.ActualWidth, this.ActualHeight),
RadiusX = 20,
RadiusY = 20
};
}
}
///
/// 支持窗口拖动
///
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}