schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using DataEntity.Share;
using DriverLib.Engine;
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.Navigation;
using System.Windows.Shapes;
using XCommon.Log;
using XCore;
using XHandler.Class;
using XHandler.Controls;
using static HxEnum.OperationTypeEnum;
 
namespace XHandler.View.MethodProperty
{
    /// <summary>
    /// OperateDialog.xaml 的交互逻辑
    /// </summary>
    public partial class OperateDialog : Window
    {
        public event EventHandler closeEvent;
        public NodeOperationTypeEnum OperMark = NodeOperationTypeEnum.Continue;
 
        System.Threading.Timer heartTimer;//用于轮询远程是否有消息过来关闭窗口
        public int remoteMark = 0;//远程控制信号
 
        /// <summary>
        /// 构造函数
        /// </summary>
        public OperateDialog(string info)
        {
            InitializeComponent();
            textblockMsg.Text = info;
            this.Owner = (Window)Shared.Main;
        }
 
        /// <summary>
        /// 初期表示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Load(object sender, RoutedEventArgs e)
        {
            heartTimer = new System.Threading.Timer(heartTimer_Tick, null, 0, 1000);
            // 状态6 报错/急停 红闪/蜂鸣5S
            CommonBll.StatusLamp(6, false);
        }
 
        #region 定时器——轮询远程是否有消息过来关闭窗口
        private void heartTimer_Tick(object sender)
        {
            try
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    if (((MainWindow)this.Owner).remoteMark == 1)
                    {
                        btnJump_Click(null, null);
                        ((MainWindow)this.Owner).remoteMark = 0;
                        heartTimer.Dispose();
                    }
                    else if (((MainWindow)this.Owner).remoteMark == 2)
                    {
                        btnRetry_Click(null, null);
                        ((MainWindow)this.Owner).remoteMark = 0;
                        heartTimer.Dispose();
                    }
                    else if (((MainWindow)this.Owner).remoteMark == 3)
                    {
                        btnCancel_Click(null, null);
                        ((MainWindow)this.Owner).remoteMark = 0;
                        heartTimer.Dispose();
                    }
                }));
            }
            catch (Exception ex)
            {
                LoggerHelper.InfoLog("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 弹出窗口控制错误: " + ex.Message.ToString());
            }
        }
        #endregion
 
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            if (EventResponseController.Instance.CanExecute() == false)
                return;
 
            OperMark = NodeOperationTypeEnum.Cancel;
            Close();
        }
 
        /// <summary>
        /// 重试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRetry_Click(object sender, RoutedEventArgs e)
        {
            if (EventResponseController.Instance.CanExecute() == false)
                return;
            OperMark = NodeOperationTypeEnum.Retry;
            Close();
 
            // 状态4 运行 绿色
            CommonBll.StatusLamp(4, false);
        }
 
        /// <summary>
        /// 跳过
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnJump_Click(object sender, RoutedEventArgs e)
        {
            if (EventResponseController.Instance.CanExecute() == false)
                return;
 
            OperMark = NodeOperationTypeEnum.Continue;
            Close();
 
            // 状态4 运行 绿色
            CommonBll.StatusLamp(4, false);
        }
    }
}