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
{
///
/// OperateDialog.xaml 的交互逻辑
///
public partial class OperateDialog : Window
{
public event EventHandler closeEvent;
public NodeOperationTypeEnum OperMark = NodeOperationTypeEnum.Continue;
System.Threading.Timer heartTimer;//用于轮询远程是否有消息过来关闭窗口
public int remoteMark = 0;//远程控制信号
///
/// 构造函数
///
public OperateDialog(string info)
{
InitializeComponent();
textblockMsg.Text = info;
this.Owner = (Window)Shared.Main;
}
///
/// 初期表示
///
///
///
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
///
/// 取消
///
///
///
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
if (EventResponseController.Instance.CanExecute() == false)
return;
OperMark = NodeOperationTypeEnum.Cancel;
Close();
}
///
/// 重试
///
///
///
private void btnRetry_Click(object sender, RoutedEventArgs e)
{
if (EventResponseController.Instance.CanExecute() == false)
return;
OperMark = NodeOperationTypeEnum.Retry;
Close();
// 状态4 运行 绿色
CommonBll.StatusLamp(4, false);
}
///
/// 跳过
///
///
///
private void btnJump_Click(object sender, RoutedEventArgs e)
{
if (EventResponseController.Instance.CanExecute() == false)
return;
OperMark = NodeOperationTypeEnum.Continue;
Close();
// 状态4 运行 绿色
CommonBll.StatusLamp(4, false);
}
}
}