添加IF逻辑字段的着色逻辑,添加IF与ElseIF节点新增时附加其子节点
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
Imports UTS_Core.UTSModule.Station
|
||||
|
||||
Public Class GridControlNodeAddCommand : Implements ICommand
|
||||
Private ReadOnly grd As StationPlanGrid
|
||||
Private ReadOnly startMoveRow As Integer
|
||||
Private ReadOnly nodes As List(Of RowNode)
|
||||
|
||||
Sub New(grd As StationPlanGrid, startMoveRow As Integer, nodes As List(Of RowNode))
|
||||
Me.grd = grd
|
||||
Me.startMoveRow = startMoveRow
|
||||
Me.nodes = nodes
|
||||
End Sub
|
||||
|
||||
Public Sub Redo() Implements ICommand.Redo
|
||||
grd.NodeAddChildCommand(startMoveRow, nodes)
|
||||
End Sub
|
||||
|
||||
Public Sub Undo() Implements ICommand.Undo
|
||||
grd.NodeDeleteChildCommand(startMoveRow, nodes)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -0,0 +1,21 @@
|
||||
Imports UTS_Core.UTSModule.Station
|
||||
|
||||
Public Class GridControlNodeDeleteCommand : Implements ICommand
|
||||
Private ReadOnly grd As StationPlanGrid
|
||||
Private ReadOnly startMoveRow As Integer
|
||||
Private ReadOnly nodes As List(Of RowNode)
|
||||
|
||||
Sub New(grd As StationPlanGrid, startMoveRow As Integer, nodes As List(Of RowNode))
|
||||
Me.grd = grd
|
||||
Me.startMoveRow = startMoveRow
|
||||
Me.nodes = nodes
|
||||
End Sub
|
||||
|
||||
Public Sub Redo() Implements ICommand.Redo
|
||||
grd.NodeDeleteChildCommand(startMoveRow, nodes)
|
||||
End Sub
|
||||
|
||||
Public Sub Undo() Implements ICommand.Undo
|
||||
grd.NodeAddChildCommand(startMoveRow, nodes)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -1,6 +1,8 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports FlexCell
|
||||
Imports FluentFTP
|
||||
Imports Mysqlx.XDevAPI.Relational
|
||||
Imports UTS_Core.UTSModule.Production
|
||||
Imports UTS_Core.UTSModule.Test.Command
|
||||
Imports UTS_Core.UTSModule.Test.StatusMonitor
|
||||
@@ -487,17 +489,20 @@ Namespace UTSModule.Station
|
||||
Dim tmpCurrRowIdx As Integer = startRowIdx
|
||||
Dim tmpCurrRowNodeLevel As Integer = GetRowNodeLevel(grd, tmpCurrRowIdx)
|
||||
'判断当前行Row type = 1,记录下本行的NodeLevel = tempNodeLevel,记录NodeLstIndx
|
||||
If rowType = RowNode.RowTypeEnum.Module Then
|
||||
'从起始行开始往下遍历
|
||||
Do
|
||||
If tmpCurrRowIdx < Grid.Rows Then '遍历到最大行还未结束
|
||||
tmpCurrRowIdx = tmpCurrRowIdx + 1
|
||||
tmpCurrRowNodeLevel = GetRowNodeLevel(grd, tmpCurrRowIdx)
|
||||
Else
|
||||
Return
|
||||
End If
|
||||
Loop Until tmpCurrRowNodeLevel <= startRowNodeLevel Or tmpCurrRowIdx >= Grid.Rows '再次遍历到与起始行同级或更高级别的行,就算是该节点遍历结束
|
||||
endRowNodeIdx = tmpCurrRowIdx - 1
|
||||
|
||||
Dim node As RowNode = _headNode.RowList(startRowIdx - _drawStartRow + 1)
|
||||
If rowType = RowNode.RowTypeEnum.Module OrElse rowType = RowNode.RowTypeEnum.Control Then
|
||||
''从起始行开始往下遍历
|
||||
'Do
|
||||
' If tmpCurrRowIdx < Grid.Rows Then '遍历到最大行还未结束
|
||||
' tmpCurrRowIdx = tmpCurrRowIdx + 1
|
||||
' tmpCurrRowNodeLevel = GetRowNodeLevel(grd, tmpCurrRowIdx)
|
||||
' Else
|
||||
' Return
|
||||
' End If
|
||||
'Loop Until tmpCurrRowNodeLevel <= startRowNodeLevel Or tmpCurrRowIdx >= Grid.Rows '再次遍历到与起始行同级或更高级别的行,就算是该节点遍历结束
|
||||
'endRowNodeIdx = tmpCurrRowIdx - 1
|
||||
endRowNodeIdx = startRowIdx + node.AllChildCount
|
||||
|
||||
'底色着色
|
||||
LockGridAutoRedraw()
|
||||
@@ -681,6 +686,8 @@ Namespace UTSModule.Station
|
||||
_grd.Cell(gMouseOldRow, gMouseOldCol).FontBold = False
|
||||
If gOldRowType = RowNode.RowTypeEnum.Module Then '光标离开Module节点
|
||||
Mouse_MoveOnNode_BackColorRepain(_grd, gOldRowType, gMouseOldRow, Color.White)
|
||||
ElseIf gOldRowType = RowNode.RowTypeEnum.Control Then '光标离开Module节点
|
||||
Mouse_MoveOnNode_BackColorRepain(_grd, gOldRowType, gMouseOldRow, Color.White)
|
||||
End If
|
||||
End If
|
||||
gMouseOldRow = tmpMouseRow
|
||||
@@ -691,6 +698,8 @@ Namespace UTSModule.Station
|
||||
_grd.Cell(tmpMouseRow, tmpMouseCol).FontBold = True
|
||||
If gRowType = RowNode.RowTypeEnum.Module Then '光标移动到module节点
|
||||
Mouse_MoveOnNode_BackColorRepain(_grd, gRowType, tmpMouseRow, Color.FromArgb(40, Color.LemonChiffon))
|
||||
ElseIf gRowType = RowNode.RowTypeEnum.Control Then
|
||||
Mouse_MoveOnNode_BackColorRepain(_grd, gRowType, tmpMouseRow, Color.FromArgb(40, Color.LemonChiffon))
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -701,6 +710,10 @@ Namespace UTSModule.Station
|
||||
gIsGri_MouseMove_EventReady = True
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 获取指定行的NodeIndex
|
||||
''' </summary>
|
||||
@@ -845,7 +858,7 @@ Namespace UTSModule.Station
|
||||
.Column(ColNames.Pause).Width = 20
|
||||
.Column(ColNames.Action).Width = 20
|
||||
.Column(ColNames.Description).Width = 200
|
||||
.Column(ColNames.ControlType).Width = 50
|
||||
.Column(ColNames.ControlType).Width = 80
|
||||
.Column(ColNames.CommandType).Width = 80
|
||||
.Column(ColNames.Command).Width = 120
|
||||
.Column(ColNames.Parameters).Width = 340
|
||||
@@ -1185,8 +1198,51 @@ Namespace UTSModule.Station
|
||||
node.ControlType = _grd.Cell(e.Row, e.Col).Text
|
||||
If String.IsNullOrWhiteSpace(node.ControlType) Then
|
||||
node.RowType = RowNode.RowTypeEnum.Flow
|
||||
|
||||
Dim cmd As New GridControlNodeDeleteCommand(Me, e.Row, node.Children)
|
||||
CommandManager.RunCommand(cmd) '添加到撤销堆栈执行
|
||||
RaiseEvent PlanGridCommandChanged(Nothing, Nothing)
|
||||
'clear
|
||||
Else
|
||||
node.RowType = RowNode.RowTypeEnum.Control
|
||||
Dim nodes As New List(Of RowNode)
|
||||
Dim tmpNode As New RowNode
|
||||
If node.ControlType = "If" Then
|
||||
tmpNode.RowType = RowNode.RowTypeEnum.Control
|
||||
tmpNode.ControlType = "Then"
|
||||
tmpNode.AddNode(New RowNode)
|
||||
tmpNode.AddNode(New RowNode)
|
||||
nodes.Add(tmpNode)
|
||||
nodes.Add(New RowNode) '添加空行
|
||||
|
||||
tmpNode = New RowNode
|
||||
tmpNode.RowType = RowNode.RowTypeEnum.Control
|
||||
tmpNode.ControlType = "ElseIf"
|
||||
tmpNode.AddNode(New RowNode)
|
||||
tmpNode.AddNode(New RowNode)
|
||||
nodes.Add(tmpNode)
|
||||
nodes.Add(New RowNode) '添加空行
|
||||
|
||||
tmpNode = New RowNode
|
||||
tmpNode.RowType = RowNode.RowTypeEnum.Control
|
||||
tmpNode.ControlType = "Else"
|
||||
tmpNode.AddNode(New RowNode)
|
||||
tmpNode.AddNode(New RowNode)
|
||||
nodes.Add(tmpNode)
|
||||
nodes.Add(New RowNode) '添加空行
|
||||
|
||||
Dim cmd As New GridControlNodeAddCommand(Me, e.Row, nodes)
|
||||
CommandManager.RunCommand(cmd) '添加到撤销堆栈执行
|
||||
RaiseEvent PlanGridCommandChanged(Nothing, Nothing)
|
||||
ElseIf node.ControlType = "ElseIf" Then
|
||||
nodes.Add(New RowNode)
|
||||
nodes.Add(New RowNode)
|
||||
|
||||
Dim cmd As New GridControlNodeAddCommand(Me, e.Row, nodes)
|
||||
CommandManager.RunCommand(cmd) '添加到撤销堆栈执行
|
||||
RaiseEvent PlanGridCommandChanged(Nothing, Nothing)
|
||||
End If
|
||||
|
||||
End If
|
||||
changeType = RowNodeChangedEventArgs.RowNodeChangeType.ControlType
|
||||
|
||||
@@ -1567,7 +1623,70 @@ Namespace UTSModule.Station
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 子级节点添加
|
||||
''' </summary>
|
||||
''' <param name="startMoveRow"></param>
|
||||
''' <param name="nodes"></param>
|
||||
Friend Sub NodeAddChildCommand(startMoveRow As Integer, nodes As List(Of RowNode))
|
||||
Dim node As RowNode
|
||||
Dim startNode As RowNode = _headNode.RowList(startMoveRow - _drawStartRow + 1)
|
||||
Dim grdNode As FlexCell.Node = _grd.Tree.FindNode(startMoveRow)
|
||||
LockGridAutoRedraw()
|
||||
_uploading = True
|
||||
|
||||
For i As Integer = 0 To nodes.Count - 1
|
||||
'更新内存
|
||||
node = nodes(i)
|
||||
|
||||
'在当前节点插入节点
|
||||
startNode.AddNode(node)
|
||||
|
||||
'更新控件
|
||||
grdNode.Nodes.Add("", "")
|
||||
UpdateGrid(_grd, node.RowListIndex, node)
|
||||
|
||||
Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex)
|
||||
AddGridTreeNode(pNode, node)
|
||||
Next
|
||||
|
||||
_uploading = False
|
||||
UnLockGridAutoRedraw()
|
||||
End Sub
|
||||
|
||||
Friend Sub NodeDeleteChildCommand(startMoveRow As Integer, nodes As List(Of RowNode))
|
||||
LockGridAutoRedraw()
|
||||
_uploading = True
|
||||
|
||||
Dim node As RowNode
|
||||
Dim grdNode As FlexCell.Node
|
||||
For i As Integer = 0 To nodes.Count - 1
|
||||
node = nodes(i) '前面节点已删除,所以每次都是固定位置
|
||||
If node Is Nothing Then Exit For
|
||||
|
||||
'更新控件
|
||||
grdNode = _grd.Tree.FindNode(node.RowListIndex)
|
||||
grdNode.Remove()
|
||||
|
||||
'更新内存
|
||||
If node.CanDelete = False Then Exit For
|
||||
node.Remove()
|
||||
|
||||
'其他操作
|
||||
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
|
||||
Next
|
||||
|
||||
_uploading = False
|
||||
UnLockGridAutoRedraw()
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 同级节点添加
|
||||
''' </summary>
|
||||
''' <param name="startMoveRow"></param>
|
||||
''' <param name="rows"></param>
|
||||
''' <param name="nodes"></param>
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user