using Panuon.WPF.UI;
|
using System;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using System.Windows;
|
|
namespace HMI.UI
|
{
|
/// <summary>
|
/// MaskWindow.xaml 的交互逻辑
|
/// </summary>
|
public partial class MaskWindow : WindowX
|
{
|
|
private Action<MaskWindow> action;
|
private int delay;
|
public MaskWindow(Window window, Action<MaskWindow> action)
|
{
|
Owner = window;
|
DataContext = this;
|
this.action = action;
|
InitializeComponent();
|
ContentRendered += MaskWindow_ContentRendered; ;
|
}
|
|
private string status;
|
|
public string Status
|
{
|
get { return status; }
|
set { Set(ref status, value); }
|
}
|
|
|
public void Info(string message, int delay = 100)
|
{
|
Status = "Info";
|
label.Content = message;
|
this.delay = delay;
|
this.ShowDialog();
|
}
|
|
private void MaskWindow_ContentRendered(object sender, EventArgs e)
|
{
|
Task.Run(() =>
|
{
|
// 暂停线程令UI完全展示
|
if (delay > 0) Thread.Sleep(delay);
|
action(this);
|
});
|
}
|
|
private void MaskWindow_Loaded(object sender, RoutedEventArgs e)
|
{
|
|
}
|
}
|
}
|