MessagePrompt.xaml.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Timers;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace ivf_tl_Operate.Windows
  16. {
  17. /// <summary>
  18. /// MessagePrompt.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class MessagePrompt : Window
  21. {
  22. private Window parent = null;
  23. public System.Timers.Timer timer;
  24. public MessagePrompt()
  25. {
  26. InitializeComponent();
  27. this.Topmost = true;
  28. timer = new System.Timers.Timer(1500);
  29. timer.Enabled = false;
  30. timer.AutoReset = false;
  31. timer.Elapsed -= timer_Elapsed;
  32. timer.Elapsed += timer_Elapsed;
  33. this.Closed += (a, b) =>
  34. {
  35. if (parent != null)
  36. {
  37. parent.Activate();
  38. }
  39. };
  40. }
  41. private void timer_Elapsed(object sender, ElapsedEventArgs e)
  42. {
  43. timer.Enabled = false;
  44. timer.Close();
  45. timer.Dispose();
  46. Dispatcher.Invoke(() =>
  47. {
  48. this.Close();
  49. });
  50. }
  51. public void ShowCenterOwnerSuccess(Window parent, string mess)
  52. {
  53. timer.Start();
  54. this.Owner = parent;
  55. this.parent = parent;
  56. this._icon_Image.Visibility = Visibility.Visible;
  57. this._conent_Border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#009648"));
  58. this.text.Text = mess;
  59. this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  60. this.Show();
  61. }
  62. /// <summary>
  63. /// 操作失败弹窗 在窗口的中间
  64. /// </summary>
  65. /// <param name="parent"></param>
  66. public void ShowCenterOwnerDefeat(Window parent, string mess)
  67. {
  68. timer.Start();
  69. this.Owner = parent;
  70. this.parent = parent;
  71. this.text.Text = mess;
  72. this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  73. this.Show();
  74. }
  75. }
  76. }