| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using ivf_tl_Manage.Converts;
- 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_Manage.Win
- {
- /// <summary>
- /// SuccessToastWindow.xaml 的交互逻辑
- /// </summary>
- public partial class ToastWindow : Window
- {
- private Window parent = null;
- public System.Timers.Timer timer;
- public ToastWindow(Window w, double viewWidth, double top, bool b)
- {
- InitializeComponent();
- if (!b)
- {
- SetImage();
- this.image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon2.png", UriKind.Absolute));
- this.textString.Text = KeyToStringConvert.GetLanguageStringByKey("0286");
- }
- timer = new System.Timers.Timer(1500);
- timer.Enabled = false;
- timer.AutoReset = false;
- timer.Elapsed += timer_Elapsed;
- this.Owner = w;
- this.parent = w;
- //this.Top = top;
- //this.Left = (viewWidth / 2) - 75;
- Loaded += (a, b) =>
- {
- this.Top = top;
- this.Left = (viewWidth / 2) - (this.ActualWidth / 2);
- };
- this.Closed += (a, b) =>
- {
- if (parent != null)
- {
- parent.Activate();
- }
- };
- timer.Start();
- }
- public ToastWindow(Window w, double viewWidth, double top, bool b, string string1)
- {
- InitializeComponent();
- if (!b)
- {
- SetImage();
- this.image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon2.png", UriKind.Absolute));
- this.textString.Text = string1;
- }
- timer = new System.Timers.Timer(1500);
- timer.Enabled = false;
- timer.AutoReset = false;
- timer.Elapsed += timer_Elapsed;
- this.Owner = w;
- this.parent = w;
- Loaded += (a, b) =>
- {
- this.Top = top;
- this.Left = (viewWidth / 2) - (this.ActualWidth / 2);
- };
- this.Closed += (a, b) =>
- {
- if (parent != null)
- {
- parent.Activate();
- }
- };
- timer.Start();
- }
- public ToastWindow(Window w, bool b)
- {
- InitializeComponent();
- if (!b) SetImage();
- timer = new System.Timers.Timer(1500);
- timer.Enabled = false;
- timer.AutoReset = false;
- timer.Elapsed += timer_Elapsed;
- this.Owner = w;
- this.parent = w;
- this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
- this.Closed += (a, b) =>
- {
- if (parent != null)
- {
- parent.Activate();
- }
- };
- timer.Start();
- }
- private void timer_Elapsed(object? sender, ElapsedEventArgs e)
- {
- timer.Stop();
- timer.Enabled = false;
- timer.Close();
- timer.Dispose();
- Dispatcher.Invoke(() =>
- {
- this.Close();
- });
- }
- private void SuccessShow(Window parent, double viewWidth)
- {
- timer.Start();
- this.Owner = parent;
- this.parent = parent;
- this.Top = 0;
- this.Left = (viewWidth / 2) - 75;
- this.Show();
- }
- private void DefeatShow(Window parent, double viewWidth)
- {
- timer.Start();
- this.Owner = parent;
- this.parent = parent;
- SetImage();
- this.Top = 0;
- this.Left = (viewWidth / 2) - 75;
- this.Show();
- }
- private void SetImage()
- {
- //this.image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon1.png", UriKind.Absolute));
- //this.image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon.png", UriKind.Absolute));
- //this.image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon3.png", UriKind.Absolute));
- //this.image.Width = 255;
- //this.image.Height = 84;
- //this.image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon.png", UriKind.Absolute));
- this.rootGrid.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DefeatToastIcon1.png", UriKind.Absolute)));
- }
- }
- }
|