using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Timers; 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 ivf_tl_Operate.Windows { /// /// MessagePrompt.xaml 的交互逻辑 /// public partial class MessagePrompt : Window { private Window parent = null; public System.Timers.Timer timer; public MessagePrompt() { InitializeComponent(); this.Topmost = true; timer = new System.Timers.Timer(1500); timer.Enabled = false; timer.AutoReset = false; timer.Elapsed -= timer_Elapsed; timer.Elapsed += timer_Elapsed; this.Closed += (a, b) => { if (parent != null) { parent.Activate(); } }; } private void timer_Elapsed(object sender, ElapsedEventArgs e) { timer.Enabled = false; timer.Close(); timer.Dispose(); Dispatcher.Invoke(() => { this.Close(); }); } public void ShowCenterOwnerSuccess(Window parent, string mess) { timer.Start(); this.Owner = parent; this.parent = parent; this._icon_Image.Visibility = Visibility.Visible; this._conent_Border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#009648")); this.text.Text = mess; this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.Show(); } /// /// 操作失败弹窗 在窗口的中间 /// /// public void ShowCenterOwnerDefeat(Window parent, string mess) { timer.Start(); this.Owner = parent; this.parent = parent; this.text.Text = mess; this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.Show(); } } }