using PaintDotNet.Base.SettingModel;
using PaintDotNet.Base.CommTool;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
namespace PaintDotNet.Instrument
{
///
/// 工作流程
///
internal class WorkFlowDialog : FloatingToolForm
{
private AppWorkspace appWorkspace;
private System.Windows.Forms.TreeView treeView1;
private WorkFlowModel workFlowModel = Startup.instance.workFlowModel;
public WorkFlowDialog(AppWorkspace appWorkspace)
{
this.appWorkspace = appWorkspace;
InitializeComponent();
this.Text = PdnResources.GetString("Menu.Setting.WorkFlowSetting.Text");
this.MinimumSize = this.Size;
InitializeWorkFlow();
}
///
/// 初始化工作流程数据
///
public void InitializeWorkFlow()
{
this.treeView1.Nodes.Clear();
if (this.workFlowModel!=null && this.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(this.workFlowModel.Flows[i].Menus[j].Name);
child.Tag = this.workFlowModel.Flows[i].Menus[j].Description;
anime.Nodes.Add(child);
}
this.treeView1.Nodes.Add(anime);
}
}
}
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.Location = new System.Drawing.Point(13, 13);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(140, 436);
this.treeView1.TabIndex = 1;
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
//
// WorkFlowDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(165, 461);
this.Controls.Add(this.treeView1);
this.Name = "WorkFlowDialog";
this.Text = "工作流程";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WorkFlowDialog_FormClosing);
this.Controls.SetChildIndex(this.treeView1, 0);
this.ResumeLayout(false);
}
///
/// 节点点击事件
///
///
///
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if(e.Node != null && e.Node.Tag!=null)
{
ToolStripItem[] menu = this.appWorkspace.ToolBar.MainMenu.Items.Find(e.Node.Tag.ToString(), true);
if (menu != null && menu.Length > 0)
{
((PdnMenuItem)menu[0]).PerformClick();
}
}
}
private void WorkFlowDialog_FormClosing(object sender, FormClosingEventArgs e)
{
this.appWorkspace.toolBar.RefreshBtnSelect(false, "WorkFlow");
this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "WorkFlow");
}
}
}