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
|
}
|
}
|