123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 |
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Data.Param;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.Setting
- {
- /// <summary>
- /// 设置->工作流程
- /// </summary>
- internal class WorkFlowSettingDialog : PdnBaseForm
- {
- #region 控件
- private GroupBox groupBox1;
- private Button cancelBtn;
- private Button saveBtn;
- private Button button2;
- private Button button1;
- private GroupBox groupBox2;
- private Button button3;
- private GroupBox groupBox3;
- private Button button4;
- private Button button5;
- private Button button6;
- private TreeView treeView1;
- private TreeView treeView2;
- #endregion
- /// <summary>
- /// 工作空间
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 新增、重命名的弹窗
- /// </summary>
- private CreateNameDialog createNameDialog;
- /// <summary>
- /// 工作流程model
- /// </summary>
- private WorkFlowModel workFlowModel = Startup.instance.workFlowModel;
- /// <summary>
- /// 右侧树形菜单
- /// </summary>
- private ToolStripItemCollection collection;
- /// <summary>
- /// 是否新建工作流程
- /// </summary>
- private bool create = true;
- private string txtPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ModuleConfig.txt";
- private string[] menuIdArr;
- public WorkFlowSettingDialog(AppWorkspace appWorkspace)
- {
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- InitVisibleMenuId();
- this.button3.Enabled = false;
- this.button4.Enabled = false;
- InitializeTreeEvent();
- InitializeLeftTreeData();
- InitializeRightTreeData();
- }
- /// <summary>
- /// 获取txt文件中已保存的菜单可用id
- /// </summary>
- private void InitVisibleMenuId()
- {
- if (System.IO.File.Exists(txtPath))
- {
- string str = System.IO.File.ReadAllText(txtPath);
- if (str.IndexOf(',') != -1)
- {
- menuIdArr = str.Split(',');
- }
- else
- {
- if (!string.IsNullOrEmpty(str))
- {
- menuIdArr = new string[] { str };
- }
- }
- }
- }
- /// <summary>
- /// 初始化treeview的事件
- /// </summary>
- private void InitializeTreeEvent()
- {
- this.treeView1.HideSelection = false;
- this.treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
- this.treeView1.DrawNode += new DrawTreeNodeEventHandler(this.treeView_DrawNode);
- this.treeView1.Invalidated += new InvalidateEventHandler(this.treeView1_InvalidateEvent);
- this.treeView2.HideSelection = false;
- this.treeView2.DrawMode = TreeViewDrawMode.OwnerDrawText;
- this.treeView2.DrawNode += new DrawTreeNodeEventHandler(this.treeView_DrawNode);
- this.treeView2.Invalidated += new InvalidateEventHandler(this.treeView2_InvalidateEvent);
- }
- /// <summary>
- /// treeView1的重绘事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView1_InvalidateEvent(object sender, InvalidateEventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- if (this.treeView2.SelectedNode.Tag == null)
- this.button3.Enabled = true;
- }
- if (this.treeView1.SelectedNode != null)
- {
- if (this.treeView1.SelectedNode.Nodes.Count > 0)
- {
- this.button3.Enabled = false;
- }
- }
- }
- /// <summary>
- /// treeView2的重绘事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView2_InvalidateEvent(object sender, InvalidateEventArgs e)
- {
- this.button1.Enabled = true;
- if (this.treeView1.SelectedNode != null)
- {
- if (this.treeView1.SelectedNode.Nodes.Count == 0)
- {
- this.button3.Enabled = true;
- }
- }
- this.button4.Enabled = false;
- this.cancelBtn.Enabled = true;
- if (this.treeView2.SelectedNode != null)
- {
- if (this.treeView2.SelectedNode.Tag != null)
- {
- this.button1.Enabled = false;
- this.button3.Enabled = false;
- this.button4.Enabled = true;
- this.cancelBtn.Enabled = false;
- }
- }
- }
- /// <summary>
- /// 自定义绘制
- /// 参考https://www.cnblogs.com/JiYF/p/6693503.html
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
- {
- /**用默认颜色
- e.DrawDefault = true;
- return;
- **/
- //以下是自定义颜色
- if ((e.State & TreeNodeStates.Selected) != 0)
- {
- //演示为绿底白字
- e.Graphics.FillRectangle(Brushes.Green, e.Node.Bounds);
- Font nodeFont = e.Node.NodeFont;
- if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
- e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
- }
- else
- {
- e.DrawDefault = true;
- }
- if ((e.State & TreeNodeStates.Focused) != 0)
- {
- using (Pen focusPen = new Pen(Color.Black))
- {
- focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
- Rectangle focusBounds = e.Node.Bounds;
- focusBounds.Size = new Size(focusBounds.Width - 1,
- focusBounds.Height - 1);
- e.Graphics.DrawRectangle(focusPen, focusBounds);
- }
- }
- }
- /// <summary>
- /// 初始化左侧工作流程菜单
- /// </summary>
- private void InitializeLeftTreeData()
- {
- if (workFlowModel != null && workFlowModel.Flows != null)
- {
- for (int i = 0; i < this.workFlowModel.Flows.Count; i++)
- {
- TreeNode anime = new TreeNode(this.workFlowModel.Flows[i].Name);
- for (int j = 0; j < this.workFlowModel.Flows[i].Menus.Count; j++)
- {
- TreeNode child = new TreeNode();
- child.Text = this.workFlowModel.Flows[i].Menus[j].Name;
- child.Name = this.workFlowModel.Flows[i].Menus[j].Description;
- child.Tag = this.workFlowModel.Flows[i].Menus[j].Id;
- anime.Nodes.Add(child);
- }
- this.treeView2.Nodes.Add(anime);
- }
- }
- }
- /// <summary>
- /// 初始化右侧树形菜单数据
- /// </summary>
- private void InitializeRightTreeData()
- {
- this.collection = this.appWorkspace.ToolBar.MainMenu.Items;
- TreeNode anime = new TreeNode(PdnResources.GetString("Menu.menu.Text"));
- this.RecursiveData(collection, anime);
- anime.Expand();
- this.treeView1.Nodes.Add(anime);
- }
- /// <summary>
- /// 递归进行数据组织
- /// </summary>
- private void RecursiveData(ToolStripItemCollection collection, TreeNode anime)
- {
- //for (int i = 0; i < toolStripItemCollection.Count; i++)
- //{
- // //排除掉最近打开的文件,或者可以用数字id判断更准确
- // if (!toolStripItemCollection[i].Name.Equals("OpenRecent") && !toolStripItemCollection[i].Name.Equals("CameraSelection"))
- // {
- // if (toolStripItemCollection[i].GetType() != typeof(ToolStripSeparator) && ((PdnMenuItem)toolStripItemCollection[i]).CanShowInSenseShield)
- // {
- // TreeNode node = new TreeNode();
- // node.Name = toolStripItemCollection[i].Name;
- // node.Text = toolStripItemCollection[i].Text;
- // node.Tag = ((PdnMenuItem)toolStripItemCollection[i]).MenuId;
- // anime.Nodes.Add(node);
- // RecursiveData(((PdnMenuItem)toolStripItemCollection[i]).DropDownItems, node);
- // }
- // }
- //}
- for (int i = 0; i < collection.Count; i++)
- {
- TreeNode node = new TreeNode(/*collection[i].Text*/);
- if (collection[i] is PdnMenuItem)
- {
- PdnMenuItem item = (PdnMenuItem)collection[i];
- if (!item.CanShowInSenseShield)
- continue;
- node.Tag = item.MenuId;
- if (menuIdArr != null && menuIdArr.Length > 0)
- {
- if (Array.IndexOf(menuIdArr, item.MenuId.ToString()) != -1)
- {
- node.Name = collection[i].Name;
- node.Text = collection[i].Text;
- node.Tag = ((PdnMenuItem)collection[i]).MenuId;
- node.Checked = true;
- }
- else
- {
- node.Checked = false;
- }
- }
- if (node.Checked)
- {
- anime.Nodes.Add(node);
- }
- if (collection[i].Name.Equals("OpenRecent") || collection[i].Name.Equals("CameraSelection"))
- continue;
- RecursiveData(((PdnMenuItem)collection[i]).DropDownItems, node);
- }
- }
- }
- private void InitializeLanguageText()
- {
- this.Text = PdnResources.GetString("Menu.Setting.WorkFlowSetting.Text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button2.Text = PdnResources.GetString("Menu.File.Save.Text");
- this.button1.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.cancelBtn.Text = PdnResources.GetString("Menu.Rename.text");
- this.saveBtn.Text = PdnResources.GetString("Menu.Add.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Set.workprocess.Theworkflowismaintained.text");
- this.button3.Text = "< " + PdnResources.GetString("Menu.Addto.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Availablefunctions.text");
- this.button4.Text = PdnResources.GetString("Menu.Moveout.text") + " >";
- this.button5.Text = PdnResources.GetString("Menu.LabelAction.MoveUpAction.Text");
- this.button6.Text = PdnResources.GetString("Menu.LabelAction.MoveDownAction.Text");
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.cancelBtn = new System.Windows.Forms.Button();
- this.saveBtn = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.treeView2 = new System.Windows.Forms.TreeView();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.treeView1 = new System.Windows.Forms.TreeView();
- this.button4 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Controls.Add(this.cancelBtn);
- this.groupBox1.Controls.Add(this.saveBtn);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(508, 58);
- this.groupBox1.TabIndex = 3;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(420, 19);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 3;
- this.button2.Text = "保存";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(339, 19);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 2;
- this.button1.Text = "删除";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // cancelBtn
- //
- this.cancelBtn.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.cancelBtn.Location = new System.Drawing.Point(258, 19);
- this.cancelBtn.Name = "cancelBtn";
- this.cancelBtn.Size = new System.Drawing.Size(75, 23);
- this.cancelBtn.TabIndex = 1;
- this.cancelBtn.Text = "重命名";
- this.cancelBtn.UseVisualStyleBackColor = true;
- this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
- //
- // saveBtn
- //
- this.saveBtn.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.saveBtn.Location = new System.Drawing.Point(177, 19);
- this.saveBtn.Name = "saveBtn";
- this.saveBtn.Size = new System.Drawing.Size(75, 23);
- this.saveBtn.TabIndex = 0;
- this.saveBtn.Text = "新增";
- this.saveBtn.UseVisualStyleBackColor = true;
- this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.treeView2);
- this.groupBox2.Location = new System.Drawing.Point(13, 77);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(200, 483);
- this.groupBox2.TabIndex = 4;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "已维护工作流程";
- //
- // treeView2
- //
- this.treeView2.Location = new System.Drawing.Point(7, 21);
- this.treeView2.Name = "treeView2";
- this.treeView2.Size = new System.Drawing.Size(187, 456);
- this.treeView2.TabIndex = 0;
- this.treeView2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView2_MouseDown);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(230, 100);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 5;
- this.button3.Text = "添加";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.treeView1);
- this.groupBox3.Location = new System.Drawing.Point(320, 77);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(200, 483);
- this.groupBox3.TabIndex = 6;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "可用功能";
- //
- // treeView1
- //
- this.treeView1.Location = new System.Drawing.Point(7, 21);
- this.treeView1.Name = "treeView1";
- this.treeView1.Size = new System.Drawing.Size(187, 456);
- this.treeView1.TabIndex = 0;
- this.treeView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseDown);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(230, 130);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 7;
- this.button4.Text = "移出";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(230, 160);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 8;
- this.button5.Text = "向上移动";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(230, 190);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 9;
- this.button6.Text = "向下移动";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // WorkFlowSettingDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(533, 572);
- this.Controls.Add(this.button6);
- this.Controls.Add(this.button5);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "WorkFlowSettingDialog";
- this.Text = "工作流程";
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.button3, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.button4, 0);
- this.Controls.SetChildIndex(this.button5, 0);
- this.Controls.SetChildIndex(this.button6, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 新建
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void saveBtn_Click(object sender, EventArgs e)
- {
- create = true;
- createNameDialog = new CreateNameDialog(this);
- createNameDialog.StartPosition = FormStartPosition.CenterParent;
- createNameDialog.ShowDialog();
- }
- /// <summary>
- /// 重命名
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cancelBtn_Click(object sender, EventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- create = false;
- createNameDialog = new CreateNameDialog(this);
- createNameDialog.SetTextBoxValue(this.treeView2.SelectedNode.Text);
- createNameDialog.StartPosition = FormStartPosition.CenterParent;
- createNameDialog.ShowDialog();
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.leaseselectaworkflowthathasbeenma.Text"));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- if (MessageBox.Show(PdnResources.GetString("Menu.reyousureyouwanttodeletetheselectedwo.Text") + "?", PdnResources.GetString("Menu.Thisdeletioncannotberecovered.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode);
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.erearenomaintainedworkflowstodel.Text"));
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- workFlowModel.Flows.Clear();
- for (int i = 0; i < this.treeView2.Nodes.Count; i++)
- {
- WorkFlowModel.Flow flow = new WorkFlowModel.Flow();
- flow.Menus = new List<WorkFlowModel.Flow.Item>();
- flow.Name = this.treeView2.Nodes[i].Text;
- if (this.treeView2.Nodes[i].Nodes.Count > 0)
- {
- for (int j = 0; j < this.treeView2.Nodes[i].Nodes.Count; j++)
- {
- WorkFlowModel.Flow.Item item = new WorkFlowModel.Flow.Item();
- item.Id = (int)(this.treeView2.Nodes[i].Nodes[j].Tag);
- item.Name = this.treeView2.Nodes[i].Nodes[j].Text;
- item.Description = this.treeView2.Nodes[i].Nodes[j].Name;
- flow.Menus.Add(item);
- }
- }
- workFlowModel.Flows.Add(flow);
- }
- string userInfoXml = XmlSerializeHelper.XmlSerialize<WorkFlowModel>(workFlowModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkFlow.xml";
- if (FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create))
- {
- Startup.instance.workFlowModel = workFlowModel;
- if (this.appWorkspace.workFlowDialog != null)
- {
- this.appWorkspace.workFlowDialog.InitializeWorkFlow();
- }
- this.Close();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Workflowsavefailed.Text"));
- }
- }
- /// <summary>
- /// 获取新建窗口里面输入的名称
- /// </summary>
- /// <param name="name"></param>
- public override void GetCreateName(string name)
- {
- if (!name.Equals(""))
- {
- if (create) //新增
- {
- this.treeView2.Nodes.Add(new TreeNode(name));
- }
- else //重命名
- {
- if (this.treeView2.SelectedNode != null)
- {
- this.treeView2.SelectedNode.Text = name;
- }
- }
- createNameDialog.Close();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.leaseenterworkflowname.Text"));
- }
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (this.treeView1.SelectedNode != null && this.treeView2.SelectedNode != null)
- {
- TreeNode child = new TreeNode();
- child.Text = this.treeView1.SelectedNode.Text;//显示的名称 多语言
- child.Name = this.treeView1.SelectedNode.Name;//唯一标识 英文
- child.Tag = this.treeView1.SelectedNode.Tag;//唯一标识 数字
- this.treeView2.SelectedNode.Nodes.Add(child);
- }
- }
- /// <summary>
- /// 移出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode);
- this.treeView2.Refresh();
- }
- }
- /// <summary>
- /// 向上移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- if (this.treeView2.SelectedNode.Parent != null)
- {
- int index = this.treeView2.SelectedNode.Parent.Nodes.IndexOf(this.treeView2.SelectedNode);
- if (index > 0)
- {
- TreeNode prenode = (TreeNode)this.treeView2.SelectedNode.PrevNode.Clone();
- this.treeView2.SelectedNode.Parent.Nodes.Insert(index + 1, prenode);
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode.PrevNode);
- }
- }
- else
- {
- int index = this.treeView2.Nodes.IndexOf(this.treeView2.SelectedNode);
- if (index > 0)
- {
- TreeNode prenode = (TreeNode)this.treeView2.SelectedNode.PrevNode.Clone();
- this.treeView2.Nodes.Insert(index + 1, prenode);
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode.PrevNode);
- }
- }
- this.treeView2.Refresh();
- }
- }
- /// <summary>
- /// 向下移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.treeView2.SelectedNode != null)
- {
- if (this.treeView2.SelectedNode.Parent != null)
- {
- int index = this.treeView2.SelectedNode.Parent.Nodes.IndexOf(this.treeView2.SelectedNode);
- if (index < this.treeView2.SelectedNode.Parent.Nodes.Count - 1)
- {
- TreeNode prenode = (TreeNode)this.treeView2.SelectedNode.NextNode.Clone();
- this.treeView2.SelectedNode.Parent.Nodes.Insert(index, prenode);
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode.NextNode);
- }
- }
- else
- {
- int index = this.treeView2.Nodes.IndexOf(this.treeView2.SelectedNode);
- if (index < this.treeView2.Nodes.Count - 1)
- {
- TreeNode prenode = (TreeNode)this.treeView2.SelectedNode.NextNode.Clone();
- this.treeView2.Nodes.Insert(index, prenode);
- this.treeView2.Nodes.Remove(this.treeView2.SelectedNode.NextNode);
- }
- }
- this.treeView2.Refresh();
- }
- }
- /// <summary>
- /// 左侧工作流程鼠标按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView2_MouseDown(object sender, MouseEventArgs e)
- {
- if ((sender as TreeView) != null)
- {
- this.treeView2.SelectedNode = this.treeView2.GetNodeAt(e.X, e.Y);
- this.treeView2.Refresh();
- }
- }
- /// <summary>
- /// 右侧功能列表鼠标按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView1_MouseDown(object sender, MouseEventArgs e)
- {
- if ((sender as TreeView) != null)
- {
- this.treeView1.SelectedNode = this.treeView1.GetNodeAt(e.X, e.Y);
- this.treeView1.Refresh();
- }
- }
- }
- }
|