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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using DataEntity.Share;
using HxEnum;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using XCommon;
using XCommon.Log;
using XCommon.Xml;
using XCore;
using XHandler.Controls;
using XHandler.Controls.Run.Com;
using XHandler.View.Com;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.MethodProperty
{
    /// <summary>
    /// 字方法工作流页面
    /// </summary>
    public partial class SubMethodWorkflow : Window
    {
        #region 变量
        /// <summary>
        /// 方法数据
        /// </summary>
        private MethodSubMethod m_methodData = null;
 
        /// <summary>
        /// 工作流数据
        /// </summary>
        private MethodEx m_rootMethod = new MethodEx();
        #endregion
 
        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        public SubMethodWorkflow(MethodSubMethod methodData)
        {
            InitializeComponent();
 
            m_methodData = methodData;
            this.Owner = (Window)Shared.Main;
        }
        #endregion
 
        #region 初始化
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
 
                tboxTitle.Text = this.Title = $"{m_methodData.strIndex}-{m_methodData.name}: {m_methodData.filePath}";
                tboxTitle.ToolTip = tboxTitle.Text;
 
                MethodEx mEx = ComUtility.FindMethodExByKeyId(Shared.AllNodeMethod, m_methodData.keyId);
                if (mEx == null || mEx.SubMethod == null)
                {
                    // 初始化工作流
                    ViewCom.InitWorkFlow(m_rootMethod);
 
                    XmlHelper xmlHelper = new XmlHelper();
                    xmlHelper.xmlDoc.Load(m_methodData.filePath);
 
                    // 解析xml往Tree上绑定命令集
                    ControlCom.BindWorkFlowIntoTree(xmlHelper.xmlDoc, m_rootMethod, runTreeviewWorkflow, null, true, true);
                }
                else
                {
                    m_rootMethod = mEx.SubMethod;
                    runTreeviewWorkflow.ItemsSource = m_rootMethod.Children;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
        #endregion
 
        #region runTreeviewWorkflow鼠标右键点击事件
        /// <summary>
        /// 鼠标右键点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void runTreeviewWorkflow_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject source = e.OriginalSource as DependencyObject;
            while (source != null && source.GetType() != typeof(TreeViewItem))
                source = VisualTreeHelper.GetParent(source);
            if (source != null)
            {
                TreeViewItem item = source as TreeViewItem;
                item.IsSelected = true;
                MethodEx mEx = item.DataContext as MethodEx;
                ContextMenu menu = FindResource("workflowMenu") as ContextMenu;
                MethodListBll methodListBll = new MethodListBll();
                int iNum = methodListBll.getNumByMethodName(mEx.method_name);
                MenuItem menuItem = menu.Items[0] as MenuItem;
                //menuItem.IsEnabled = mEx.method_id.Equals(EnumManagement.GetEnumValue(MethodNameEnum.subMethod).ToString()) ? true : false;
                menuItem.IsEnabled = (iNum == (int)MethodNameEnum.subMethod) ? true : false;
            }
        }
        #endregion
 
        #region 子方法节点右击运行状态
        private void workflowMenuRunStatus_Click(object sender, RoutedEventArgs e)
        {
            // 打开子方法流程状态页面
            ViewCom.OpenSubMethodWorkflow(runTreeviewWorkflow);
        }
        #endregion
 
        #region 关闭页面
        /// <summary>
        /// 关闭页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        #endregion
 
        #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
    }
}