FormToolBox.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using CommonMethods;
  11. using WeifenLuo.WinFormsUI.Docking;
  12. using ToolLib.VisionJob;
  13. using VisionJobFactory;
  14. namespace ToolLib.VisionJob
  15. {
  16. public partial class FormToolBox : DockContent
  17. {
  18. public FormToolBox()
  19. {
  20. InitializeComponent();
  21. VisionToolFactory.InitVisionToolTypeDic();
  22. }
  23. /// <summary>
  24. /// 窗体对象实例
  25. /// </summary>
  26. private static FormToolBox _instance;
  27. public static FormToolBox Instance
  28. {
  29. get
  30. {
  31. if (_instance == null)
  32. _instance = new FormToolBox();
  33. return _instance;
  34. }
  35. }
  36. private void tvw_ToolBox_AfterSelect(object sender, TreeViewEventArgs e)
  37. {
  38. if(e.Node.Level == 0)
  39. {
  40. this.richTextBoxEx1.Text = e.Node.Text;
  41. }
  42. else if(e.Node.Level == 1)
  43. {
  44. object selectTag = tvw_ToolBox.SelectedNode.Tag;
  45. if (selectTag != null)
  46. {
  47. IToolInfo insertTool = VisionToolFactory.CreateToolVision((ToolType)Enum.Parse(typeof(ToolType), selectTag.ToString()));
  48. this.richTextBoxEx1.Text = insertTool.toolDescription;
  49. }
  50. else
  51. {
  52. this.richTextBoxEx1.Text = "此工具尚未开发";
  53. }
  54. }
  55. }
  56. private void tvw_ToolBox_DoubleClick(object sender, EventArgs e)
  57. {
  58. try
  59. {
  60. if (tvw_ToolBox.SelectedNode.Level == 0) //如果双击的是文件夹节点,返回
  61. return;
  62. if(VisionJobParams.pVisionProject.Project.Count == 0) // 若当前无流程,需要先建立项目和流程树,并对其进行初始化
  63. {
  64. OperateProject.Instance.CreateNewJob();
  65. }
  66. if (VisionJobParams.pVisionProject.Project.Count > 0) //再次确认已存在流程
  67. {
  68. object selectTag = tvw_ToolBox.SelectedNode.Tag;
  69. if(selectTag != null)
  70. {
  71. ToolType mToolType = (ToolType)Enum.Parse(typeof(ToolType), selectTag.ToString());
  72. OperateTreeView.Instance.Add_Tool(mToolType);
  73. }
  74. else
  75. {
  76. Logger.LoggerClass.WriteLog($"{tvw_ToolBox.SelectedNode.Text} 工具尚未开发", Logger.MsgLevel.Warn);
  77. }
  78. }
  79. }
  80. catch (Exception ex)
  81. {
  82. Logger.LoggerClass.WriteLog($"添加流程失败!失败原因:{ex.Message}", ex);
  83. }
  84. }
  85. private void tvw_ToolBox_Click(object sender, EventArgs e)
  86. {
  87. }
  88. }
  89. }