using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace ST_CUBE_MES { /// /// Window1.xaml 的互動邏輯 /// public partial class ResultDialog : Window { public ResultDialog() { InitializeComponent(); KeyDown += ResultDialog_KeyDown; MouseDown += ResultDialog_MouseDown; } public event EventHandler OnAnyInput; public bool IsSuccess { get; private set; } private delegate void GenericDelegate(); private void ResultDialog_KeyDown(object sender, KeyEventArgs e) { OnAnyInput?.Invoke(this, e); } private void ResultDialog_MouseDown(object sender, MouseButtonEventArgs e) { OnAnyInput?.Invoke(this, e); } public void ShowResult(bool isSuccess) { GenericDelegate ShowResultAct = () => { if (isSuccess) { uxBg.Background = Brushes.Lime; uxResultText.Content = "PASS"; } if (!isSuccess) { uxBg.Background = Brushes.Red; uxResultText.Content = "FAIL"; } IsSuccess = isSuccess; this.ShowDialog(); }; this.Dispatcher.BeginInvoke(ShowResultAct); } } }