diff --git a/AUTS_Win/bin/Debug/UTS_Core.xml b/AUTS_Win/bin/Debug/UTS_Core.xml index 9a1d437..dcd9d36 100644 --- a/AUTS_Win/bin/Debug/UTS_Core.xml +++ b/AUTS_Win/bin/Debug/UTS_Core.xml @@ -1513,53 +1513,48 @@ UTS_Core - - - 运行一条需要记录在撤销栈的命令 - - - + 重做命令 - + 撤销命令 - + 运行命令,并将命令添加至撤销堆栈 - + 将命令添加至撤销堆栈 - + 清空撤销命令堆栈 - + 清空重做命令堆栈 - + 清空撤销与重做命令堆栈 - + 执行撤销命令 - + 执行重做命令 @@ -6074,12 +6069,42 @@ UTS_Core 测试流程所关联的项目站包信息 + + 表格控件对象 + + + 表格树状目录起始节点 + + + 起始绘制列 + + + 起始绘制行 + + + 调试模式是否开启 + + + 是否显示节点图标 + 处于更新表格状态中,不触发表格单元格修改事件 多个参数间的分割符号 + + 测试命令管理器 + + + 错误代码管理器 + + + 表格标签字段字典 + + + 表格记录名称字段字典 + 当前活动节点 @@ -6089,11 +6114,8 @@ UTS_Core 节点文本被修改事件 - - 测试命令管理器 - - - 错误代码管理器 + + 节点执行可撤销事件 @@ -6101,11 +6123,6 @@ UTS_Core - - - 对第二行的Action执行一遍操作,以触发更新事件 - - 向后导航 @@ -6135,6 +6152,80 @@ UTS_Core + + + 当前模块名是否已存在 + + + + + + + 当前字段名 + + + + + + + 清空标签名称 + + + + + 清空记录名称 + + + + + 添加标签名称 + + 标签名称 + 行号 + + + + 添加记录名称 + + 记录名 + 行号 + + + + 移出标签名称 + + 标签名称 + + + + 移出记录名称 + + 记录名称 + + + + 获取标签名称行号 + + + + + + + 获取记录名称行号 + + + + + + + 从表格中重载标签名称 + + + + + 从表格中重载记录名称 + + 光标离开grd表格时,黄色底色切换到选中行 @@ -6145,38 +6236,16 @@ UTS_Core 光标进入grd表格时,原底色切换到选中行 - - - 根据CmdType 和 isAction 返回该行字体颜色 - - - 鼠标移动到节点位置时所有子节点背景着色 - + - FixModule节点Action变化时子节点字体重新着色 + 节点类型变更,修改节点行样式 - - - - - FixModule节点Action变化时子节点字体重新着色 - - - - - 根据总表状态对单元格字体重新着色 - - - - - 遍历表格,并更新到全局数组 - - + @@ -6195,16 +6264,6 @@ UTS_Core 选定行使能或清除Action选项 - - - 更新表格内容到缓存,但是并不重新着色 - - - - - 更新ActionEn信息 - - 光标移动时,所在行底色高亮 @@ -6251,6 +6310,12 @@ UTS_Core 初始化测试站表格 + + + 加载测试文件后更新表格 + + + 展开行节点 diff --git a/UTS_Core/UTSModule/Station/FrmStationPlan.Designer.vb b/UTS_Core/UTSModule/Station/FrmStationPlan.Designer.vb index defc978..52ecc33 100644 --- a/UTS_Core/UTSModule/Station/FrmStationPlan.Designer.vb +++ b/UTS_Core/UTSModule/Station/FrmStationPlan.Designer.vb @@ -35,12 +35,15 @@ Namespace UTSModule.Station Me.TsBtnLoad = New System.Windows.Forms.ToolStripButton() Me.TsBtnSaveAs = New System.Windows.Forms.ToolStripButton() Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() - Me.tsBtnInsertRow = New System.Windows.Forms.ToolStripButton() - Me.tsBtnRemoveRow = New System.Windows.Forms.ToolStripButton() - Me.ToolStripSeparator13 = New System.Windows.Forms.ToolStripSeparator() - Me.TsBtnBackward = New System.Windows.Forms.ToolStripButton() - Me.TsBtnForward = New System.Windows.Forms.ToolStripButton() - Me.ToolStripSeparator14 = New System.Windows.Forms.ToolStripSeparator() + Me.TsBtnBackward = New System.Windows.Forms.ToolStripButton() + Me.TsBtnForward = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() + Me.TsBtnUndo = New System.Windows.Forms.ToolStripButton() + Me.TsBtnRedo = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator13 = New System.Windows.Forms.ToolStripSeparator() + Me.tsBtnInsertRow = New System.Windows.Forms.ToolStripButton() + Me.tsBtnRemoveRow = New System.Windows.Forms.ToolStripButton() + Me.ToolStripSeparator14 = New System.Windows.Forms.ToolStripSeparator() Me.TsBtnMoveUp = New System.Windows.Forms.ToolStripButton() Me.TsBtnMoveDown = New System.Windows.Forms.ToolStripButton() Me.TsBtnMoveLeft = New System.Windows.Forms.ToolStripButton() @@ -76,8 +79,8 @@ Namespace UTSModule.Station Me.ToolStripSeparator11 = New System.Windows.Forms.ToolStripSeparator() Me.TsmiDebugStart = New System.Windows.Forms.ToolStripMenuItem() Me.TsmiDebugEnd = New System.Windows.Forms.ToolStripMenuItem() - Me.TsmiDebugStep = New System.Windows.Forms.ToolStripMenuItem() Me.TsmiDebugContinue = New System.Windows.Forms.ToolStripMenuItem() + Me.TsmiDebugStep = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator8 = New System.Windows.Forms.ToolStripSeparator() Me.TsmiDebugSetup = New System.Windows.Forms.ToolStripMenuItem() Me.TsmiDebugMain = New System.Windows.Forms.ToolStripMenuItem() @@ -95,6 +98,7 @@ Namespace UTSModule.Station Me.TabControl1 = New System.Windows.Forms.TabControl() Me.TpOutputInfo = New System.Windows.Forms.TabPage() Me.RtxOutputInfo = New System.Windows.Forms.RichTextBox() + Me.TsmiJumpCall = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStrip1.SuspendLayout() Me.StuMain.SuspendLayout() CType(Me.SplStationPlan, System.ComponentModel.ISupportInitialize).BeginInit() @@ -119,7 +123,7 @@ Namespace UTSModule.Station ' 'ToolStrip1 ' - Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TsBtnOpen, Me.TsBtnSave, Me.ToolStripSeparator4, Me.TsBtnLoad, Me.TsBtnSaveAs, Me.ToolStripSeparator3, Me.TsBtnBackward, Me.TsBtnForward, Me.ToolStripSeparator13, Me.tsBtnInsertRow, Me.tsBtnRemoveRow, Me.ToolStripSeparator14, Me.TsBtnMoveUp, Me.TsBtnMoveDown, Me.TsBtnMoveLeft, Me.TsBtnMoveRight, Me.ToolStripSeparator2, Me.TsBtnDebugMode, Me.TsBtnDebugStart, Me.TsBtnFailMode, Me.ToolStripSeparator10, Me.tslBtn_ActionOnly, Me.TsBtn_Record, Me.TsBtn_ExpandNode}) + Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TsBtnOpen, Me.TsBtnSave, Me.ToolStripSeparator4, Me.TsBtnLoad, Me.TsBtnSaveAs, Me.ToolStripSeparator3, Me.TsBtnBackward, Me.TsBtnForward, Me.ToolStripSeparator1, Me.TsBtnUndo, Me.TsBtnRedo, Me.ToolStripSeparator13, Me.tsBtnInsertRow, Me.tsBtnRemoveRow, Me.ToolStripSeparator14, Me.TsBtnMoveUp, Me.TsBtnMoveDown, Me.TsBtnMoveLeft, Me.TsBtnMoveRight, Me.ToolStripSeparator2, Me.TsBtnDebugMode, Me.TsBtnDebugStart, Me.TsBtnFailMode, Me.ToolStripSeparator10, Me.tslBtn_ActionOnly, Me.TsBtn_Record, Me.TsBtn_ExpandNode}) Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" Me.ToolStrip1.Size = New System.Drawing.Size(977, 40) @@ -176,6 +180,58 @@ Namespace UTSModule.Station Me.ToolStripSeparator3.Name = "ToolStripSeparator3" Me.ToolStripSeparator3.Size = New System.Drawing.Size(6, 40) ' + 'TsBtnBackward + ' + Me.TsBtnBackward.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) + Me.TsBtnBackward.Image = CType(resources.GetObject("TsBtnBackward.Image"), System.Drawing.Image) + Me.TsBtnBackward.ImageTransparentColor = System.Drawing.Color.Magenta + Me.TsBtnBackward.Name = "TsBtnBackward" + Me.TsBtnBackward.Size = New System.Drawing.Size(47, 37) + Me.TsBtnBackward.Text = "上一步" + Me.TsBtnBackward.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText + ' + 'TsBtnForward + ' + Me.TsBtnForward.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) + Me.TsBtnForward.Image = CType(resources.GetObject("TsBtnForward.Image"), System.Drawing.Image) + Me.TsBtnForward.ImageTransparentColor = System.Drawing.Color.Magenta + Me.TsBtnForward.Name = "TsBtnForward" + Me.TsBtnForward.Size = New System.Drawing.Size(47, 37) + Me.TsBtnForward.Text = "下一步" + Me.TsBtnForward.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText + Me.TsBtnForward.ToolTipText = "下一步" + ' + 'ToolStripSeparator1 + ' + Me.ToolStripSeparator1.Name = "ToolStripSeparator1" + Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 40) + ' + 'TsBtnUndo + ' + Me.TsBtnUndo.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) + Me.TsBtnUndo.Image = CType(resources.GetObject("TsBtnUndo.Image"), System.Drawing.Image) + Me.TsBtnUndo.ImageTransparentColor = System.Drawing.Color.Magenta + Me.TsBtnUndo.Name = "TsBtnUndo" + Me.TsBtnUndo.Size = New System.Drawing.Size(35, 37) + Me.TsBtnUndo.Text = "撤销" + Me.TsBtnUndo.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText + ' + 'TsBtnRedo + ' + Me.TsBtnRedo.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) + Me.TsBtnRedo.Image = CType(resources.GetObject("TsBtnRedo.Image"), System.Drawing.Image) + Me.TsBtnRedo.ImageTransparentColor = System.Drawing.Color.Magenta + Me.TsBtnRedo.Name = "TsBtnRedo" + Me.TsBtnRedo.Size = New System.Drawing.Size(35, 37) + Me.TsBtnRedo.Text = "重做" + Me.TsBtnRedo.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText + Me.TsBtnRedo.ToolTipText = "撤销" + ' + 'ToolStripSeparator13 + ' + Me.ToolStripSeparator13.Name = "ToolStripSeparator13" + Me.ToolStripSeparator13.Size = New System.Drawing.Size(6, 40) + ' 'tsBtnInsertRow ' Me.tsBtnInsertRow.Image = CType(resources.GetObject("tsBtnInsertRow.Image"), System.Drawing.Image) @@ -194,32 +250,6 @@ Namespace UTSModule.Station Me.tsBtnRemoveRow.Text = "移除行" Me.tsBtnRemoveRow.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText ' - 'ToolStripSeparator13 - ' - Me.ToolStripSeparator13.Name = "ToolStripSeparator13" - Me.ToolStripSeparator13.Size = New System.Drawing.Size(6, 40) - ' - 'TsBtnBackward - ' - Me.TsBtnBackward.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) - Me.TsBtnBackward.Image = CType(resources.GetObject("TsBtnBackward.Image"), System.Drawing.Image) - Me.TsBtnBackward.ImageTransparentColor = System.Drawing.Color.Magenta - Me.TsBtnBackward.Name = "TsBtnBackward" - Me.TsBtnBackward.Size = New System.Drawing.Size(59, 37) - Me.TsBtnBackward.Text = "向后导航" - Me.TsBtnBackward.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText - ' - 'TsBtnForward - ' - Me.TsBtnForward.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) - Me.TsBtnForward.Image = CType(resources.GetObject("TsBtnForward.Image"), System.Drawing.Image) - Me.TsBtnForward.ImageTransparentColor = System.Drawing.Color.Magenta - Me.TsBtnForward.Name = "TsBtnForward" - Me.TsBtnForward.Size = New System.Drawing.Size(59, 37) - Me.TsBtnForward.Text = "向前导航" - Me.TsBtnForward.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText - Me.TsBtnForward.ToolTipText = "向前导航" - ' 'ToolStripSeparator14 ' Me.ToolStripSeparator14.Name = "ToolStripSeparator14" @@ -421,9 +451,9 @@ Namespace UTSModule.Station ' 'CmsPlanGrid ' - Me.CmsPlanGrid.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MsiGridRowBlockInsert, Me.MsiGridRowBlockDelete, Me.ToolStripSeparator7, Me.tsBtn_CheckAction, Me.tsBtn_UncheckAction, Me.ToolStripSeparator15, Me.MsiUndo, Me.MsiRedo, Me.ToolStripSeparator6, Me.MsiSaveNodeFile, Me.MsiLoadNodeFile, Me.ToolStripSeparator11, Me.TsmiDebugStart, Me.TsmiDebugEnd, Me.TsmiDebugContinue, Me.TsmiDebugStep, Me.ToolStripSeparator8, Me.TsmiDebugSetup, Me.TsmiDebugMain, Me.TsmiDebugPass, Me.TsmiDebugFail, Me.TsmiDebugCleanup, Me.ToolStripSeparator9, Me.TsmiDebugNode, Me.TsmiDebugNodeBegin}) + Me.CmsPlanGrid.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MsiGridRowBlockInsert, Me.MsiGridRowBlockDelete, Me.ToolStripSeparator7, Me.tsBtn_CheckAction, Me.tsBtn_UncheckAction, Me.ToolStripSeparator15, Me.MsiUndo, Me.MsiRedo, Me.ToolStripSeparator6, Me.MsiSaveNodeFile, Me.MsiLoadNodeFile, Me.ToolStripSeparator11, Me.TsmiDebugStart, Me.TsmiDebugEnd, Me.TsmiDebugContinue, Me.TsmiDebugStep, Me.ToolStripSeparator8, Me.TsmiDebugSetup, Me.TsmiDebugMain, Me.TsmiDebugPass, Me.TsmiDebugFail, Me.TsmiDebugCleanup, Me.ToolStripSeparator9, Me.TsmiDebugNode, Me.TsmiDebugNodeBegin, Me.TsmiJumpCall}) Me.CmsPlanGrid.Name = "CmsMain" - Me.CmsPlanGrid.Size = New System.Drawing.Size(222, 458) + Me.CmsPlanGrid.Size = New System.Drawing.Size(222, 502) ' 'MsiGridRowBlockInsert ' @@ -431,7 +461,7 @@ Namespace UTSModule.Station Me.MsiGridRowBlockInsert.Name = "MsiGridRowBlockInsert" Me.MsiGridRowBlockInsert.ShortcutKeyDisplayString = "Ctr+I" Me.MsiGridRowBlockInsert.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.I), System.Windows.Forms.Keys) - Me.MsiGridRowBlockInsert.Size = New System.Drawing.Size(192, 22) + Me.MsiGridRowBlockInsert.Size = New System.Drawing.Size(221, 22) Me.MsiGridRowBlockInsert.Text = "插入" ' 'MsiGridRowBlockDelete @@ -440,75 +470,75 @@ Namespace UTSModule.Station Me.MsiGridRowBlockDelete.Name = "MsiGridRowBlockDelete" Me.MsiGridRowBlockDelete.ShortcutKeyDisplayString = "Ctr+D" Me.MsiGridRowBlockDelete.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D), System.Windows.Forms.Keys) - Me.MsiGridRowBlockDelete.Size = New System.Drawing.Size(192, 22) + Me.MsiGridRowBlockDelete.Size = New System.Drawing.Size(221, 22) Me.MsiGridRowBlockDelete.Text = "删除" ' 'ToolStripSeparator7 ' Me.ToolStripSeparator7.Name = "ToolStripSeparator7" - Me.ToolStripSeparator7.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator7.Size = New System.Drawing.Size(218, 6) ' 'tsBtn_CheckAction ' Me.tsBtn_CheckAction.Image = CType(resources.GetObject("tsBtn_CheckAction.Image"), System.Drawing.Image) Me.tsBtn_CheckAction.Name = "tsBtn_CheckAction" - Me.tsBtn_CheckAction.Size = New System.Drawing.Size(192, 22) + Me.tsBtn_CheckAction.Size = New System.Drawing.Size(221, 22) Me.tsBtn_CheckAction.Text = "勾选测试" ' 'tsBtn_UncheckAction ' Me.tsBtn_UncheckAction.Image = CType(resources.GetObject("tsBtn_UncheckAction.Image"), System.Drawing.Image) Me.tsBtn_UncheckAction.Name = "tsBtn_UncheckAction" - Me.tsBtn_UncheckAction.Size = New System.Drawing.Size(192, 22) + Me.tsBtn_UncheckAction.Size = New System.Drawing.Size(221, 22) Me.tsBtn_UncheckAction.Text = "取消勾选测试" ' 'ToolStripSeparator15 ' Me.ToolStripSeparator15.Name = "ToolStripSeparator15" - Me.ToolStripSeparator15.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator15.Size = New System.Drawing.Size(218, 6) ' 'MsiUndo ' - Me.MsiUndo.Enabled = False Me.MsiUndo.Name = "MsiUndo" - Me.MsiUndo.Size = New System.Drawing.Size(192, 22) + Me.MsiUndo.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys) + Me.MsiUndo.Size = New System.Drawing.Size(221, 22) Me.MsiUndo.Text = "撤销" ' 'MsiRedo ' - Me.MsiRedo.Enabled = False Me.MsiRedo.Name = "MsiRedo" - Me.MsiRedo.Size = New System.Drawing.Size(192, 22) + Me.MsiRedo.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Y), System.Windows.Forms.Keys) + Me.MsiRedo.Size = New System.Drawing.Size(221, 22) Me.MsiRedo.Text = "重做" ' 'ToolStripSeparator6 ' Me.ToolStripSeparator6.Name = "ToolStripSeparator6" - Me.ToolStripSeparator6.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator6.Size = New System.Drawing.Size(218, 6) ' 'MsiSaveNodeFile ' Me.MsiSaveNodeFile.Name = "MsiSaveNodeFile" - Me.MsiSaveNodeFile.Size = New System.Drawing.Size(192, 22) + Me.MsiSaveNodeFile.Size = New System.Drawing.Size(221, 22) Me.MsiSaveNodeFile.Text = "另存为节点文件" ' 'MsiLoadNodeFile ' Me.MsiLoadNodeFile.Name = "MsiLoadNodeFile" - Me.MsiLoadNodeFile.Size = New System.Drawing.Size(192, 22) + Me.MsiLoadNodeFile.Size = New System.Drawing.Size(221, 22) Me.MsiLoadNodeFile.Text = "加载节点文件" ' 'ToolStripSeparator11 ' Me.ToolStripSeparator11.Name = "ToolStripSeparator11" - Me.ToolStripSeparator11.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator11.Size = New System.Drawing.Size(218, 6) ' 'TsmiDebugStart ' Me.TsmiDebugStart.Image = CType(resources.GetObject("TsmiDebugStart.Image"), System.Drawing.Image) Me.TsmiDebugStart.Name = "TsmiDebugStart" Me.TsmiDebugStart.ShortcutKeys = System.Windows.Forms.Keys.F5 - Me.TsmiDebugStart.Size = New System.Drawing.Size(207, 22) + Me.TsmiDebugStart.Size = New System.Drawing.Size(221, 22) Me.TsmiDebugStart.Text = "开始执行" ' 'TsmiDebugEnd @@ -516,42 +546,42 @@ Namespace UTSModule.Station Me.TsmiDebugEnd.Image = CType(resources.GetObject("TsmiDebugEnd.Image"), System.Drawing.Image) Me.TsmiDebugEnd.Name = "TsmiDebugEnd" Me.TsmiDebugEnd.ShortcutKeys = CType((System.Windows.Forms.Keys.Shift Or System.Windows.Forms.Keys.F5), System.Windows.Forms.Keys) - Me.TsmiDebugEnd.Size = New System.Drawing.Size(207, 22) + Me.TsmiDebugEnd.Size = New System.Drawing.Size(221, 22) Me.TsmiDebugEnd.Text = "退出执行" ' - 'TsmiDebugStep - ' - Me.TsmiDebugStep.Image = CType(resources.GetObject("TsmiDebugStep.Image"), System.Drawing.Image) - Me.TsmiDebugStep.Name = "TsmiDebugStep" - Me.TsmiDebugStep.ShortcutKeys = System.Windows.Forms.Keys.F11 - Me.TsmiDebugStep.Size = New System.Drawing.Size(207, 22) - Me.TsmiDebugStep.Text = "单步执行" - ' 'TsmiDebugContinue ' Me.TsmiDebugContinue.Image = CType(resources.GetObject("TsmiDebugContinue.Image"), System.Drawing.Image) Me.TsmiDebugContinue.Name = "TsmiDebugContinue" Me.TsmiDebugContinue.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.F5), System.Windows.Forms.Keys) - Me.TsmiDebugContinue.Size = New System.Drawing.Size(207, 22) + Me.TsmiDebugContinue.Size = New System.Drawing.Size(221, 22) Me.TsmiDebugContinue.Text = "继续执行" ' + 'TsmiDebugStep + ' + Me.TsmiDebugStep.Image = CType(resources.GetObject("TsmiDebugStep.Image"), System.Drawing.Image) + Me.TsmiDebugStep.Name = "TsmiDebugStep" + Me.TsmiDebugStep.ShortcutKeys = System.Windows.Forms.Keys.F11 + Me.TsmiDebugStep.Size = New System.Drawing.Size(221, 22) + Me.TsmiDebugStep.Text = "单步执行" + ' 'ToolStripSeparator8 ' Me.ToolStripSeparator8.Name = "ToolStripSeparator8" - Me.ToolStripSeparator8.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator8.Size = New System.Drawing.Size(218, 6) ' 'TsmiDebugSetup ' Me.TsmiDebugSetup.Name = "TsmiDebugSetup" Me.TsmiDebugSetup.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.F1), System.Windows.Forms.Keys) - Me.TsmiDebugSetup.Size = New System.Drawing.Size(207, 22) + Me.TsmiDebugSetup.Size = New System.Drawing.Size(221, 22) Me.TsmiDebugSetup.Text = "Setup模块执行" ' 'TsmiDebugMain ' Me.TsmiDebugMain.Name = "TsmiDebugMain" Me.TsmiDebugMain.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.F2), System.Windows.Forms.Keys) - Me.TsmiDebugMain.Size = New System.Drawing.Size(207, 22) + Me.TsmiDebugMain.Size = New System.Drawing.Size(221, 22) Me.TsmiDebugMain.Text = "Main模块执行" ' 'TsmiDebugPass @@ -578,7 +608,7 @@ Namespace UTSModule.Station 'ToolStripSeparator9 ' Me.ToolStripSeparator9.Name = "ToolStripSeparator9" - Me.ToolStripSeparator9.Size = New System.Drawing.Size(189, 6) + Me.ToolStripSeparator9.Size = New System.Drawing.Size(218, 6) ' 'TsmiDebugNode ' @@ -646,59 +676,67 @@ Namespace UTSModule.Station Me.RtxColTip.Size = New System.Drawing.Size(296, 78) Me.RtxColTip.TabIndex = 0 Me.RtxColTip.Text = "" - ' - 'GrpOutputInfo - ' - Me.GrpOutputInfo.Controls.Add(Me.TabControl1) - Me.GrpOutputInfo.Dock = System.Windows.Forms.DockStyle.Fill - Me.GrpOutputInfo.Location = New System.Drawing.Point(0, 0) - Me.GrpOutputInfo.Name = "GrpOutputInfo" - Me.GrpOutputInfo.Size = New System.Drawing.Size(977, 166) - Me.GrpOutputInfo.TabIndex = 0 - Me.GrpOutputInfo.TabStop = false - Me.GrpOutputInfo.Text = "输出内容" - ' - 'TabControl1 - ' - Me.TabControl1.Controls.Add(Me.TpOutputInfo) - Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill - Me.TabControl1.Location = New System.Drawing.Point(3, 17) - Me.TabControl1.Name = "TabControl1" - Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New System.Drawing.Size(971, 146) - Me.TabControl1.TabIndex = 1 - ' - 'TpOutputInfo - ' - Me.TpOutputInfo.Controls.Add(Me.RtxOutputInfo) - Me.TpOutputInfo.Location = New System.Drawing.Point(4, 22) - Me.TpOutputInfo.Name = "TpOutputInfo" - Me.TpOutputInfo.Padding = New System.Windows.Forms.Padding(3) - Me.TpOutputInfo.Size = New System.Drawing.Size(963, 120) - Me.TpOutputInfo.TabIndex = 0 - Me.TpOutputInfo.Text = "输出信息" - Me.TpOutputInfo.UseVisualStyleBackColor = true - ' - 'RtxOutputInfo - ' - Me.RtxOutputInfo.BorderStyle = System.Windows.Forms.BorderStyle.None - Me.RtxOutputInfo.Dock = System.Windows.Forms.DockStyle.Fill - Me.RtxOutputInfo.Location = New System.Drawing.Point(3, 3) - Me.RtxOutputInfo.Name = "RtxOutputInfo" - Me.RtxOutputInfo.Size = New System.Drawing.Size(957, 114) - Me.RtxOutputInfo.TabIndex = 0 - Me.RtxOutputInfo.Text = "" - ' - 'FrmStationPlan - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 12!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(977, 580) - Me.Controls.Add(Me.SplStationPlan) - Me.Controls.Add(Me.StuMain) - Me.Controls.Add(Me.ToolStrip1) - Me.KeyPreview = true - Me.Name = "FrmStationPlan" + ' + 'GrpOutputInfo + ' + Me.GrpOutputInfo.Controls.Add(Me.TabControl1) + Me.GrpOutputInfo.Dock = System.Windows.Forms.DockStyle.Fill + Me.GrpOutputInfo.Location = New System.Drawing.Point(0, 0) + Me.GrpOutputInfo.Name = "GrpOutputInfo" + Me.GrpOutputInfo.Size = New System.Drawing.Size(977, 166) + Me.GrpOutputInfo.TabIndex = 0 + Me.GrpOutputInfo.TabStop = False + Me.GrpOutputInfo.Text = "输出内容" + ' + 'TabControl1 + ' + Me.TabControl1.Controls.Add(Me.TpOutputInfo) + Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill + Me.TabControl1.Location = New System.Drawing.Point(3, 17) + Me.TabControl1.Name = "TabControl1" + Me.TabControl1.SelectedIndex = 0 + Me.TabControl1.Size = New System.Drawing.Size(971, 146) + Me.TabControl1.TabIndex = 1 + ' + 'TpOutputInfo + ' + Me.TpOutputInfo.Controls.Add(Me.RtxOutputInfo) + Me.TpOutputInfo.Location = New System.Drawing.Point(4, 22) + Me.TpOutputInfo.Name = "TpOutputInfo" + Me.TpOutputInfo.Padding = New System.Windows.Forms.Padding(3) + Me.TpOutputInfo.Size = New System.Drawing.Size(963, 120) + Me.TpOutputInfo.TabIndex = 0 + Me.TpOutputInfo.Text = "输出信息" + Me.TpOutputInfo.UseVisualStyleBackColor = True + ' + 'RtxOutputInfo + ' + Me.RtxOutputInfo.BorderStyle = System.Windows.Forms.BorderStyle.None + Me.RtxOutputInfo.Dock = System.Windows.Forms.DockStyle.Fill + Me.RtxOutputInfo.Location = New System.Drawing.Point(3, 3) + Me.RtxOutputInfo.Name = "RtxOutputInfo" + Me.RtxOutputInfo.Size = New System.Drawing.Size(957, 114) + Me.RtxOutputInfo.TabIndex = 0 + Me.RtxOutputInfo.Text = "" + ' + 'TsmiJumpCall + ' + Me.TsmiJumpCall.Name = "TsmiJumpCall" + Me.TsmiJumpCall.ShortcutKeys = System.Windows.Forms.Keys.F12 + Me.TsmiJumpCall.Size = New System.Drawing.Size(221, 22) + Me.TsmiJumpCall.Text = "函数跳转" + Me.TsmiJumpCall.Visible = False + ' + 'FrmStationPlan + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(977, 580) + Me.Controls.Add(Me.SplStationPlan) + Me.Controls.Add(Me.StuMain) + Me.Controls.Add(Me.ToolStrip1) + Me.KeyPreview = True + Me.Name = "FrmStationPlan" Me.Text = "Form1" Me.ToolStrip1.ResumeLayout(false) Me.ToolStrip1.PerformLayout @@ -794,5 +832,9 @@ End Sub Friend WithEvents tsBtn_CheckAction As ToolStripMenuItem Friend WithEvents tsBtn_UncheckAction As ToolStripMenuItem Friend WithEvents ToolStripSeparator15 As ToolStripSeparator + Friend WithEvents ToolStripSeparator1 As ToolStripSeparator + Friend WithEvents TsBtnUndo As ToolStripButton + Friend WithEvents TsBtnRedo As ToolStripButton + Friend WithEvents TsmiJumpCall As ToolStripMenuItem End Class End Namespace \ No newline at end of file diff --git a/UTS_Core/UTSModule/Station/FrmStationPlan.resx b/UTS_Core/UTSModule/Station/FrmStationPlan.resx index f8397b5..4670ff4 100644 --- a/UTS_Core/UTSModule/Station/FrmStationPlan.resx +++ b/UTS_Core/UTSModule/Station/FrmStationPlan.resx @@ -170,26 +170,6 @@ UQwy2qIWr4A5OaxVi0fATrsJPfFVQR7m/pGA42eBmARc8yrgpMxj38aewhjuEbNg/LgMLUEfVe01jGmu 4CpO4hz7JfYUxrgFGzER09jXsacwxi34/WdggZgE7MwCMQk8aYbA8tHPYe5Hgfe35R2spYRwB61XwcSY NxMjAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADTSURBVDhPvVKrDoNAEOSX+gt1tfxBg6psUNjmFJKcQjY5 - gyQ5gyXBVDbBVFYgKitWVEzZ43qpoDwC6SSjZmc2uxlvMXRRQ+UVVNZRnjVEomHlceAL9OooEjUzwBrp - CTQtw0hOD/hsZaPhA/APYnrAZhegj1ZeDzLVYPJ/RCwRHIWhlX/CDbCZz6vvQHUD9IWgChoMYNGRNxvj - FVAlQWSEIBkOYLiB8CSNUeaEMCX4MWEbNaMBDnxv77N1WUMXbQttG7smzi2SxWpNDBY3cf+3JnreG12r - GpgvtOAmAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADdSURBVDhPY6AK2Hbwwv+1O0/9X7zh0P+Zy3b9nzBv8//e - 2ev/Q6UJg3W7Tv8HgS/f//1//PbP/0uPfv039Uwm3oD5a/ajaD5+6+d/p7B84g2YMG8j2EYQBmmcsXA1 - HE+es/x/19SF/5t6ZqEYyMLEgtsCkMbDN/7833bu5/+lB7/9n7T5E9hwkCZ0DNWCCkA2rjvx43/7sgf/ - S2fe/Z/ScwcjTFA0o8dCZesUsFdg3oJhqHJMgC0WIrKbcGtAB9hiAa+N6ABkALpzSTKAJgmJJAOQExIy - hkoPasDAAACBjwD6rwhXUgAAAABJRU5ErkJggg== @@ -213,6 +193,49 @@ MMZLXiK1d5zSLwohxBwZ+9IGEBc6sd6JjYXBNO8XOOfG9Kx3xF4GJIOF3hP7M6BGM6CXrgCi0aUzYIiW MOcgUa2BJcy3bb1DWg34RkafGwF2A+hlg/vnJThAGkAI0WDRU9HAV/6tHp9FdAB/QLi4qrG0hAAAAABJ RU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHJSURBVDhPvZHdK4NhGMb3pzAt4dgfIPmMosgBB8pHjnbA + kSMhijSa2pgJ89U23jEJExpmvhq2+ZoMxVZD78vYxjsue5+NMTVK+dV18jxdv7v7eXh/Rrt8BC7UkpVE + OWvCoHYdoeuf4cqRKCaNqGwY/p1Es2gN1YL4X14hGZmHzmBFcXX7zxLl3A4p6mwAtQuY7Qw6FTOgVhmo + l2mo9DT652iIJ25JQrUwg1ojEXA8PfvB3PvgcLmJIJKm0WskVxi+SuRqPbnsMzxDNMugnrpCzYAdIws3 + 5Pwz1TIXtBsMkoomwxJpYF9u70cPi2vag3PHHQ7sN5BPO0mplfKTmE/uUCpyIrFoCgkFY4jPGwpKuH29 + PvZjslBuQ5V0Hx2qcyJ4h3lgcXLphcFyDxm1DUFub1jAuH04PHNh59gBo/kCS1unaOgLfm/dqBtCqRMl + bTbkN+6RyKhNCLK7woLkrLJvqRHvEQEbWM9Fs7DYH7FoYqBZuUX3mBFxGeKvjxlJedMGEXye/J4u9Rr4 + aaLogsJaPTxPL5BPmNCj2YZsfJNM5spS5SpiU1uiCzKEusBrq0ji8xQQ5PQgLlMCfnp7oNyKmJTm6IJ/ + gsd7A8Wc0VfbPf1MAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACMSURBVDhPtZDRDYAgDET7wazu5AIOY/x2BX/dAHO2KNQW + MMZLXiK1d5zSLwohxBwZ+9IGEBc6sd6JjYXBNO8XOOfG9Kx3xF4GJIOF3hP7M6BGM6CXrgCi0aUzYIiW + MOcgUa2BJcy3bb1DWg34RkafGwF2A+hlg/vnJThAGkAI0WDRU9HAV/6tHp9FdAB/QLi4qrG0hAAAAABJ + RU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADTSURBVDhPvVKrDoNAEOSX+gt1tfxBg6psUNjmFJKcQjY5 + gyQ5gyXBVDbBVFYgKitWVEzZ43qpoDwC6SSjZmc2uxlvMXRRQ+UVVNZRnjVEomHlceAL9OooEjUzwBrp + CTQtw0hOD/hsZaPhA/APYnrAZhegj1ZeDzLVYPJ/RCwRHIWhlX/CDbCZz6vvQHUD9IWgChoMYNGRNxvj + FVAlQWSEIBkOYLiB8CSNUeaEMCX4MWEbNaMBDnxv77N1WUMXbQttG7smzi2SxWpNDBY3cf+3JnreG12r + GpgvtOAmAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADdSURBVDhPY6AK2Hbwwv+1O0/9X7zh0P+Zy3b9nzBv8//e + 2ev/Q6UJg3W7Tv8HgS/f//1//PbP/0uPfv039Uwm3oD5a/ajaD5+6+d/p7B84g2YMG8j2EYQBmmcsXA1 + HE+es/x/19SF/5t6ZqEYyMLEgtsCkMbDN/7833bu5/+lB7/9n7T5E9hwkCZ0DNWCCkA2rjvx43/7sgf/ + S2fe/Z/ScwcjTFA0o8dCZesUsFdg3oJhqHJMgC0WIrKbcGtAB9hiAa+N6ABkALpzSTKAJgmJJAOQExIy + hkoPasDAAACBjwD6rwhXUgAAAABJRU5ErkJggg== diff --git a/UTS_Core/UTSModule/Station/FrmStationPlan.vb b/UTS_Core/UTSModule/Station/FrmStationPlan.vb index c587509..1b01e6f 100644 --- a/UTS_Core/UTSModule/Station/FrmStationPlan.vb +++ b/UTS_Core/UTSModule/Station/FrmStationPlan.vb @@ -60,7 +60,7 @@ Namespace UTSModule.Station If StationPlan IsNot Nothing Then _planGrid.HeadNode = StationPlan.HeadNode _planGrid.UpdateGrid() - _planGrid.GridUpdateEventTrigger(GrdStationPlan) '笨方法,开始就触发一次刷新 + StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.None _tester.ProcessStation = _utsApp.ProcessStation @@ -94,6 +94,9 @@ Namespace UTSModule.Station .RtxColTip = RtxColTip} AddHandler _planGrid.PlanNodeSelectChanged, AddressOf PlanGridSelectChanged + AddHandler _planGrid.PlanGridCommandChanged, AddressOf PlanGridCommandChanged + 'todo:检测撤销队列的变化 + AddHandler _planGrid.PlanNodeSelectChanged, AddressOf _nodeGrid.Grid_PlanNodeSelectChanged AddHandler _planGrid.RowNodeTextChanged, AddressOf _nodeGrid.Grid_RowNodeTextChanged @@ -117,6 +120,15 @@ Namespace UTSModule.Station TsBtnForward.Enabled = _planGrid.CanForward End Sub + Public Sub PlanGridCommandChanged(sender As Object, e As EventArgs) + TsBtnUndo.Enabled = _planGrid.CanUndo + TsBtnRedo.Enabled = _planGrid.CanRedo + + MsiUndo.Enabled = _planGrid.CanUndo + MsiRedo.Enabled = _planGrid.CanRedo + End Sub + + Private Function InitializeUtsApp() As Boolean _utsApp = UtsAppForm.CreateSingleton() _utsApp.AddStatisticsObserver(Me) @@ -206,7 +218,7 @@ Namespace UTSModule.Station Try StationPlan.LoadFile(revStationPlanPath) _planGrid.UpdateGrid() - _planGrid.GridUpdateEventTrigger(GrdStationPlan) '笨方法,开始就触发一次刷新 + ' _planGrid.GridUpdateEventTrigger(GrdStationPlan) '笨方法,开始就触发一次刷新 StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.None If StationEditStatusMonitor.StationEditStatus <> StationEditStatusMonitor.StationEditStatusEnum.Saved Then @@ -226,7 +238,7 @@ Namespace UTSModule.Station Try StationPlan.LoadFile(revStationPlanPath) _planGrid.UpdateGrid() - _planGrid.GridUpdateEventTrigger(GrdStationPlan) '笨方法,开始就触发一次刷新 + StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.None If StationEditStatusMonitor.StationEditStatus <> StationEditStatusMonitor.StationEditStatusEnum.Saved Then @@ -300,8 +312,10 @@ Namespace UTSModule.Station End Using _planGrid.ClearNavigation() - TsBtnBackward.Enabled = _planGrid.CanBackward - TsBtnForward.Enabled = _planGrid.CanForward + _planGrid.ClearCommand() + + PlanGridSelectChanged(Nothing, Nothing) + PlanGridCommandChanged(Nothing, Nothing) End Sub Private Sub TsBtnLoad_Click(sender As Object, e As EventArgs) Handles TsBtnLoad.Click @@ -309,8 +323,10 @@ Namespace UTSModule.Station ApplicationLog.WriteInfoLog($"编辑页面执行流程重载中。") LoadTreeViewFormXml() _planGrid.ClearNavigation() - TsBtnBackward.Enabled = _planGrid.CanBackward - TsBtnForward.Enabled = _planGrid.CanForward + _planGrid.ClearCommand() + PlanGridSelectChanged(Nothing, Nothing) + PlanGridCommandChanged(Nothing, Nothing) + ApplicationLog.WriteInfoLog($"编辑页面执行流程重载完成。") End If End Sub @@ -802,6 +818,18 @@ Namespace UTSModule.Station _planGrid.Check_Uncheck_Action(GrdStationPlan, tmpFrisRow, tmpLastRow, False) End Sub + Private Sub MsiUndo_Click(sender As Object, e As EventArgs) Handles MsiUndo.Click, TsBtnUndo.Click + _planGrid.UndoCommand() + End Sub + + Private Sub MsiRedo_Click(sender As Object, e As EventArgs) Handles MsiRedo.Click, TsBtnRedo.Click + _planGrid.RedoCommand() + End Sub + + Private Sub TsmiJumpCall_Click(sender As Object, e As EventArgs) Handles TsmiJumpCall.Click + _planGrid.JumpCall() + End Sub + #End Region diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/CommandManager.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/CommandManager.vb new file mode 100644 index 0000000..3577715 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/CommandManager.vb @@ -0,0 +1,94 @@ +Public Module CommandManager + Private Property UndoCommands As New Stack(Of ICommand) + + Private Property RedoCommands As New Stack(Of ICommand) + + Private _isRunning As Boolean = False + + ''' + ''' 运行命令,并将命令添加至撤销堆栈 + ''' + ''' + Public Sub RunCommand(command As ICommand) + command.Redo() + + AddUndoCommand(command) + End Sub + + + Public ReadOnly Property IsRuning() As Boolean + Get + Return _isRunning + End Get + End Property + + Public Function CanUndo() As Boolean + Return UndoCommands.Count > 0 + End Function + + Public Function CanRedo() As Boolean + Return RedoCommands.Count > 0 + End Function + + ''' + ''' 将命令添加至撤销堆栈 + ''' + Public Sub AddUndoCommand(command As ICommand) + UndoCommands.Push(command) + + If RedoCommands.Count > 0 Then + ClearRedoCommands() + End If + End Sub + + ''' + ''' 清空撤销命令堆栈 + ''' + Public Sub ClearUndoCommands() + UndoCommands.Clear() + + End Sub + + ''' + ''' 清空重做命令堆栈 + ''' + Public Sub ClearRedoCommands() + RedoCommands.Clear() + End Sub + + ''' + ''' 清空撤销与重做命令堆栈 + ''' + Public Sub ClearCommands() + ClearUndoCommands() + ClearRedoCommands() + End Sub + + ''' + ''' 执行撤销命令 + ''' + Public Sub Undo() + If UndoCommands.Count <= 0 Then Return + _isRunning = True + Dim command As ICommand = UndoCommands.Pop() + command.Undo() + RedoCommands.Push(command) + _isRunning = False + End Sub + + + ''' + ''' 执行重做命令 + ''' + Public Sub Redo() + If RedoCommands.Count <= 0 Then Return + _isRunning = True + + Dim command As ICommand = RedoCommands.Pop() + command.Redo() + + UndoCommands.Push(command) + _isRunning = False + End Sub + +End Module diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeAddCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeAddCommand.vb new file mode 100644 index 0000000..91880fc --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeAddCommand.vb @@ -0,0 +1,22 @@ +Imports UTS_Core.UTSModule.Station + +Public Class GridNodeAddCommand : Implements ICommand + + Private ReadOnly grd As StationPlanGrid + Private ReadOnly startMoveRow As Integer + Private ReadOnly moveRows As Integer + + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer) + Me.grd = grd + Me.startMoveRow = startMoveRow + Me.moveRows = moveRows + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.NodeAddCommand(startMoveRow, moveRows) + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.NodeDeleteCommand(startMoveRow, moveRows) + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCopyPasteCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCopyPasteCommand.vb new file mode 100644 index 0000000..e5636b2 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCopyPasteCommand.vb @@ -0,0 +1,12 @@ +Public Class GridNodeCopyPasteCommand : Implements ICommand + Public Sub New() + End Sub + + Public Sub Redo() Implements ICommand.Redo + Throw New NotImplementedException() + End Sub + + Public Sub Undo() Implements ICommand.Undo + Throw New NotImplementedException() + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCutPasteCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCutPasteCommand.vb new file mode 100644 index 0000000..1395316 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeCutPasteCommand.vb @@ -0,0 +1,10 @@ +Public Class GridNodeCutPasteCommand : Implements ICommand + + Public Sub Redo() Implements ICommand.Redo + Throw New NotImplementedException() + End Sub + + Public Sub Undo() Implements ICommand.Undo + Throw New NotImplementedException() + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeDeleteCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeDeleteCommand.vb new file mode 100644 index 0000000..c6ca3ed --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeDeleteCommand.vb @@ -0,0 +1,23 @@ +Imports UTS_Core.UTSModule.Station + +Public Class GridNodeDeleteCommand : Implements ICommand + Private ReadOnly grd As StationPlanGrid + Private ReadOnly startMoveRow As Integer + Private ReadOnly moveRows As Integer + Private ReadOnly nodes As List(Of RowNode) + + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer, nodes As List(Of RowNode)) + Me.grd = grd + Me.startMoveRow = startMoveRow + Me.moveRows = moveRows + Me.nodes = nodes + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.NodeDeleteCommand(startMoveRow, moveRows) + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.NodeAddCommand(startMoveRow, moveRows, nodes) + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveDownCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveDownCommand.vb new file mode 100644 index 0000000..fb6be0d --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveDownCommand.vb @@ -0,0 +1,23 @@ +Imports UTS_Core.UTSModule.Station + +Public Class GridNodeMoveDownCommand : Implements ICommand + Private ReadOnly grd As StationPlanGrid + Private ReadOnly startMoveRow As Integer + Private ReadOnly moveRows As Integer + Private ReadOnly moveEndRow As Integer + + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer, moveEndRow As Integer) + Me.grd = grd + Me.startMoveRow = startMoveRow + Me.moveRows = moveRows + Me.moveEndRow = moveEndRow + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.NodeMoveDownCommand(startMoveRow, moveRows) + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.NodeMoveUpCommand(moveEndRow, moveRows) + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveLeftCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveLeftCommand.vb new file mode 100644 index 0000000..8b30657 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveLeftCommand.vb @@ -0,0 +1,25 @@ +Imports UTS_Core.UTSModule.Station + +Public Class GridNodeMoveLeftCommand : Implements ICommand + Private ReadOnly grd As StationPlanGrid + Private ReadOnly startMoveRow As Integer + Private ReadOnly moveRows As Integer + Private ReadOnly moveEndRow As Integer + Private ReadOnly moveRightNodeIndex As Integer + + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer, moveEndRow As Integer, moveRightNodeIndex As Integer) + Me.grd = grd + Me.startMoveRow = startMoveRow + Me.moveRows = moveRows + Me.moveEndRow = moveEndRow + Me.moveRightNodeIndex = moveRightNodeIndex + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.NodeMoveLeftCommand(startMoveRow, moveRows) + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.NodeMoveRightCommand(moveEndRow, moveRows, moveRightNodeIndex) + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveRightCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveRightCommand.vb new file mode 100644 index 0000000..84db681 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveRightCommand.vb @@ -0,0 +1,25 @@ +Imports UTS_Core.UTSModule.Station + +Public Class GridNodeMoveRightCommand : Implements ICommand + Private ReadOnly grd As StationPlanGrid + Private ReadOnly startMoveRow As Integer + Private ReadOnly moveRows As Integer + Private ReadOnly moveEndRow As Integer + Private ReadOnly moveRightNodeIndex As Integer + + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer, moveEndRow As Integer, moveRightNodeIndex As Integer) + Me.grd = grd + Me.startMoveRow = startMoveRow + Me.moveRows = moveRows + Me.moveEndRow = moveEndRow + Me.moveRightNodeIndex = moveRightNodeIndex + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.NodeMoveRightCommand(startMoveRow, moveRows, moveRightNodeIndex) + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.NodeMoveLeftCommand(moveEndRow, moveRows) + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeMoveUpCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveUpCommand.vb similarity index 62% rename from UTS_Core/UTSModule/Station/GridNodeMoveUpCommand.vb rename to UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveUpCommand.vb index d377db5..af04ea5 100644 --- a/UTS_Core/UTSModule/Station/GridNodeMoveUpCommand.vb +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeMoveUpCommand.vb @@ -1,28 +1,25 @@ -Imports UTS_Core.Undo -Imports UTS_Core.UTSModule.Station +Imports UTS_Core.UTSModule.Station + Public Class GridNodeMoveUpCommand : Implements ICommand Private ReadOnly grd As StationPlanGrid Private ReadOnly startMoveRow As Integer Private ReadOnly moveRows As Integer + Private ReadOnly moveEndRow As Integer - Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer) + Sub New(grd As StationPlanGrid, startMoveRow As Integer, moveRows As Integer, moveEndRow As Integer) Me.grd = grd Me.startMoveRow = startMoveRow Me.moveRows = moveRows - End Sub - - - Public Sub Execute() Implements ICommand.Execute - grd.NodeMoveUp(startMoveRow, moveRows) + Me.moveEndRow = moveEndRow End Sub Public Sub Redo() Implements ICommand.Redo - grd.NodeMoveUp(startMoveRow, moveRows) + grd.NodeMoveUpCommand(startMoveRow, moveRows) End Sub Public Sub Undo() Implements ICommand.Undo - grd.NodeMoveDown(startMoveRow, moveRows) + grd.NodeMoveDownCommand(moveEndRow, moveRows) End Sub End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeTextChangedCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeTextChangedCommand.vb new file mode 100644 index 0000000..92270c0 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridNodeTextChangedCommand.vb @@ -0,0 +1,24 @@ +Public Class GridNodeTextChangedCommand : Implements ICommand + + Private ReadOnly grd As FlexCell.Grid + Private ReadOnly row As Integer + Private ReadOnly col As Integer + Private ReadOnly beforeText As String + Private ReadOnly afterText As String + + Sub New(grd As FlexCell.Grid, row As Integer, col As Integer, beforeText As String, afterText As String) + Me.grd = grd + Me.row = row + Me.col = col + Me.beforeText = beforeText + Me.afterText = afterText + End Sub + + Public Sub Redo() Implements ICommand.Redo + grd.Cell(row, col).Text = afterText + End Sub + + Public Sub Undo() Implements ICommand.Undo + grd.Cell(row, col).Text = beforeText + End Sub +End Class diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/ICommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/ICommand.vb new file mode 100644 index 0000000..794f1da --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/ICommand.vb @@ -0,0 +1,11 @@ +Public Interface ICommand + ''' + ''' 重做命令 + ''' + Sub Redo() + + ''' + ''' 撤销命令 + ''' + Sub Undo() +End Interface \ No newline at end of file diff --git a/UTS_Core/UTSModule/Station/GridNavigation.vb b/UTS_Core/UTSModule/Station/GridNodeNavigation/GridNavigation.vb similarity index 100% rename from UTS_Core/UTSModule/Station/GridNavigation.vb rename to UTS_Core/UTSModule/Station/GridNodeNavigation/GridNavigation.vb diff --git a/UTS_Core/UTSModule/Station/GridNavigationManager.vb b/UTS_Core/UTSModule/Station/GridNodeNavigation/GridNavigationManager.vb similarity index 100% rename from UTS_Core/UTSModule/Station/GridNavigationManager.vb rename to UTS_Core/UTSModule/Station/GridNodeNavigation/GridNavigationManager.vb diff --git a/UTS_Core/UTSModule/Station/INavigation.vb b/UTS_Core/UTSModule/Station/GridNodeNavigation/INavigation.vb similarity index 100% rename from UTS_Core/UTSModule/Station/INavigation.vb rename to UTS_Core/UTSModule/Station/GridNodeNavigation/INavigation.vb diff --git a/UTS_Core/UTSModule/Station/RowNodeCommand.vb b/UTS_Core/UTSModule/Station/RowNodeCommand.vb deleted file mode 100644 index d427f55..0000000 --- a/UTS_Core/UTSModule/Station/RowNodeCommand.vb +++ /dev/null @@ -1,136 +0,0 @@ -Imports UTS_Core.Undo - -Namespace UTSModule.Station - Public Class RowNodeCommand - Implements ICommand - - Private ReadOnly _row As Integer - Private ReadOnly _rowNode As RowNode - - - Sub New(rowNode As RowNode, row As Integer, redoString As String) - _row = row - _rowNode = rowNode - - End Sub - - Public Sub Redo() Implements ICommand.Redo - - End Sub - - Public Sub Undo() Implements ICommand.Undo - - End Sub - - Public Sub Execute() Implements ICommand.Execute - Redo() - End Sub - End Class - - - Public Class RowNodeCommand2 - Implements ICommand - - Enum ChangeType - Add - Remove - Insert - RemoveChildAt - RemoveChildNode - MoveUp - MoveDown - MoveLeft - MoveRight - TextChanged - End Enum - - Private _parentNode As RowNode - Private _rowNode As RowNode - Private _index As Integer '增加节点的位置 - Private _type As ChangeType '当前操作的类型 - - Sub New(parentNode As RowNode, rowNode As RowNode, type As ChangeType, Optional index As Integer = 0) - _parentNode = parentNode - _rowNode = rowNode - _index = index - _type = type - End Sub - - Public Sub Execute() Implements ICommand.Execute - Redo() - End Sub - - Public Sub Redo() Implements ICommand.Redo - Select Case _type - Case ChangeType.Add - _parentNode.AddNode(_rowNode) - _index = _rowNode.RowIndex - - Case ChangeType.Insert - _parentNode.InsertNode(_index, _rowNode) - - Case ChangeType.Remove - _index = _rowNode.RowIndex - _parentNode.RemoveChildNode(_rowNode) - - Case ChangeType.RemoveChildAt - _index = _rowNode.RowIndex - _parentNode.RemoveChildAt(_index) - - Case ChangeType.RemoveChildNode - _index = _rowNode.RowIndex - _parentNode.RemoveChildNode(_rowNode) - - - Case ChangeType.MoveUp - _rowNode.MoveUp() - - Case ChangeType.MoveDown - _rowNode.MoveDown() - - Case ChangeType.MoveLeft - _rowNode.MoveLeft() - - Case ChangeType.MoveRight - _rowNode.MoveRight() - - Case ChangeType.TextChanged - - End Select - End Sub - - Public Sub Undo() Implements ICommand.Undo - Select Case _type - Case ChangeType.Add - _parentNode.RemoveChildNode(_rowNode) - - Case ChangeType.Insert - _parentNode.RemoveChildAt(_index) - - Case ChangeType.Remove - _parentNode.InsertNode(_index, _rowNode) - - Case ChangeType.RemoveChildAt - _parentNode.InsertNode(_index, _rowNode) - - Case ChangeType.RemoveChildNode - _parentNode.InsertNode(_index, _rowNode) - - Case ChangeType.MoveUp - _rowNode.MoveDown() - - Case ChangeType.MoveDown - _rowNode.MoveUp() - - Case ChangeType.MoveLeft - _rowNode.MoveRight() - - Case ChangeType.MoveRight - _rowNode.MoveLeft() - - Case ChangeType.TextChanged - - End Select - End Sub - End Class -End Namespace \ No newline at end of file diff --git a/UTS_Core/UTSModule/Station/RowNodeGrid.vb b/UTS_Core/UTSModule/Station/RowNodeGrid.vb index b98dfdd..14d02b4 100644 --- a/UTS_Core/UTSModule/Station/RowNodeGrid.vb +++ b/UTS_Core/UTSModule/Station/RowNodeGrid.vb @@ -38,6 +38,7 @@ Namespace UTSModule.Station Public Event RowNodeTextChanged(ByVal sender As Object, ByVal e As RowNodeChangedEventArgs) '自定义事件 + Public Sub New() _errCodeManager = ErrCodeManager.CreateManager() _testCmdManager = TestCmdManager.CreateManager() diff --git a/UTS_Core/UTSModule/Station/StationPlanGrid.vb b/UTS_Core/UTSModule/Station/StationPlanGrid.vb index 83b99cf..186736c 100644 --- a/UTS_Core/UTSModule/Station/StationPlanGrid.vb +++ b/UTS_Core/UTSModule/Station/StationPlanGrid.vb @@ -1,49 +1,30 @@ -Imports System.Drawing -Imports System.Reflection.Emit -Imports System.Text -Imports System.Web.UI.WebControls +Imports System.Diagnostics.Eventing.Reader +Imports System.Drawing Imports System.Windows.Forms Imports FlexCell -Imports Steema.TeeChart.Walls +Imports FluentFTP Imports UTS_Core.UTSModule.Production Imports UTS_Core.UTSModule.Test.Command Imports UTS_Core.UTSModule.Test.StatusMonitor Namespace UTSModule.Station Public Class StationPlanGrid - - 'ActionEn属性:注意这个属性不仅仅由Action列决定,还由他的父节点的Action属性决定 - 'ActionEn属性是隐性的,表格中看不到,表格中只能看到本行的Action值 - '每一行的ActionEn属性由它本身的Action和往祖辈方向溯源的所有级的ActionEn值决定 - '只有Level=1的Module节点,ActionEn属性等于其Action值,因为在往上溯源就是FixModule,而FixModule是肯定为True的 - 'ActionEn属性为False时,该行为灰色 - Public Structure RowNodeInfo '用于保存每一行的关键信息 - Dim RowIdx As Integer '表格行号’ - Dim NodeType As Integer - Dim NodeLevel As Integer - Dim NodeIdx As Integer '同级节点顺序’ - Dim ActionVal As Boolean 'Action框勾选值 - Dim ActionEn As Boolean 'ActionEn,由自身的Action值和父节点的Action值共同决定 - Dim CmdType As String '命令类型’ - Dim TextColor As Color '文本颜色 - Dim FatherNodeIdxLst As List(Of Integer) '保存父级节点的行号 - Dim IsRecord As Boolean '是否保存 - Dim Description As String - Dim RecordName As String - End Structure - - + ''' 表格控件对象 Private _grd As Grid - Private _cms As ContextMenuStrip - - Private _drawCol As Integer - - Private _drawStartRow As Integer - - Private _debugMode As Boolean + ''' 表格树状目录起始节点 Private _headNode As RowNode + ''' 起始绘制列 + Private _drawCol As Integer + + ''' 起始绘制行 + Private _drawStartRow As Integer + + ''' 调试模式是否开启 + Private _debugMode As Boolean + + ''' 是否显示节点图标 Private ReadOnly _showNodeIcon As Boolean ''' 处于更新表格状态中,不触发表格单元格修改事件 @@ -52,6 +33,25 @@ Namespace UTSModule.Station ''' 多个参数间的分割符号 Private ReadOnly _paramChar As Char + ''' 测试命令管理器 + Private ReadOnly _testCmdManager As TestCmdManager + + ''' 错误代码管理器 + Private ReadOnly _errCodeManager As ErrCodeManager + + ''' 表格标签字段字典 + Private ReadOnly _labelNames As New Dictionary(Of String, Integer) + + ''' 表格记录名称字段字典 + Private ReadOnly _recordNames As New Dictionary(Of String, Integer) + + Private gMouseOldRow As Integer '记录鼠标移动前的行号 + Private gMouseOldCol As Integer + Private gOldRowType As Integer + Private gRowType As Integer + Private gDescTextColor As Brush 'description cell 文字颜色 + Private gIsGri_MouseMove_EventReady As Boolean = True 'MoveMove 函数加锁,防止嵌套执行 + ''' 当前活动节点 Public ActiveNode As RowNode @@ -61,22 +61,9 @@ Namespace UTSModule.Station ''' 节点文本被修改事件 Public Event RowNodeTextChanged(ByVal sender As Object, ByVal e As RowNodeChangedEventArgs) - ''' 测试命令管理器 - Private ReadOnly _testCmdManager As TestCmdManager + ''' 节点执行可撤销事件 + Public Event PlanGridCommandChanged(ByVal sender As Object, ByVal e As EventArgs) - ''' 错误代码管理器 - Private ReadOnly _errCodeManager As ErrCodeManager - - Private gMouseOldRow As Integer '记录鼠标移动前的行号 - Private gMouseOldCol As Integer - Private gOldRowType As Integer - Private gRowType As Integer - Private gDescTextColor As Brush 'description cell 文字颜色 - - Public gRowNodeInfo() As RowNodeInfo '用于保存每一行的关键信息,如有修改,使用前调用UpdateGridActionInfo刷新一次 - - Private gIsGri_UpdateGridActionInfo_EventReady As Boolean = True 'UpdateGridActionInfo 函数加锁,防止嵌套执行 - Private gIsGri_MouseMove_EventReady As Boolean = True 'MoveMove 函数加锁,防止嵌套执行 Sub New() @@ -118,28 +105,23 @@ Namespace UTSModule.Station InitializeGrid() - ' RemoveHandler _grd.OwnerDrawCell, AddressOf Grid_OwnerDrawCell - RemoveHandler _grd.Click, AddressOf Grid_Click + 'RemoveHandler _grd.Click, AddressOf Grid_Click RemoveHandler _grd.CellChange, AddressOf Grid_CellChange RemoveHandler _grd.SelChange, AddressOf Grid_SelChange RemoveHandler _grd.LeaveCell, AddressOf Grid_LeaveCell RemoveHandler _grd.ComboDropDown, AddressOf Grid_ComboDropDown RemoveHandler _grd.ComboClick, AddressOf Grid_ComboClick RemoveHandler _grd.MouseMove, AddressOf Grid_MouseMove - RemoveHandler _grd.EnterRow, AddressOf Grid_EnterRow RemoveHandler _grd.MouseLeave, AddressOf Grid_MouseLeave RemoveHandler _grd.MouseEnter, AddressOf Grid_MouseEnter - - ' AddHandler _grd.OwnerDrawCell, AddressOf Grid_OwnerDrawCell - AddHandler _grd.Click, AddressOf Grid_Click + 'AddHandler _grd.Click, AddressOf Grid_Click AddHandler _grd.CellChange, AddressOf Grid_CellChange AddHandler _grd.SelChange, AddressOf Grid_SelChange AddHandler _grd.LeaveCell, AddressOf Grid_LeaveCell AddHandler _grd.ComboDropDown, AddressOf Grid_ComboDropDown AddHandler _grd.ComboClick, AddressOf Grid_ComboClick AddHandler _grd.MouseMove, AddressOf Grid_MouseMove - AddHandler _grd.EnterRow, AddressOf Grid_EnterRow AddHandler _grd.MouseLeave, AddressOf Grid_MouseLeave AddHandler _grd.MouseEnter, AddressOf Grid_MouseEnter @@ -151,15 +133,6 @@ Namespace UTSModule.Station End Set End Property - ''' - ''' 对第二行的Action执行一遍操作,以触发更新事件 - ''' - Public Sub GridUpdateEventTrigger(grd As Grid) - Dim tmpCheckValue As Boolean = grd.Cell(2, ColNames.Action).BooleanValue - grd.Cell(2, ColNames.Action).Text = (Not tmpCheckValue).ToString - grd.Cell(2, ColNames.Action).Text = (tmpCheckValue).ToString - End Sub - Private _autoRedraw As Integer = 0 Private Sub LockGridAutoRedraw() @@ -177,7 +150,7 @@ Namespace UTSModule.Station End If End Sub - +#Region "导航功能" ''' ''' 向后导航 ''' @@ -219,6 +192,194 @@ Namespace UTSModule.Station _lastTempSelction = Nothing End Sub + Public Sub JumpCall() + If _grd.ActiveCell Is Nothing Then Return + Dim row As Integer = _grd.ActiveCell.Row + Dim node As RowNode = _headNode.RowList(row - _drawStartRow + 1) + If node.CommandType = "System" AndAlso node.Command = "Call" Then + Dim labelName As String = node.Parameters(0).Value + If String.IsNullOrWhiteSpace(labelName) Then + MsgBox("请填写有效的模块名!") + Else + If IsExistLabelName(labelName) Then + Dim destRow As Integer = GetLabelNameGridRow(labelName) + _grd.Cell(destRow, ColNames.Label).SetFocus() + Else + MsgBox($"未发现当前模块名[{labelName}]匹配的模块!") + End If + End If + End If + End Sub +#End Region + + +#Region "撤销功能" + Public Sub ClearCommand() + CommandManager.ClearCommands() + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + End Sub + + Public Function CanUndo() As Boolean + Return CommandManager.CanUndo + End Function + + Public Function CanRedo() As Boolean + Return CommandManager.CanRedo + End Function + + Public Sub UndoCommand() + If CommandManager.CanUndo Then + CommandManager.Undo() + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + End If + End Sub + + Public Sub RedoCommand() + If CommandManager.CanRedo Then + CommandManager.Redo() + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + End If + End Sub +#End Region + +#Region "字段去重" + ''' + ''' 当前模块名是否已存在 + ''' + ''' + ''' + Public Function IsExistLabelName(labelName As String) As Boolean + labelName = labelName.ToLower() + Return _labelNames.ContainsKey(labelName) + End Function + + ''' + ''' 当前字段名 + ''' + ''' + ''' + Public Function IsExistRecordName(recordName As String) As Boolean + recordName = recordName.ToLower() + + Return _recordNames.ContainsKey(recordName) + End Function + + ''' + ''' 清空标签名称 + ''' + Private Sub ClearLabelNames() + _labelNames.Clear() + End Sub + + ''' + ''' 清空记录名称 + ''' + Private Sub ClearRecordNames() + _recordNames.Clear() + End Sub + + ''' + ''' 添加标签名称 + ''' + ''' 标签名称 + ''' 行号 + Private Sub AddLabelName(labelName As String, row As Integer) + labelName = labelName.ToLower() + If Not _labelNames.ContainsKey(labelName) Then + _labelNames.Add(labelName, row) + End If + End Sub + + ''' + ''' 添加记录名称 + ''' + ''' 记录名 + ''' 行号 + Private Sub AddRecordName(recordName As String, row As Integer) + recordName = recordName.ToLower() + + If Not _recordNames.ContainsKey(recordName) Then + _recordNames.Add(recordName, row) + End If + End Sub + + ''' + ''' 移出标签名称 + ''' + ''' 标签名称 + Private Sub RemoveLabelName(labelName As String) + labelName = labelName.ToLower() + + If _labelNames.ContainsKey(labelName) Then + _labelNames.Remove(labelName) + End If + End Sub + + ''' + ''' 移出记录名称 + ''' + ''' 记录名称 + Private Sub RemoveRecordName(recordName As String) + recordName = recordName.ToLower() + + If _recordNames.ContainsKey(recordName) Then + _recordNames.Remove(recordName) + End If + End Sub + + ''' + ''' 获取标签名称行号 + ''' + ''' + ''' + Private Function GetLabelNameGridRow(labelName As String) As Integer + labelName = labelName.ToLower() + + Return _labelNames(labelName) + End Function + + ''' + ''' 获取记录名称行号 + ''' + ''' + ''' + Private Function GetRecordNameGridRow(recordName As String) As Integer + recordName = recordName.ToLower() + + Return _recordNames(recordName) + End Function + + ''' + ''' 从表格中重载标签名称 + ''' + Private Sub ReflushLabelNames() + ClearLabelNames() + If _headNode Is Nothing Then Return + For Each node As RowNode In _headNode.RowList + If node.RowType = RowNode.RowTypeEnum.Module OrElse node.RowType = RowNode.RowTypeEnum.FixedModule Then + If Not String.IsNullOrWhiteSpace(node.Label) AndAlso Not IsExistLabelName(node.Label) Then + AddLabelName(node.Label, node.RowListIndex) + End If + End If + Next + End Sub + + + ''' + ''' 从表格中重载记录名称 + ''' + Private Sub ReflushRecordNames() + ClearRecordNames() + If _headNode Is Nothing Then Return + For Each node As RowNode In _headNode.RowList + If Not String.IsNullOrWhiteSpace(node.RecordName) AndAlso Not IsExistRecordName(node.RecordName) Then + AddRecordName(node.RecordName, node.RowListIndex) + End If + Next + End Sub + +#End Region + '离开表格时活动单元格背景颜色 Private leaveColor As Color = Color.White @@ -254,37 +415,6 @@ Namespace UTSModule.Station End Sub - ''' - ''' 根据CmdType 和 isAction 返回该行字体颜色 - ''' - ''' - Public Function setRowTextForeColor(rowCmdType As String, isAction As Boolean, Optional rowNodeType As RowNode.RowTypeEnum = RowNode.RowTypeEnum.Flow) As Color - If isAction = True Then - If rowNodeType = RowNode.RowTypeEnum.Flow Then - Select Case rowCmdType - Case "System" - Return Color.DarkSlateGray - Case "ComPort" - Return Color.DarkCyan - Case "UtsComPort" - Return Color.SeaGreen - Case "Converter" - Return Color.DarkOrange - Case "Process" - Return Color.DarkBlue - Case Else - Return Color.Black - End Select - ElseIf rowNodeType = RowNode.RowTypeEnum.Module Then - Return Color.DeepPink - ElseIf rowNodeType = RowNode.RowTypeEnum.FixedModule Then - Return Color.Blue - End If - Else - Return Color.LightGray - End If - End Function - ''' ''' 鼠标移动到节点位置时所有子节点背景着色 ''' @@ -318,88 +448,6 @@ Namespace UTSModule.Station End Sub - - -#Region "修改待删除" - ''' - ''' FixModule节点Action变化时子节点字体重新着色 - ''' - ''' - Public Function getRowActionEn(grd As Grid, row As Integer) As Boolean - UpdateGridActionInfo(grd) - Return gRowNodeInfo(row).ActionEn - End Function - - - ''' - ''' FixModule节点Action变化时子节点字体重新着色 - ''' - Private Sub NodeAction_Change(grd As Grid, rowType As Integer, startRowIdx As Integer, isAction As Boolean) - '刷新表格数据 - UpdateGridActionInfo(grd) '节点关系发生变化后,重新刷新数组变量 - '重新着色 - ' UpdateGridInfo(grd) '重新将表格内容更新到数组变量中,如果没有节点变化,调用这个更新即可 - Grid_Repain_By_ActionEn(grd) '根据刷新的数据,重新着色 - End Sub - - ''' - ''' 根据总表状态对单元格字体重新着色 - ''' - Private Sub Grid_Repain_By_ActionEn(grd As Grid) - ''逐行着色 - Dim idx As Integer - Dim tmpRowColor As Color - - grd.AutoRedraw = False '关闭更新,加快界面刷新速度 - For idx = 1 To grd.Rows - 1 - 'todo:修改过程注释错误 - ' tmpRowColor = setRowTextForeColor(gRowNodeInfo(idx).CmdType, gRowNodeInfo(idx).ActionEn, gRowNodeInfo(idx).NodeType) '获取选颜色 - grd.Range(idx, ColNames.Result, idx, ColNames.ErrorMessage).ForeColor = tmpRowColor '着色 - - If gRowNodeInfo(idx).IsRecord = False Then - grd.Cell(idx, ColNames.RecordName).ForeColor = Color.LightGray '着色 - End If - - If gRowNodeInfo(idx).CmdType = "" And gRowNodeInfo(idx).Description = "" Then '空白行字体与底色同色,避免对编辑产生干扰 - grd.Range(idx, ColNames.Result, idx, ColNames.ErrorMessage).ForeColor = grd.Cell(idx, ColNames.Description).BackColor '着色 - End If - - If gRowNodeInfo(idx).NodeType = RowNode.RowTypeEnum.FixedModule Then - grd.Range(idx, ColNames.CommandType, idx, ColNames.ErrorMessage).ForeColor = grd.Cell(idx, ColNames.Description).BackColor '着色 - End If - Next - - grd.Refresh() '刷新表格 - grd.AutoRedraw = True - End Sub - - -#End Region - - - ''' - ''' 遍历表格,并更新到全局数组 - ''' - ''' - Private Sub UpdateGridInfo(grd As Grid) - 'If grd.EditorVisible Then Return '处于编辑状态 - - Dim idx As Integer - ReDim gRowNodeInfo(grd.Rows) - '先将参数遍历后写入整体数组 - For idx = 0 To grd.Rows - 1 - gRowNodeInfo(idx).ActionVal = grd.Cell(idx, ColNames.Action).BooleanValue '当前行 Action - gRowNodeInfo(idx).NodeLevel = GetRowNodeLevel(grd, idx) '当前行的 NodeLevel - gRowNodeInfo(idx).NodeType = GetRowType(grd, idx) '当前行的 NodeType - gRowNodeInfo(idx).CmdType = grd.Cell(idx, ColNames.CommandType).Text '获取cmdType’ - gRowNodeInfo(idx).RowIdx = idx - gRowNodeInfo(idx).IsRecord = grd.Cell(idx, ColNames.SaveToDb).BooleanValue - gRowNodeInfo(idx).Description = grd.Cell(idx, ColNames.Description).Text - gRowNodeInfo(idx).RecordName = grd.Cell(idx, ColNames.RecordName).Text - 'gRowNodeInfo(idx).FatherNodeIdxLst.Clear() - Next idx - End Sub - Private Function GetRowNodeAction(node As RowNode) As Boolean If node.ParentNode.RowLever <= 1 Then Return node.ParentNode.Action @@ -448,6 +496,28 @@ Namespace UTSModule.Station End If End Function + ''' + ''' 节点类型变更,修改节点行样式 + ''' + ''' + Private Sub NodeRowTypeChanged(node As RowNode) + Dim row As Integer = node.RowListIndex + With _grd + If node.RowType = RowNode.RowTypeEnum.FixedModule Then + .Cell(row, ColNames.Label).FontSize = 10 + .Cell(row, ColNames.Label).FontBold = True + ElseIf node.RowType = RowNode.RowTypeEnum.Module Then + .Cell(row, ColNames.Label).FontSize = 8 + .Cell(row, ColNames.Label).FontBold = True + ElseIf node.RowType = RowNode.RowTypeEnum.Flow Then + .Cell(row, ColNames.Label).FontSize = 8 + .Cell(row, ColNames.Label).FontBold = False + End If + NodeActionChanged(node) + End With + End Sub + + ''' ''' 节点状态变更,修改节点行颜色 ''' @@ -520,81 +590,6 @@ Namespace UTSModule.Station grd.Cell(idx, ColNames.Action).Text = IsCheck.ToString Next End Sub - ''' - ''' 更新表格内容到缓存,但是并不重新着色 - ''' - Public Sub Call_UpdateGridActionInfo() - UpdateGridActionInfo(_grd) - End Sub - - ''' - ''' 更新ActionEn信息 - ''' - Public Sub UpdateGridActionInfo(grd As Grid) - If grd.EditorVisible Then Return '处于编辑状态 - - Dim idx As Integer - Dim tmpRowType As Integer - Dim tmpRowLevel As Integer - Dim tmpRowIdx As Integer - Dim tmpActionEn As Boolean - Dim currRowCmdType As String - - If gIsGri_UpdateGridActionInfo_EventReady = True Then - gIsGri_UpdateGridActionInfo_EventReady = False - UpdateGridInfo(grd) - - '根据遍历数据,重新确认每一行的ActiveEn值 - For idx = 1 To grd.Rows - 1 - 'For idx = startRowIdx To endRowNodeIdx - - currRowCmdType = gRowNodeInfo(idx).CmdType - tmpRowLevel = gRowNodeInfo(idx).NodeLevel - tmpRowType = gRowNodeInfo(idx).NodeType - tmpActionEn = gRowNodeInfo(idx).ActionVal - tmpRowIdx = idx - - 'gRowNodeInfo(idx).FatherNodeIdxLst.Add(idx) - If gRowNodeInfo(idx).ActionVal = False Then '如果本行Action = false,则免去遍历,直接给false - gRowNodeInfo(idx).ActionEn = False - Else '如果本机为Active val = true,就继续遍历父级节点 - Select Case tmpRowType - Case > 0 - If tmpRowLevel > 1 Then - Do - tmpRowIdx = tmpRowIdx - 1 '往上一行 - tmpRowType = gRowNodeInfo(tmpRowIdx).NodeType '该行的RowType - If tmpRowType = RowNode.RowTypeEnum.Module Then '找到Module - If gRowNodeInfo(tmpRowIdx).NodeLevel = tmpRowLevel - 1 Then '第一个上一级节点就是自己的亲生父亲 - tmpRowLevel = gRowNodeInfo(tmpRowIdx).NodeLevel '更新节点级别 - tmpActionEn = tmpActionEn And gRowNodeInfo(tmpRowIdx).ActionVal '将父节点的Action状态运算进来’ - 'gRowNodeInfo(idx).FatherNodeIdxLst.Add(tmpRowIdx) '将父级节点添加到链表 - End If - End If - '一直遍历直到一级父节点,或者达到表格顶端,或者检查到False的父节点就退出遍历 - Loop Until tmpRowLevel = 1 Or tmpRowIdx <= 1 Or tmpActionEn = False - gRowNodeInfo(idx).ActionEn = tmpActionEn - - Else '==1 - gRowNodeInfo(idx).ActionEn = gRowNodeInfo(idx).ActionVal - - End If - Case RowNode.RowTypeEnum.FixedModule - gRowNodeInfo(idx).ActionEn = gRowNodeInfo(idx).ActionVal - End Select - End If - Next idx - - gIsGri_UpdateGridActionInfo_EventReady = True - End If - - - End Sub - - - Private Sub Grid_EnterRow(Sender As Object, e As Grid.EnterRowEventArgs) - - End Sub ''' ''' 光标移动时,所在行底色高亮 @@ -609,12 +604,6 @@ Namespace UTSModule.Station If tmpMouseRow <= 0 Or tmpMouseCol <= 0 Then Return - 'Dim tmpMouseRowNodeIdx As Integer = gRowNodeInfo(tmpMouseRow).RowIdx 'GetRowNodeIdx(_grd, tmpMouseRow) '同级节点计数’ - 'Dim tmpMouseRowNodeLevel As Integer = gRowNodeInfo(tmpMouseRow).NodeLevel 'GetRowNodeLevel(_grd, tmpMouseRow) '节点级数 - 'Dim tmpMouseRowNodeLstIdx As Integer = gRowNodeInfo(tmpMouseRow).NodeIdx 'GetRowNodeLstIdx(_grd, tmpMouseRow) '就是行号 - 'gRowType = gRowNodeInfo(tmpMouseRow).NodeType 'GetRowType(_grd, tmpMouseRow) '现在所在行的row type - 'gOldRowType = gRowNodeInfo(gMouseOldRow).NodeType 'GetRowType(_grd, gMouseOldRow) '前一次的row type - Dim tmpMouseRowNodeIdx As Integer = GetRowNodeIdx(_grd, tmpMouseRow) '同级节点计数’ Dim tmpMouseRowNodeLevel As Integer = GetRowNodeLevel(_grd, tmpMouseRow) '节点级数 Dim tmpMouseRowNodeLstIdx As Integer = GetRowNodeLstIdx(_grd, tmpMouseRow) '就是行号 @@ -626,7 +615,7 @@ Namespace UTSModule.Station If gOldRowType <> RowNode.RowTypeEnum.FixedModule Then '光标离开Flow节点 _grd.Range(gMouseOldRow, ColNames.Result, gMouseOldRow, ColNames.ErrorMessage).BackColor = Color.White _grd.Cell(gMouseOldRow, gMouseOldCol).FontBold = False - If gOldRowType = RowNode.RowTypeEnum.Module And gMouseOldCol = ColNames.Description Then '光标离开Module节点 + If gOldRowType = RowNode.RowTypeEnum.Module Then '光标离开Module节点 Mouse_MoveOnNode_BackColorRepain(_grd, gOldRowType, gMouseOldRow, Color.White) End If End If @@ -635,9 +624,8 @@ Namespace UTSModule.Station Else If gRowType <> RowNode.RowTypeEnum.FixedModule Then '光标移动到flow节点 _grd.Range(tmpMouseRow, ColNames.Result, tmpMouseRow, ColNames.ErrorMessage).BackColor = Color.LemonChiffon - '_grd.Cell(_grd.MouseRow, _grd.MouseCol).FontBold = True _grd.Cell(tmpMouseRow, tmpMouseCol).FontBold = True - If gRowType = RowNode.RowTypeEnum.Module And tmpMouseCol = ColNames.Description Then '光标移动到module节点 + If gRowType = RowNode.RowTypeEnum.Module Then '光标移动到module节点 Mouse_MoveOnNode_BackColorRepain(_grd, gRowType, tmpMouseRow, Color.LemonChiffon) End If End If @@ -863,17 +851,19 @@ Namespace UTSModule.Station End Sub Private Function ParamsToString(params As List(Of TestCmdParam)) As String - Dim result As New StringBuilder + Return String.Join($" {_paramChar} ", params.Select(Function(p) p.Value)) - For i As Integer = 0 To params.Count - 1 - If i = 0 Then - result.Append(params(i).Value) - Else - result.Append($" {_paramChar} {params(i).Value}") - End If - Next + 'Dim result As New StringBuilder - Return result.ToString() + 'For i As Integer = 0 To params.Count - 1 + ' If i = 0 Then + ' result.Append(params(i).Value) + ' Else + ' result.Append($" {_paramChar} {params(i).Value}") + ' End If + 'Next + + 'Return result.ToString() End Function @@ -942,6 +932,10 @@ Namespace UTSModule.Station Next End Sub + ''' + ''' 加载测试文件后更新表格 + ''' + ''' Public Sub UpdateGrid() _uploading = True @@ -951,6 +945,8 @@ Namespace UTSModule.Station LockGridAutoRedraw() UpdateGrid(_grd, _headNode.RowNodes) + ReflushLabelNames() + ReflushRecordNames() UnLockGridAutoRedraw() End With @@ -960,110 +956,6 @@ Namespace UTSModule.Station End Sub #Region "表格事件" - Public Sub Grid_OwnerDrawCell(ByVal sender As Object, ByVal e As Grid.OwnerDrawCellEventArgs) - If e.Row < NodeStartRow OrElse e.Col <> _drawCol Then Return - - Dim intWidth As Integer - Dim intAdd As Integer - - If _showNodeIcon Then - intWidth = 20 - intAdd = 26 - Else - intWidth = 10 - intAdd = 6 - End If - - If _headNode Is Nothing Then Return - Dim node As RowNode = _headNode.RowList(e.Row - _drawStartRow + 1) - If node Is Nothing Then Return - - '画树线 - Dim pen As New Pen(Color.Gray, 1) With {.DashStyle = Drawing2D.DashStyle.Solid} - - Dim drawLine As Boolean - Dim intLevel As Integer = node.RowLever - Dim tmpNode As RowNode - - For i As Integer = 0 To intLevel - If i < intLevel - 1 Then '父级的父级 - drawLine = True - tmpNode = node - For j As Integer = i To intLevel - 2 - tmpNode = tmpNode.ParentNode - Next - - If tmpNode.NextNode Is Nothing Then - drawLine = False - End If - - If drawLine Then - '全部 - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top - 1), CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1)) - End If - ElseIf i = intLevel - 1 Then '父级 - '上半部分 - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top - 1), CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2)) - - If node.NextNode IsNot Nothing Then - '下半部分 - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1)) - End If - - ElseIf i = intLevel Then '同级 - '下半部分 - If node.Expanded AndAlso node.Count > 0 Then - If _showNodeIcon Then - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2) + 7, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1)) - Else - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * i + intAdd), CInt(e.Bounds.Bottom + 1)) - End If - End If - End If - - '水平的 - If intLevel > 0 Then - If String.IsNullOrEmpty(_grd.Cell(e.Row, ColNames.Description).Text) Then - If node.NextNode Is Nothing Then - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd + 10), CInt(e.Bounds.Top + e.Bounds.Height / 2)) - End If - - _grd.Cell(e.Row, ColNames.Action).CellType = CellTypeEnum.TextBox - _grd.Cell(e.Row, ColNames.Action).Text = "" - Else - e.Graphics.DrawLine(pen, CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd), CInt(e.Bounds.Top + e.Bounds.Height / 2), CInt(e.Bounds.Left + intWidth * (intLevel - 1) + intAdd + 10), CInt(e.Bounds.Top + e.Bounds.Height / 2)) - _grd.Cell(e.Row, ColNames.Action).CellType = CellTypeEnum.CheckBox - End If - End If - Next - - pen.Dispose() - - '+/- - If node.RowNodes.Count > 0 Then - Dim rect As New Rectangle(e.Bounds.Left + 2 + intLevel * intWidth, CInt(e.Bounds.Top + (e.Bounds.Height - 9) / 2), 8, 8) - e.Graphics.FillRectangle(Brushes.White, rect) - e.Graphics.DrawRectangle(Pens.Black, rect) - If node.Expanded Then - e.Graphics.DrawLine(Pens.Black, rect.Left + 2, rect.Top + 4, rect.Right - 2, rect.Top + 4) - Else - e.Graphics.DrawLine(Pens.Black, rect.Left + 2, rect.Top + 4, rect.Right - 2, rect.Top + 4) - e.Graphics.DrawLine(Pens.Black, rect.Left + 4, rect.Top + 2, rect.Left + 4, rect.Bottom - 2) - End If - End If - - '文字 - Dim bColor As New SolidBrush(_grd.Cell(e.Row, e.Col).ForeColor) - With _grd.Cell(e.Row, e.Col) - If _showNodeIcon Then - e.Graphics.DrawString(.Text, .Font, bColor, e.Bounds.Left + intWidth * intLevel + 35, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 1) - Else - e.Graphics.DrawString(.Text, .Font, bColor, e.Bounds.Left + intWidth * intLevel + 12, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 1) - End If - End With - - e.Handled = True - End Sub Private Sub Grid_Click(ByVal sender As Object, ByVal e As EventArgs) If _grd.EditorVisible Then Return '处于编辑状态 @@ -1162,8 +1054,13 @@ Namespace UTSModule.Station Dim changeType As RowNodeChangedEventArgs.RowNodeChangeType changeType = RowNodeChangedEventArgs.RowNodeChangeType.None + + Dim cmd As ICommand + Select Case e.Col Case ColNames.[Pause] + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Pause.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.[Pause] = _grd.Cell(e.Row, e.Col).BooleanValue If node.[Pause] Then _grd.Cell(e.Row, e.Col).BackColor = Color.Red @@ -1171,6 +1068,8 @@ Namespace UTSModule.Station _grd.Cell(e.Row, e.Col).BackColor = Color.White End If Case ColNames.Action + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Action.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.Action = _grd.Cell(e.Row, e.Col).BooleanValue changeType = RowNodeChangedEventArgs.RowNodeChangeType.Action If node.RowType = RowNode.RowTypeEnum.FixedModule Then @@ -1180,18 +1079,36 @@ Namespace UTSModule.Station NodeActionChanged(node) Case ColNames.Description + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Description.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.Description = _grd.Cell(e.Row, e.Col).Text changeType = RowNodeChangedEventArgs.RowNodeChangeType.Description Case ColNames.[Label] - node.Label = _grd.Cell(e.Row, e.Col).Text - If String.IsNullOrWhiteSpace(node.Label) Then - node.RowType = RowNode.RowTypeEnum.Flow + Dim labelName As String = _grd.Cell(e.Row, e.Col).Text + If IsExistLabelName(labelName) Then '标签名称冲突检测,不区分大小写 + MsgBox($"标签名称[{labelName}]已存在于{GetLabelNameGridRow(labelName)}行,请重新输入!", MsgBoxStyle.Critical, "提示") + _uploading = True + _grd.Cell(e.Row, e.Col).Text = node.Label + _grd.Cell(e.Row, e.Col).SetFocus() + _uploading = False + Return Else - node.RowType = RowNode.RowTypeEnum.Module - End If + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Label.ToString(), _grd.Cell(e.Row, e.Col).Text) + If Not String.IsNullOrEmpty(node.Label) Then RemoveLabelName(node.Label) '移出之前记录标签名称 - changeType = RowNodeChangedEventArgs.RowNodeChangeType.Label + node.Label = labelName + If String.IsNullOrWhiteSpace(node.Label) Then + node.RowType = RowNode.RowTypeEnum.Flow + Else + node.RowType = RowNode.RowTypeEnum.Module + AddLabelName(node.Label, e.Row) '记录新的标签名称 + End If + + changeType = RowNodeChangedEventArgs.RowNodeChangeType.Label + End If Case ColNames.ControlType + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.ControlType.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.ControlType = _grd.Cell(e.Row, e.Col).Text If String.IsNullOrWhiteSpace(node.ControlType) Then node.RowType = RowNode.RowTypeEnum.Flow @@ -1202,6 +1119,8 @@ Namespace UTSModule.Station Case ColNames.CommandType If String.Compare(node.CommandType, _grd.Cell(e.Row, e.Col).Text) <> 0 Then + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.CommandType.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.CommandType = _grd.Cell(e.Row, e.Col).Text node.Command = "" node.Parameters.Clear() @@ -1209,10 +1128,12 @@ Namespace UTSModule.Station changeType = RowNodeChangedEventArgs.RowNodeChangeType.CommandType End If - 'NodeAction_Change(_grd, node.RowType, e.Row, node.Action) + NodeActionChanged(node) Case ColNames.Command If node.Command <> _grd.Cell(e.Row, e.Col).Text Then + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Command.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.Command = _grd.Cell(e.Row, e.Col).Text If String.IsNullOrWhiteSpace(node.Command) Then @@ -1234,6 +1155,9 @@ Namespace UTSModule.Station changeType = RowNodeChangedEventArgs.RowNodeChangeType.Command End If Case ColNames.Parameters + Dim pStr As String = ParamsToString(node.Parameters) + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, pStr, _grd.Cell(e.Row, e.Col).Text) + Dim str() As String = _grd.Cell(e.Row, e.Col).Text.Split(New Char() {_paramChar}) For i As Integer = 0 To node.Parameters.Count - 1 @@ -1245,6 +1169,8 @@ Namespace UTSModule.Station Next changeType = RowNodeChangedEventArgs.RowNodeChangeType.Parameters Case ColNames.SaveToDb + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.SaveToDb.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.SaveToDb = _grd.Cell(e.Row, e.Col).BooleanValue changeType = RowNodeChangedEventArgs.RowNodeChangeType.SaveToDb If node.RowType = RowNode.RowTypeEnum.FixedModule Then @@ -1253,23 +1179,52 @@ Namespace UTSModule.Station ' NodeAction_Change(_grd, node.RowType, e.Row, node.Action) NodeActionChanged(node) Case ColNames.RecordName - node.RecordName = _grd.Cell(e.Row, e.Col).Text - changeType = RowNodeChangedEventArgs.RowNodeChangeType.RecordName - 'CheckRecordName_Duplicate(_grd) '确认记录名称是否有重名项 + Dim recordName As String = _grd.Cell(e.Row, e.Col).Text + + If IsExistRecordName(recordName) Then + MsgBox($"记录名称[{recordName}]已存在于{GetRecordNameGridRow(recordName)}行,请重新输入!", MsgBoxStyle.Critical, "提示") + _uploading = True + _grd.Cell(e.Row, e.Col).Text = node.Label + _grd.Cell(e.Row, e.Col).SetFocus() + _uploading = False + Return + Else + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.RecordName.ToString(), recordName) + If IsExistRecordName(node.RecordName) Then RemoveRecordName(node.RecordName) '移出之前记录名称 + + node.RecordName = recordName + If Not String.IsNullOrWhiteSpace(recordName) Then + AddRecordName(node.RecordName, e.Row) '记录新的记录名称 + End If + changeType = RowNodeChangedEventArgs.RowNodeChangeType.RecordName + End If Case ColNames.Retry + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.Retry.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.Retry = _grd.Cell(e.Row, e.Col).IntegerValue changeType = RowNodeChangedEventArgs.RowNodeChangeType.Retry Case ColNames.RetryInterval + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.RetryInterval.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.RetryInterval = _grd.Cell(e.Row, e.Col).IntegerValue changeType = RowNodeChangedEventArgs.RowNodeChangeType.RetryInterval Case ColNames.ErrorCode + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.ErrorCode.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.ErrorCode = _grd.Cell(e.Row, e.Col).Text changeType = RowNodeChangedEventArgs.RowNodeChangeType.ErrorCode Case ColNames.ErrorMessage + cmd = New GridNodeTextChangedCommand(_grd, e.Row, e.Col, node.ErrorMessage.ToString(), _grd.Cell(e.Row, e.Col).Text) + node.ErrorMessage = _grd.Cell(e.Row, e.Col).Text changeType = RowNodeChangedEventArgs.RowNodeChangeType.ErrorMessage End Select + If CommandManager.IsRuning = False AndAlso cmd IsNot Nothing Then + CommandManager.RunCommand(cmd) + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + End If + '触发事件 If SkipEvent Then Return Select Case changeType @@ -1541,79 +1496,101 @@ Namespace UTSModule.Station Public Sub NodeAdd(startMoveRow As Integer, rows As Integer) - Dim idx As Integer - Dim node As RowNode - If rows < 1 Then Return If _headNode Is Nothing Then Return - LockGridAutoRedraw() + Dim cmd As New GridNodeAddCommand(Me, startMoveRow, rows) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + + Friend Sub NodeAddCommand(startMoveRow As Integer, rows As Integer, Optional nodes As List(Of RowNode) = Nothing) + Dim node As RowNode + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) Dim row As Integer = startMoveRow + rows - For idx = 1 To rows - node = _headNode.RowList(startMoveRow - _drawStartRow + 1) - - If node Is Nothing Then Exit For + Dim grdNode As FlexCell.Node = _grd.Tree.FindNode(startMoveRow) + LockGridAutoRedraw() + _uploading = True + For i As Integer = 1 To rows '更新内存 - Dim rowNode As New RowNode With {.RowType = RowNode.RowTypeEnum.Flow} + If nodes Is Nothing OrElse nodes.Count < i Then + node = New RowNode With {.RowType = RowNode.RowTypeEnum.Flow} + Else + node = nodes(i - 1) + End If '在当前节点后插入节点 - node.ParentNode.InsertNode(node.RowIndex, rowNode) + startNode.ParentNode.InsertNode(startNode.RowIndex, node) - '更新控件,若为最后一行,插入会失败 - If _grd.Tree.SelectedNode.NextNode Is Nothing Then - _grd.Tree.SelectedNode.Parent.Nodes.Add("", "") - Else - _grd.Tree.SelectedNode.Parent.Nodes.Insert(_grd.Tree.SelectedNode.Index, "") - End If - UpdateGrid(_grd, rowNode.RowListIndex, rowNode) + '更新控件 + grdNode.Parent.Nodes.Insert(grdNode.Index, "") + UpdateGrid(_grd, node.RowListIndex, node) - Next idx + Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex) + AddGridTreeNode(pNode, node) + Next '其他操作 _grd.Cell(row, _drawCol).SetFocus() + _uploading = False UnLockGridAutoRedraw() End Sub - Public Sub NodeDel(startMoveRow As Integer, rows As Integer) - Dim idx As Integer - Dim node As RowNode + Public Sub NodeDel(startMoveRow As Integer, rows As Integer) If rows < 1 Then Return If _headNode Is Nothing Then Return + Dim nodes As New List(Of RowNode) + Dim node As RowNode + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + For i As Integer = 1 To rows + node = _headNode.RowList(startMoveRow - _drawStartRow + i) + If node.RowLever > startNode.RowLever Then Continue For + If node.RowLever < startNode.RowLever Then Exit For + nodes.Add(node) + Next + Dim cmd As New GridNodeDeleteCommand(Me, startMoveRow, rows, nodes) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + Friend Sub NodeDeleteCommand(startMoveRow As Integer, rows As Integer) LockGridAutoRedraw() + _uploading = True + Dim node As RowNode + Dim grdNode As FlexCell.Node Dim row As Integer = startMoveRow - 1 - For idx = 1 To rows - node = _headNode.RowList(startMoveRow - _drawStartRow + 1) + For i As Integer = 1 To rows + node = _headNode.RowList(startMoveRow - _drawStartRow + 1) '前面节点已删除,所以每次都是固定位置 If node Is Nothing Then Exit For + '更新控件 + grdNode = _grd.Tree.FindNode(node.RowListIndex) + grdNode.Remove() + '更新内存 If node.CanDelete = False Then Exit For - If node.RowType = RowNode.RowTypeEnum.Module Then - If MessageBox.Show("删除节点将会导致所有子节点被连带删除!" & - vbCrLf & "删除后不可恢复!" & - vbCrLf & vbCrLf & "是否需要删除?", - "删除节点", MessageBoxButtons.OKCancel, - MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = DialogResult.Cancel Then Return - End If node.Remove() - '更新控件 - _grd.Tree.SelectedNode.Remove() - '其他操作 StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - Next idx + Next _grd.Cell(row, _drawCol).SetFocus() + _uploading = False UnLockGridAutoRedraw() End Sub + Public Sub NodeClear() If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return @@ -1632,26 +1609,53 @@ Namespace UTSModule.Station '其他操作 StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - End Sub Public Sub NodeMoveUp(startMoveRow As Integer, moveRows As Integer) If _headNode Is Nothing Then Return + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + Dim prevNode As RowNode = startNode.PrevNode + + If prevNode Is Nothing Then Return + + Dim moveEndRow As Integer = prevNode.RowListIndex + Dim cmd As New GridNodeMoveUpCommand(Me, startMoveRow, moveRows, moveEndRow) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + Public Sub NodeMoveDown(startMoveRow As Integer, moveRows As Integer) + If _headNode Is Nothing Then Return + + Dim endNode As RowNode = _headNode.RowList(startMoveRow + moveRows - _drawStartRow) + Dim nextNode As RowNode = endNode.NextNode + If nextNode Is Nothing Then Return + + Dim moveEndRow As Integer = startMoveRow + nextNode.AllChildCount + 1 + Dim cmd As New GridNodeMoveDownCommand(Me, startMoveRow, moveRows, moveEndRow) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + + Friend Sub NodeMoveUpCommand(startMoveRow As Integer, moveRows As Integer) + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + Dim prevNode As RowNode = startNode.PrevNode + + Dim endNode As RowNode = _headNode.RowList(startMoveRow + moveRows - _drawStartRow) + Dim nextNode As RowNode = endNode.NextNode + + Dim node As RowNode = startNode + Dim moveUpRows As Integer = node.AllChildCount + 1 + '获取起始节点信息 Dim lstMoveNodes As New List(Of RowNode) Dim lstFixNodes As New List(Of RowNode) Dim isMoveUp As Boolean = True - - Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) - Dim prevNode As RowNode = startNode.PrevNode - Dim node As RowNode = startNode - Dim moveUpRows As Integer = node.AllChildCount + 1 - - If prevNode Is Nothing Then Return - - '获取所有移动节点信息 lstMoveNodes.Add(node) For i As Integer = 2 To moveRows node = _headNode.RowList(startMoveRow - _drawStartRow + i) @@ -1669,55 +1673,45 @@ Namespace UTSModule.Station If isMoveUp Then NodeMoveUp(lstFixNodes, lstMoveNodes) Else - NodeMoveNext(lstFixNodes, lstMoveNodes) + NodeMoveDown(lstFixNodes, lstMoveNodes) End If - - - - 'Dim grdNode As FlexCell.Node - 'Dim grdPrevNode As FlexCell.Node - - ''进行移动操作 - 'LockGridAutoRedraw() - '_uploading = True - - 'For i As Integer = 0 To lstMoveNodes.Count - 1 - - ' node = lstMoveNodes(i) - - ' grdNode = _grd.Tree.FindNode(node.RowListIndex) - ' grdPrevNode = grdNode.PrevNode - - ' If node Is Nothing Then Exit For - ' If node.PrevNode Is Nothing Then Exit For - - ' If isMoveUp Then - ' node.MoveUp() - ' grdNode.Remove() - ' grdPrevNode.Parent.Nodes.Insert(grdPrevNode.Index, String.Empty) - ' UpdateGrid(_grd, node.RowListIndex, node) - ' '获取表格节点,添加其子节点 - ' Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex) - ' AddGridTreeNode(pNode, node) - - ' ' UpdateGrid(grdPrevNode, grdNode) - ' Else - ' node.MoveDown() - ' grdNode.Remove() - ' grdPrevNode.Parent.Nodes.Insert(grdPrevNode.Index, String.Empty) - - - ' End If - 'Next - - ''节点修改 - 'StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - - '_uploading = False - 'UnLockGridAutoRedraw() End Sub - Public Sub NodeMoveNext(upNode As List(Of RowNode), downNode As List(Of RowNode)) + + Friend Sub NodeMoveDownCommand(startMoveRow As Integer, moveRows As Integer) + Dim endNode As RowNode = _headNode.RowList(startMoveRow + moveRows - _drawStartRow) + Dim nextNode As RowNode = endNode.NextNode + + Dim node As RowNode = endNode + Dim moveDownRows As Integer = 0 + + '获取起始节点信息 + Dim lstMoveNodes As New List(Of RowNode) + Dim lstFixNodes As New List(Of RowNode) + Dim isMoveDown As Boolean = True + For i As Integer = 1 To moveRows + node = _headNode.RowList(startMoveRow - _drawStartRow + i) + If node.RowLever < node.RowLever Then Exit For '高于起始节点级别不移动 + If node.RowLever > node.RowLever Then Continue For '低于起始节点级别认为是子节点不记录 + + moveDownRows += node.AllChildCount + 1 + lstMoveNodes.Add(node) + Next + + '如果需要上移的节点过多则修改为上一节点下移操作 + lstFixNodes.Add(nextNode) + isMoveDown = moveDownRows < nextNode.AllChildCount + + If isMoveDown Then + NodeMoveDown(lstMoveNodes, lstFixNodes) + Else + NodeMoveUp(lstMoveNodes, lstFixNodes) + End If + End Sub + + + + Private Sub NodeMoveDown(upNode As List(Of RowNode), downNode As List(Of RowNode)) LockGridAutoRedraw() _uploading = True @@ -1750,7 +1744,7 @@ Namespace UTSModule.Station UnLockGridAutoRedraw() End Sub - Public Sub NodeMoveUp(upNode As List(Of RowNode), downNode As List(Of RowNode)) + Private Sub NodeMoveUp(upNode As List(Of RowNode), downNode As List(Of RowNode)) LockGridAutoRedraw() _uploading = True @@ -1778,110 +1772,6 @@ Namespace UTSModule.Station '节点修改 StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - _uploading = False - UnLockGridAutoRedraw() - - End Sub - - - - Public Sub NodeMoveDown(startMoveRow As Integer, moveRows As Integer) - If _headNode Is Nothing Then Return - - '获取起始节点信息 - Dim lstMoveNodes As New List(Of RowNode) - Dim lstFixNodes As New List(Of RowNode) - Dim isMoveDown As Boolean = True - - Dim endNode As RowNode = _headNode.RowList(startMoveRow + moveRows - _drawStartRow) - Dim nextNode As RowNode = endNode.NextNode - Dim node As RowNode = endNode - Dim moveDownRows As Integer = 0 - - If nextNode Is Nothing Then Return - - '获取所有移动节点信息 - For i As Integer = 1 To moveRows - node = _headNode.RowList(startMoveRow - _drawStartRow + i) - If node.RowLever < node.RowLever Then Exit For '高于起始节点级别不移动 - If node.RowLever > node.RowLever Then Continue For '低于起始节点级别认为是子节点不记录 - - moveDownRows += node.AllChildCount + 1 - lstMoveNodes.Add(node) - Next - - '如果需要上移的节点过多则修改为上一节点下移操作 - lstFixNodes.Add(nextNode) - isMoveDown = moveDownRows < nextNode.AllChildCount - - If isMoveDown Then - NodeMoveNext(lstMoveNodes, lstFixNodes) - Else - NodeMoveUp(lstMoveNodes, lstFixNodes) - End If - - - - - - - - - - - 'If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return - - 'If _headNode Is Nothing Then Return - 'Dim node As RowNode = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1) - 'If node Is Nothing Then Return - - - ''更新内存 - 'If node.NextNode Is Nothing Then Return - - 'Dim moveDownRow As Integer = node.RowListIndex '下移动前起始位置 - 'Dim moveDownCount As Integer = node.AllChildCount + 1 '下移动总量 - - 'Dim moveUpRow As Integer = node.NextNode.RowListIndex '上移动前起始位置 - 'Dim moveUpCount As Integer = node.NextNode.AllChildCount + 1 '上移动总量 - - 'node.MoveDown() - - 'UpdateGrid(_grd.Tree.SelectedNode, _grd.Tree.SelectedNode.NextNode) - - '_grd.Cell(node.RowListIndex, _grd.ActiveCell.Col).SetFocus() - End Sub - - - Private Sub UpdateGrid(srcNode As FlexCell.Node, targetNode As FlexCell.Node) - LockGridAutoRedraw() - _uploading = True - - If srcNode.ChildCount >= targetNode.ChildCount Then - targetNode.Remove() - srcNode.Parent.Nodes.Insert(srcNode.Index, String.Empty) - - Dim node As RowNode = _headNode.RowList(srcNode.PrevNode.Row) - UpdateGrid(_grd, node.RowListIndex, node) - - '获取表格节点,添加其子节点 - Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex) - AddGridTreeNode(pNode, node) - Else - srcNode.Remove() - targetNode.Parent.Nodes.Insert(targetNode.Index + 1, String.Empty) - - Dim node As RowNode = _headNode.RowList(targetNode.NextNode.Row) - UpdateGrid(_grd, node.RowListIndex, node) - - '获取表格节点,添加其子节点 - Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex) - AddGridTreeNode(pNode, node) - End If - - '节点修改 - StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - _uploading = False UnLockGridAutoRedraw() End Sub @@ -1895,29 +1785,6 @@ Namespace UTSModule.Station Next End Sub - Private Sub UpdateGrid(moveDownRow As Integer, moveDownCount As Integer, moveUpRow As Integer, moveUpCount As Integer) - LockGridAutoRedraw() - - '更新控件 - If moveUpCount < moveDownCount Then - '表格行上移 - For i As Integer = 0 To moveUpCount - 1 - _grd.Row(moveUpRow + i).Position = moveDownRow + i - Next - Else - '表格行下移 - While moveDownCount > 0 - _grd.Row(moveDownRow).Position = moveUpRow + moveUpCount - 1 - moveDownCount -= 1 - End While - End If - - '节点修改 - StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed - - UnLockGridAutoRedraw() - End Sub - ''' ''' 节点升级 @@ -1925,14 +1792,37 @@ Namespace UTSModule.Station Public Sub NodeMoveLeft(startMoveRow As Integer, moveRows As Integer) If _headNode Is Nothing Then Return + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + If startNode.RowLever <= 1 Then Return + + Dim startNodeIndex As Integer = startNode.RowIndex + Dim node As RowNode + Dim moveEndRow As Integer = startNode.ParentNode.RowListIndex + startNode.ParentNode.AllChildCount + 1 + For i As Integer = 1 To moveRows + node = _headNode.RowList(startMoveRow - _drawStartRow + i) + If node.RowLever < startNode.RowLever Then Exit For '高于起始节点级别不移动 + If node.RowLever > startNode.RowLever Then Continue For + + moveEndRow -= (node.AllChildCount + 1) + Next + + Dim cmd As New GridNodeMoveLeftCommand(Me, startMoveRow, moveRows, moveEndRow, startNodeIndex) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + + Public Sub NodeMoveLeftCommand(startMoveRow As Integer, moveRows As Integer) Dim node As RowNode Dim grdNode As FlexCell.Node Dim grdParentNode As FlexCell.Node LockGridAutoRedraw() _uploading = True - For idx As Integer = moveRows To 1 Step -1 - node = _headNode.RowList(startMoveRow - _drawStartRow + idx) - Console.WriteLine($"Index:{node.RowListIndex}") + + Dim parentNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1).ParentNode + For i As Integer = moveRows To 1 Step -1 + node = _headNode.RowList(startMoveRow - _drawStartRow + i) If node Is Nothing Then Exit For If node.RowLever = 0 Then Exit For @@ -1941,7 +1831,6 @@ Namespace UTSModule.Station grdParentNode = grdNode.Parent node.MoveLeft() - Console.WriteLine($"Node:{node.RowLever}") grdNode.Remove() grdParentNode.Parent.Nodes.Insert(grdParentNode.Index + 1, "") @@ -1949,8 +1838,10 @@ Namespace UTSModule.Station AddGridTreeNode(_grd.Tree.FindNode(node.RowListIndex), node) StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed Next - - + If parentNode.Children.Count = 0 Then + parentNode.RowType = RowNode.RowTypeEnum.Flow + NodeRowTypeChanged(parentNode) + End If _uploading = False UnLockGridAutoRedraw() @@ -1963,74 +1854,117 @@ Namespace UTSModule.Station Public Sub NodeMoveRight(startMoveRow As Integer, moveRows As Integer) If _headNode Is Nothing Then Return - Dim node As RowNode - Dim grdNode As FlexCell.Node - Dim grdPreNode As FlexCell.Node - Dim moveLeftSatrtRow As Integer = _grd.ActiveCell.Row + Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + If startNode.RowLever < 1 Then Return '固定节点不移动 + If startNode.PrevNode Is Nothing Then Return '没有上一级节点 + + Dim moveRightNodeIndex As Integer = startNode.PrevNode.Children.Count + Dim moveEndRow As Integer = startNode.PrevNode.RowListIndex + startNode.PrevNode.AllChildCount + 1 + + Dim cmd As New GridNodeMoveRightCommand(Me, startMoveRow, moveRows, moveEndRow, moveRightNodeIndex) + CommandManager.RunCommand(cmd) '添加到撤销堆栈执行 + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End Sub + + + Public Sub NodeMoveRightCommand(startMoveRow As Integer, moveRows As Integer, nodeIndex As Integer) + Dim node As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1) + Dim parentNode As RowNode = node.PrevNode + Dim grdNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex) + Dim grdPreNode As FlexCell.Node = grdNode.PrevNode LockGridAutoRedraw() _uploading = True - For idx As Integer = 1 To moveRows - node = _headNode.RowList(startMoveRow - _drawStartRow + idx) + + For i As Integer = 1 To moveRows + node = _headNode.RowList(startMoveRow - _drawStartRow + i) If node Is Nothing Then Exit For - If node.RowType = RowNode.RowTypeEnum.FixedModule Then Exit For - If node.RowIndex = 0 Then Exit For + If parentNode.RowLever > node.RowLever Then Continue For + If parentNode.RowLever < node.RowLever Then Exit For grdNode = _grd.Tree.FindNode(node.RowListIndex) - grdPreNode = grdNode.PrevNode - node.MoveRight() + ' node.MoveRight() + node.Remove() + parentNode.InsertNode(nodeIndex + i - 1, node) grdNode.Remove() - grdPreNode.Nodes.Add("", "") + grdPreNode.Nodes.Insert(nodeIndex + i - 1, "") + UpdateGrid(_grd, node.RowListIndex, node) AddGridTreeNode(_grd.Tree.FindNode(node.RowListIndex), node) StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed Next + If parentNode.RowType = RowNode.RowTypeEnum.Flow Then + parentNode.RowType = RowNode.RowTypeEnum.Module + NodeRowTypeChanged(parentNode) + End If + _uploading = False UnLockGridAutoRedraw() End Sub + #End Region #Region "外部事件" Public Sub Grid_RowNodeTextChanged(sender As Object, e As RowNodeChangedEventArgs) Dim row As Integer = e.Node.RowListIndex Dim node As RowNode = e.Node + Dim cmd As ICommand _uploading = True With _grd Select Case e.ChangeType Case RowNodeChangedEventArgs.RowNodeChangeType.Action + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Action, .Cell(row, ColNames.Action).Text, node.Action.ToString()) + .Cell(row, ColNames.Action).Text = IIf(node.Action, "1", "0").ToString() Case RowNodeChangedEventArgs.RowNodeChangeType.RowType - If node.RowType = RowNode.RowTypeEnum.FixedModule Then - .Cell(row, ColNames.Label).FontSize = 10 - .Cell(row, ColNames.Label).FontBold = True - ElseIf node.RowType = RowNode.RowTypeEnum.Module Then - .Cell(row, ColNames.Label).FontSize = 8 - .Cell(row, ColNames.Label).FontBold = True - ElseIf node.RowType = RowNode.RowTypeEnum.Flow Then - .Cell(row, ColNames.Label).FontSize = 8 - .Cell(row, ColNames.Label).FontBold = False - End If - NodeActionChanged(node) - ' NodeAction_Change(_grd, node.RowType, row, node.Action) + 'If node.RowType = RowNode.RowTypeEnum.FixedModule Then + ' .Cell(row, ColNames.Label).FontSize = 10 + ' .Cell(row, ColNames.Label).FontBold = True + 'ElseIf node.RowType = RowNode.RowTypeEnum.Module Then + ' .Cell(row, ColNames.Label).FontSize = 8 + ' .Cell(row, ColNames.Label).FontBold = True + 'ElseIf node.RowType = RowNode.RowTypeEnum.Flow Then + ' .Cell(row, ColNames.Label).FontSize = 8 + ' .Cell(row, ColNames.Label).FontBold = False + 'End If + 'NodeActionChanged(node) + NodeRowTypeChanged(node) Case RowNodeChangedEventArgs.RowNodeChangeType.Label + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Label, .Cell(row, ColNames.Label).Text, node.Label.ToString()) + .Cell(row, ColNames.Label).Text = $"{node.Label}" Case RowNodeChangedEventArgs.RowNodeChangeType.ControlType + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.ControlType, .Cell(row, ColNames.ControlType).Text, node.ControlType.ToString()) + .Cell(row, ColNames.ControlType).Text = $"{node.ControlType}" Case RowNodeChangedEventArgs.RowNodeChangeType.Description + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Description, .Cell(row, ColNames.Description).Text, node.Description.ToString()) + .Cell(row, ColNames.Description).Text = $"{node.Description}" Case RowNodeChangedEventArgs.RowNodeChangeType.SaveToDb + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.SaveToDb, .Cell(row, ColNames.SaveToDb).Text, node.SaveToDb.ToString()) + .Cell(row, ColNames.SaveToDb).Text = IIf(node.SaveToDb, "1", "0").ToString() Case RowNodeChangedEventArgs.RowNodeChangeType.RecordName + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.RecordName, .Cell(row, ColNames.RecordName).Text, node.RecordName.ToString()) + .Cell(row, ColNames.RecordName).Text = $"{node.RecordName}" Case RowNodeChangedEventArgs.RowNodeChangeType.Retry + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Retry, .Cell(row, ColNames.Retry).Text, node.Retry.ToString()) + .Cell(row, ColNames.Retry).Text = $"{node.Retry}" Case RowNodeChangedEventArgs.RowNodeChangeType.RetryInterval + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.RetryInterval, .Cell(row, ColNames.RetryInterval).Text, node.RetryInterval.ToString()) + .Cell(row, ColNames.RetryInterval).Text = $"{node.RetryInterval}" Case RowNodeChangedEventArgs.RowNodeChangeType.ErrorCode + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.ErrorCode, .Cell(row, ColNames.ErrorCode).Text, node.ErrorCode.ToString()) + .Cell(row, ColNames.ErrorCode).Text = $"{node.ErrorCode}" If String.IsNullOrWhiteSpace(node.ErrorCode) = False Then .Cell(row, ColNames.ErrorCode).BackColor = _errCodeManager(node.ErrorCode).Color @@ -2040,22 +1974,36 @@ Namespace UTSModule.Station .Cell(row, ColNames.ErrorMessage).BackColor = Color.White End If Case RowNodeChangedEventArgs.RowNodeChangeType.ErrorMessage + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.ErrorMessage, .Cell(row, ColNames.ErrorMessage).Text, node.ErrorMessage.ToString()) + .Cell(row, ColNames.ErrorMessage).Text = $"{node.ErrorMessage}" Case RowNodeChangedEventArgs.RowNodeChangeType.CommandType If String.Compare(.Cell(row, ColNames.CommandType).Text, node.CommandType) <> 0 Then + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.CommandType, .Cell(row, ColNames.CommandType).Text, node.CommandType.ToString()) + .Cell(row, ColNames.CommandType).Text = $"{node.CommandType}" CommandTypeChanged(node) End If Case RowNodeChangedEventArgs.RowNodeChangeType.Command If String.Compare(.Cell(row, ColNames.Command).Text, node.Command) <> 0 Then + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Command, .Cell(row, ColNames.Command).Text, node.Command.ToString()) + .Cell(row, ColNames.Command).Text = $"{node.Command}" CommandChanged(node) End If Case RowNodeChangedEventArgs.RowNodeChangeType.Parameters + cmd = New GridNodeTextChangedCommand(_grd, row, ColNames.Parameters, .Cell(row, ColNames.Parameters).Text, ParamsToString(node.Parameters)) + .Cell(row, ColNames.Parameters).Text = $"{ParamsToString(node.Parameters)}" End Select End With + If CommandManager.IsRuning = False AndAlso cmd IsNot Nothing Then + CommandManager.RunCommand(cmd) + RaiseEvent PlanGridCommandChanged(Nothing, Nothing) + + End If + StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed _uploading = False @@ -2090,36 +2038,6 @@ Namespace UTSModule.Station Return True End Function - Private Sub CheckRecordName_Duplicate(grd As Grid) - Dim idx As Integer - Dim x As Integer - Dim tmpRecordName As String - - '更新信息数组中 - UpdateGridInfo(grd) - - For idx = 0 To _grd.Rows - 2 - If gRowNodeInfo(idx).NodeType = RowNode.RowTypeEnum.Flow Then - tmpRecordName = gRowNodeInfo(idx).RecordName - If tmpRecordName <> "" Then - For x = idx + 1 To grd.Rows - 1 - If tmpRecordName = gRowNodeInfo(x).RecordName Then - MsgBox("Record Name 重名!" & vbNewLine & - "行号: " & idx & vbNewLine & - "行号: " & x & vbNewLine & - "RecordName: " & tmpRecordName & - vbNewLine & vbNewLine & - "请注意,记录名不能重复,否则前面的数据将会被覆盖!" - ) - End If - Next x - End If - End If - Next idx - End Sub - - - ''' ''' 反显节点所在行 ''' diff --git a/UTS_Core/UTSModule/Test/UtsTester.vb b/UTS_Core/UTSModule/Test/UtsTester.vb index b21fc47..6bf4e76 100644 --- a/UTS_Core/UTSModule/Test/UtsTester.vb +++ b/UTS_Core/UTSModule/Test/UtsTester.vb @@ -446,9 +446,6 @@ Namespace UTSModule.Test _customModules.Clear() GetTestModule(_customModules, node.RowNodes) End If - 'If node.RowNodes.Count > 0 Then - ' GetTestModule(modules, node.RowNodes) - 'End If Next End Sub diff --git a/UTS_Core/UTS_Core.vbproj b/UTS_Core/UTS_Core.vbproj index f06f920..ec5151f 100644 --- a/UTS_Core/UTS_Core.vbproj +++ b/UTS_Core/UTS_Core.vbproj @@ -200,8 +200,16 @@ - - + + + + + + + + + + @@ -298,10 +306,10 @@ - - - - + + + + @@ -354,7 +362,6 @@ - @@ -506,10 +513,7 @@ - - - - + diff --git a/UTS_Core/Undo/CommandManager.vb b/UTS_Core/Undo/CommandManager.vb deleted file mode 100644 index bca0394..0000000 --- a/UTS_Core/Undo/CommandManager.vb +++ /dev/null @@ -1,77 +0,0 @@ -Namespace Undo - Public Class CommandManager - Protected Property UndoCommands As New Stack(Of ICommand) - - Protected Property RedoCommands As New Stack(Of ICommand) - - - ''' - ''' 运行命令,并将命令添加至撤销堆栈 - ''' - ''' - Public Sub RunCommand(command As ICommand) - command.Execute() - - AddUndoCommand(command) - End Sub - - ''' - ''' 将命令添加至撤销堆栈 - ''' - Public Sub AddUndoCommand(command As ICommand) - UndoCommands.Push(command) - - If RedoCommands.Count > 0 Then - ClearRedoCommands() - End If - End Sub - - ''' - ''' 清空撤销命令堆栈 - ''' - Public Sub ClearUndoCommands() - UndoCommands.Clear() - - End Sub - - ''' - ''' 清空重做命令堆栈 - ''' - Public Sub ClearRedoCommands() - RedoCommands.Clear() - End Sub - - ''' - ''' 清空撤销与重做命令堆栈 - ''' - Public Sub ClearCommands() - ClearUndoCommands() - ClearRedoCommands() - End Sub - - ''' - ''' 执行撤销命令 - ''' - Public Sub Undo() - If UndoCommands.Count <= 0 Then Return - Dim command As ICommand = UndoCommands.Pop() - command.Undo() - - RedoCommands.Push(command) - End Sub - - - ''' - ''' 执行重做命令 - ''' - Public Sub Redo() - If RedoCommands.Count <= 0 Then Return - - Dim command As ICommand = RedoCommands.Pop() - command.Redo() - - UndoCommands.Push(command) - End Sub - - End Class -End Namespace \ No newline at end of file diff --git a/UTS_Core/Undo/ICommand.vb b/UTS_Core/Undo/ICommand.vb deleted file mode 100644 index 3d35e96..0000000 --- a/UTS_Core/Undo/ICommand.vb +++ /dev/null @@ -1,19 +0,0 @@ -Namespace Undo - Public Interface ICommand - ''' - ''' 运行一条需要记录在撤销栈的命令 - ''' - Sub Execute() - - - ''' - ''' 重做命令 - ''' - Sub Redo() - - ''' - ''' 撤销命令 - ''' - Sub Undo() - End Interface -End NameSpace \ No newline at end of file diff --git a/UTS_Core/bin/Debug/UTS_Core.xml b/UTS_Core/bin/Debug/UTS_Core.xml index 9a1d437..dcd9d36 100644 --- a/UTS_Core/bin/Debug/UTS_Core.xml +++ b/UTS_Core/bin/Debug/UTS_Core.xml @@ -1513,53 +1513,48 @@ UTS_Core - - - 运行一条需要记录在撤销栈的命令 - - - + 重做命令 - + 撤销命令 - + 运行命令,并将命令添加至撤销堆栈 - + 将命令添加至撤销堆栈 - + 清空撤销命令堆栈 - + 清空重做命令堆栈 - + 清空撤销与重做命令堆栈 - + 执行撤销命令 - + 执行重做命令 @@ -6074,12 +6069,42 @@ UTS_Core 测试流程所关联的项目站包信息 + + 表格控件对象 + + + 表格树状目录起始节点 + + + 起始绘制列 + + + 起始绘制行 + + + 调试模式是否开启 + + + 是否显示节点图标 + 处于更新表格状态中,不触发表格单元格修改事件 多个参数间的分割符号 + + 测试命令管理器 + + + 错误代码管理器 + + + 表格标签字段字典 + + + 表格记录名称字段字典 + 当前活动节点 @@ -6089,11 +6114,8 @@ UTS_Core 节点文本被修改事件 - - 测试命令管理器 - - - 错误代码管理器 + + 节点执行可撤销事件 @@ -6101,11 +6123,6 @@ UTS_Core - - - 对第二行的Action执行一遍操作,以触发更新事件 - - 向后导航 @@ -6135,6 +6152,80 @@ UTS_Core + + + 当前模块名是否已存在 + + + + + + + 当前字段名 + + + + + + + 清空标签名称 + + + + + 清空记录名称 + + + + + 添加标签名称 + + 标签名称 + 行号 + + + + 添加记录名称 + + 记录名 + 行号 + + + + 移出标签名称 + + 标签名称 + + + + 移出记录名称 + + 记录名称 + + + + 获取标签名称行号 + + + + + + + 获取记录名称行号 + + + + + + + 从表格中重载标签名称 + + + + + 从表格中重载记录名称 + + 光标离开grd表格时,黄色底色切换到选中行 @@ -6145,38 +6236,16 @@ UTS_Core 光标进入grd表格时,原底色切换到选中行 - - - 根据CmdType 和 isAction 返回该行字体颜色 - - - 鼠标移动到节点位置时所有子节点背景着色 - + - FixModule节点Action变化时子节点字体重新着色 + 节点类型变更,修改节点行样式 - - - - - FixModule节点Action变化时子节点字体重新着色 - - - - - 根据总表状态对单元格字体重新着色 - - - - - 遍历表格,并更新到全局数组 - - + @@ -6195,16 +6264,6 @@ UTS_Core 选定行使能或清除Action选项 - - - 更新表格内容到缓存,但是并不重新着色 - - - - - 更新ActionEn信息 - - 光标移动时,所在行底色高亮 @@ -6251,6 +6310,12 @@ UTS_Core 初始化测试站表格 + + + 加载测试文件后更新表格 + + + 展开行节点 diff --git a/UTS_Core/obj/Debug/UTS_Core.UTSModule.Station.FrmStationPlan.resources b/UTS_Core/obj/Debug/UTS_Core.UTSModule.Station.FrmStationPlan.resources index 6e4425a..38333d6 100644 Binary files a/UTS_Core/obj/Debug/UTS_Core.UTSModule.Station.FrmStationPlan.resources and b/UTS_Core/obj/Debug/UTS_Core.UTSModule.Station.FrmStationPlan.resources differ diff --git a/UTS_Core/obj/Debug/UTS_Core.vbproj.AssemblyReference.cache b/UTS_Core/obj/Debug/UTS_Core.vbproj.AssemblyReference.cache index cbb3e57..00cbd48 100644 Binary files a/UTS_Core/obj/Debug/UTS_Core.vbproj.AssemblyReference.cache and b/UTS_Core/obj/Debug/UTS_Core.vbproj.AssemblyReference.cache differ diff --git a/UTS_Core/obj/Debug/UTS_Core.vbproj.CoreCompileInputs.cache b/UTS_Core/obj/Debug/UTS_Core.vbproj.CoreCompileInputs.cache index 625f20c..da7a322 100644 --- a/UTS_Core/obj/Debug/UTS_Core.vbproj.CoreCompileInputs.cache +++ b/UTS_Core/obj/Debug/UTS_Core.vbproj.CoreCompileInputs.cache @@ -1 +1,5 @@ +<<<<<<< HEAD 8992de695cb4747f2d61d8ca9c137991718f6aad703974b1d98d7b62777d4093 +======= +123841b57461e4faf5bdd4496fa809c8ea3dfc46239271d30d61e3bd64bcde7d +>>>>>>> e82bfaaf20ab8230c1840fbb0068ce2e7d5fd4ec diff --git a/UTS_Core/obj/Debug/UTS_Core.xml b/UTS_Core/obj/Debug/UTS_Core.xml index 9a1d437..dcd9d36 100644 --- a/UTS_Core/obj/Debug/UTS_Core.xml +++ b/UTS_Core/obj/Debug/UTS_Core.xml @@ -1513,53 +1513,48 @@ UTS_Core - - - 运行一条需要记录在撤销栈的命令 - - - + 重做命令 - + 撤销命令 - + 运行命令,并将命令添加至撤销堆栈 - + 将命令添加至撤销堆栈 - + 清空撤销命令堆栈 - + 清空重做命令堆栈 - + 清空撤销与重做命令堆栈 - + 执行撤销命令 - + 执行重做命令 @@ -6074,12 +6069,42 @@ UTS_Core 测试流程所关联的项目站包信息 + + 表格控件对象 + + + 表格树状目录起始节点 + + + 起始绘制列 + + + 起始绘制行 + + + 调试模式是否开启 + + + 是否显示节点图标 + 处于更新表格状态中,不触发表格单元格修改事件 多个参数间的分割符号 + + 测试命令管理器 + + + 错误代码管理器 + + + 表格标签字段字典 + + + 表格记录名称字段字典 + 当前活动节点 @@ -6089,11 +6114,8 @@ UTS_Core 节点文本被修改事件 - - 测试命令管理器 - - - 错误代码管理器 + + 节点执行可撤销事件 @@ -6101,11 +6123,6 @@ UTS_Core - - - 对第二行的Action执行一遍操作,以触发更新事件 - - 向后导航 @@ -6135,6 +6152,80 @@ UTS_Core + + + 当前模块名是否已存在 + + + + + + + 当前字段名 + + + + + + + 清空标签名称 + + + + + 清空记录名称 + + + + + 添加标签名称 + + 标签名称 + 行号 + + + + 添加记录名称 + + 记录名 + 行号 + + + + 移出标签名称 + + 标签名称 + + + + 移出记录名称 + + 记录名称 + + + + 获取标签名称行号 + + + + + + + 获取记录名称行号 + + + + + + + 从表格中重载标签名称 + + + + + 从表格中重载记录名称 + + 光标离开grd表格时,黄色底色切换到选中行 @@ -6145,38 +6236,16 @@ UTS_Core 光标进入grd表格时,原底色切换到选中行 - - - 根据CmdType 和 isAction 返回该行字体颜色 - - - 鼠标移动到节点位置时所有子节点背景着色 - + - FixModule节点Action变化时子节点字体重新着色 + 节点类型变更,修改节点行样式 - - - - - FixModule节点Action变化时子节点字体重新着色 - - - - - 根据总表状态对单元格字体重新着色 - - - - - 遍历表格,并更新到全局数组 - - + @@ -6195,16 +6264,6 @@ UTS_Core 选定行使能或清除Action选项 - - - 更新表格内容到缓存,但是并不重新着色 - - - - - 更新ActionEn信息 - - 光标移动时,所在行底色高亮 @@ -6251,6 +6310,12 @@ UTS_Core 初始化测试站表格 + + + 加载测试文件后更新表格 + + + 展开行节点