/ZXFramework_2/source/Tool/HF.WorkFlow.Tool/FrmworkTreeFrm.cs
C# | 310 lines | 297 code | 12 blank | 1 comment | 9 complexity | 7ae126505ea5ee33a5c8b401511bfee7 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, Apache-2.0, GPL-2.0, BSD-3-Clause, LGPL-2.0, MIT, GPL-3.0
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.IO;
- using System.Windows.Forms;
- using HF.Framework.UI.BaseForms;
- using HF.Framework;
- using HF.WorkFlow.Navigate;
- using HF.WorkFlow.DataContract;
- using HF.WorkFlow.Const;
- using HF.Framework.Windows;
-
-
-
- namespace HF.WorkFlow.Tool
- {
- public partial class FrmworkTreeFrm : BaseForm_Single
- {
- private string formState;//窗体状态,是修改还是新建
- private string InfoId;//操做主键
- private HFTreeNode NowTreeNode;//当前节点
- private FrmworkTreeEntity NowTreeNodeEntity;
-
- public FrmworkTreeFrm()
- {
- InitializeComponent();
- }
- private void initImage()
- {
- //AboutFrm
- this.Icon = HF.Resources.Properties.Resources.HF_AppMainIcon;
- }
-
- public FrmworkTreeFrm(string state, string iInfoId, HFTreeNode node)
- {
- InitializeComponent();
- formState = state;
- InfoId = iInfoId;
- NowTreeNode = node;
- NowTreeNodeEntity = (FrmworkTreeEntity)node.Tag;
- if (formState == WorkFlowConst.STATE_ADD)
- {
- this.Text = "新建模块";
- this.tbxFatherCaption.Text = NowTreeNodeEntity.Caption;
- rbtnWindow.Checked = true;//默认弹出窗体
- cbxOpenType.SelectedIndex = 1;//默认新窗口打开
- cbxRunType.SelectedIndex = 1;//默认双击执行
- }
- else
- {
- this.Text = "修改模块";
- getInfoById();
- }
-
- }
- private void getInfoById()
- {
- this.tbxNodeCaption.Text = NowTreeNodeEntity.Caption;
- if (NowTreeNode.Parent != null)
- {
- this.tbxFatherCaption.Text = NowTreeNode.Parent.Text; //上级节点名称,只做显示。
- }
- this.tbxDllFile.Text = NowTreeNodeEntity.DllFileName;
- string AssemblyName = Global.AppPath + "\\" + tbxDllFile.Text;
- if (File.Exists(AssemblyName) == false)
- {
- WorkDialog.WarningDlg("未找到程序集:" + AssemblyName + ",请将该程序集复制到程序运行目录下!", "警告");
- return;
-
- }
- loadClass(AssemblyName);
- if (string.IsNullOrEmpty(NowTreeNodeEntity.DllClassName)==false)
- this.cbxClassName.SelectedIndex =cbxClassName.Items.IndexOf( NowTreeNodeEntity.DllClassName);
- loadMethod(AssemblyName, NowTreeNodeEntity.DllClassName);
- this.tbxDescription.Text = NowTreeNodeEntity.Description;
-
- rbtnWindow.Checked = (NowTreeNodeEntity.NodeType == WorkFlowConst.TREENODE_TYPE_WIN);//弹出窗体
- cbxOpenType.Enabled = (NowTreeNodeEntity.NodeType == WorkFlowConst.TREENODE_TYPE_WIN);//窗口打开方式
- rbtnFunction.Checked = (NowTreeNodeEntity.NodeType == WorkFlowConst.TREENODE_TYPE_FUN);//执行功能
- cbxMethodName.Enabled = (NowTreeNodeEntity.NodeType == WorkFlowConst.TREENODE_TYPE_FUN);//功能名称
-
- if (string.IsNullOrEmpty(NowTreeNodeEntity.OpenWindowType) == false)
- cbxOpenType.SelectedIndex = cbxOpenType.Items.IndexOf(NowTreeNodeEntity.OpenWindowType);//打开方式 新窗口/独占
- if (string.IsNullOrEmpty(NowTreeNodeEntity.DllMethodName) == false)
- cbxMethodName.SelectedIndex = cbxMethodName.Items.IndexOf(NowTreeNodeEntity.DllMethodName);//功能名
-
- if (NowTreeNodeEntity.MouseIsClick)
- {
- cbxRunType.SelectedIndex = 0;//单击
- }
- else
- {
- cbxRunType.SelectedIndex = 1;//双击
- }
- this.cbxVisable.Checked = NowTreeNodeEntity.IsVisable;
- this.cmbxImageIndex.SelectedIndex = NowTreeNodeEntity.ImageIndex;
-
- }
-
-
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private bool checkData()
- {
- if (string.IsNullOrEmpty(tbxNodeCaption.Text))
- {
- WorkDialog.WarningDlg("当前节点名称不能为空!","警告");
- tbxNodeCaption.Focus();
- return false;
- }
- if (string.IsNullOrEmpty(tbxDllFile.Text))
- {
- WorkDialog.WarningDlg("模块DLL文件不能为空!", "警告");
- tbxDllFile.Focus();
- return false;
- }
- if (cbxClassName.SelectedIndex<1)
- {
- WorkDialog.WarningDlg("请选择类名!", "警告");
- cbxClassName.Focus();
- return false;
- }
- if (rbtnFunction.Checked && cbxMethodName.SelectedIndex < 1)
- {
- WorkDialog.WarningDlg("请选择执行的功能!", "警告");
- cbxMethodName.Focus();
- return false;
- }
- if (rbtnWindow.Checked && cbxOpenType.SelectedIndex < 0)
- {
- WorkDialog.WarningDlg("请选择窗体打开方式!", "警告");
- cbxOpenType.Focus();
- return false;
- }
- if (cbxRunType.SelectedIndex < 0)
- {
- WorkDialog.WarningDlg("请选择执行方式!", "警告");
- cbxRunType.Focus();
- return false;
- }
- return true;
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (checkData() == false) return;
- if (formState == WorkFlowConst.STATE_ADD)
- {
- FrmworkTreeEntity entity = new FrmworkTreeEntity();
- entity.FatherId = NowTreeNode.NodeId;
- entity.TreeId = Guid.NewGuid().ToString();
- entity.Caption = this.tbxNodeCaption.Text;
- entity.DllFileName = this.tbxDllFile.Text;
- entity.DllClassName = this.cbxClassName.SelectedItem.ToString();
- entity.Description = this.tbxDescription.Text;
- entity.MouseIsClick = (this.cbxRunType.SelectedIndex == 0);
- entity.IsVisable = this.cbxVisable.Checked;
- if (rbtnWindow.Checked)
- {
- entity.NodeType = WorkFlowConst.TREENODE_TYPE_WIN;
- entity.OpenWindowType = this.cbxOpenType.SelectedItem.ToString();
- }
- else
- {
- entity.NodeType = WorkFlowConst.TREENODE_TYPE_FUN;
- entity.DllMethodName = this.cbxMethodName.SelectedItem.ToString();
- }
- entity.ImageIndex = this.cmbxImageIndex.SelectedIndex;
- FrmworkTreeData.GetInstance().Insert(entity);
-
- HFTreeNode tmpNode = new HFTreeNode();
- tmpNode.NodeId = entity.TreeId;
- tmpNode.Text = entity.Caption;
- tmpNode.ImageIndex = entity.ImageIndex;
- tmpNode.SelectedImageIndex = entity.ImageIndex;
- tmpNode.Tag = entity;
- NowTreeNode.Nodes.Add(tmpNode);
-
- }
- else
- {
- NowTreeNodeEntity.Caption = this.tbxNodeCaption.Text;
- NowTreeNodeEntity.DllFileName = this.tbxDllFile.Text;
- NowTreeNodeEntity.DllClassName = this.cbxClassName.SelectedItem.ToString();
- NowTreeNodeEntity.Description = this.tbxDescription.Text;
- NowTreeNodeEntity.MouseIsClick = (this.cbxRunType.SelectedIndex == 0);
- NowTreeNodeEntity.IsVisable = this.cbxVisable.Checked;
- if (rbtnWindow.Checked)
- {
- NowTreeNodeEntity.NodeType = WorkFlowConst.TREENODE_TYPE_WIN;
- NowTreeNodeEntity.OpenWindowType = this.cbxOpenType.SelectedItem.ToString();
- }
- else
- {
- NowTreeNodeEntity.NodeType = WorkFlowConst.TREENODE_TYPE_FUN;
- NowTreeNodeEntity.DllMethodName = this.cbxMethodName.SelectedItem.ToString();
- }
-
- NowTreeNodeEntity.ImageIndex = this.cmbxImageIndex.SelectedIndex;
- FrmworkTreeData.GetInstance().Update(NowTreeNodeEntity);
-
- NowTreeNode.NodeId = NowTreeNodeEntity.TreeId;
- NowTreeNode.Text = NowTreeNodeEntity.Caption;
- NowTreeNode.ImageIndex = NowTreeNodeEntity.ImageIndex;
- NowTreeNode.SelectedImageIndex = NowTreeNodeEntity.ImageIndex;
-
-
-
- }
- this.Close();
-
-
- }
-
- private void cmbxNodeType_SelectedIndexChanged(object sender, EventArgs e)
- {
-
-
- }
-
- private void FrmworkTreeFrm_Load(object sender, EventArgs e)
- {
- initImage();
- }
-
- private void rbtnWindow_CheckedChanged(object sender, EventArgs e)
- {
- cbxOpenType.Enabled = (rbtnWindow.Checked);
- cbxMethodName.Enabled = rbtnFunction.Checked;
-
- }
- private void loadCombobox(List<string> list,ComboBox cb)
- {
- cb.Items.Clear();
- cb.Items.Add("请选择...");
- foreach (string each in list)
- {
- cb.Items.Add(each);
- }
-
- }
- private void loadClass(string assemblyName)
- {
-
- List<string> classList = DynamicLibrary.GetAssemblyClassList(assemblyName);
- loadCombobox(classList, cbxClassName);
- }
- private void loadMethod(string assemblyName, string className)
- {
- List<string> methodList = DynamicLibrary.GetAssemblyMethodList(assemblyName, className);
- loadCombobox(methodList, cbxMethodName);
- }
- private void btnOpenDll_Click(object sender, EventArgs e)
- {
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- string fileName =Path.GetFileName(openFileDialog1.FileName);
- tbxDllFile.Text = fileName;
- string AssemblyName = Global.AppPath + "\\" + fileName;
- if (File.Exists(AssemblyName) == false)
- {
- WorkDialog.WarningDlg("未找到程序集:"+AssemblyName+",请将该程序集复制到程序运行目录下!","警告");
- return ;
- }
- loadClass(AssemblyName);
-
- }
- }
-
- private void btnLoadClass_Click(object sender, EventArgs e)
- {
-
- }
-
- private void cbxMethodName_DropDown(object sender, EventArgs e)
- {
- string ClassName = cbxClassName.SelectedItem.ToString();
- string AssemblyName = Global.AppPath + "\\" + tbxDllFile.Text;
-
- if (File.Exists(AssemblyName) == false)
- {
- WorkDialog.WarningDlg("未找到程序集:" + AssemblyName + ",请将该程序集复制到程序运行目录下!", "警告");
- return;
- }
- if (cbxClassName.SelectedIndex < 1)
- {
- WorkDialog.WarningDlg("请先选择类名!", "警告");
- return;
- }
- loadMethod(AssemblyName, ClassName);
- }
-
- private void cbxClassName_DropDown(object sender, EventArgs e)
- {
- string AssemblyName = Global.AppPath + "\\" + tbxDllFile.Text;
- if (File.Exists(AssemblyName) == false)
- {
- WorkDialog.WarningDlg("未找到程序集:" + AssemblyName + ",请将该程序集复制到程序运行目录下!", "警告");
- return;
- }
- loadClass(AssemblyName);
- }
-
- }
- }
-