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
140
141
using DataEntity.Share;
using System;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using XCommon.Log;
using XHandler.Controls.Run.Com;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.MethodProperty
{
    public enum DialogResults
    {
        None,
        OK,
        Cancel,
        Yes,
        No
    }
    /// <summary>
    /// 确认Dialog
    /// </summary>
    public partial class PlsToolTipWin : Window
    {
        public RunWnd lauchView = null;
        System.Threading.Timer heartTimer;//用于轮询远程是否有消息过来关闭窗口
        public int remoteMark = 0;//远程控制信号
 
        public PlsToolTipWin(string info)
        {
            InitializeComponent();
            textblockMsg.Text = info;
            this.Owner = (Window)Shared.Main;
        }
 
        #region 定时器——轮询远程是否有消息过来关闭窗口
        private void heartTimer_Tick(object sender)
        {
            try
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    if (((MainWindow)this.Owner).remoteMark == 4)
                    {
                        btnOK_Click(null, null);
                    }
                    else if (((MainWindow)this.Owner).remoteMark == 3)
                    {
                        btnCancel_Click(null, null);
                    }
                }));
            }
            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)
        {
            this.DialogResult = false;
            this.Close();
        }
 
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }
 
        /// <summary>
        /// 清除缓存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
 
        private void btnClearData_Click(object sender, RoutedEventArgs e)
        {
            if (lauchView != null)
            {
                // 清除Tip缓存数据
                ControlCom.ClearTipData(lauchView);
            }
 
            string directoryBase = System.AppDomain.CurrentDomain.BaseDirectory;
            string xmlFilePath = directoryBase + "Config\\" + "CurrentUsedTips.xml";
            if (File.Exists(xmlFilePath))
            {
                File.Delete(xmlFilePath);
            }
        }
 
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
 
        #region 拖动窗体
        /// <summary>
        /// 拖动窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                this.DragMove();
            }
        }
        #endregion
 
        #region ESC关闭画面
        /// <summary>
        /// ESC关闭画面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                this.Close();
            }
        }
        #endregion
    }
}