新增导航功能,节点操作支持多行操作

This commit is contained in:
2025-04-09 19:59:49 +08:00
parent 501fa77e5a
commit 9da8e6fecd
32 changed files with 1326 additions and 953 deletions

View File

@@ -1,8 +1,10 @@
Imports System.Drawing
Imports System.Reflection.Emit
Imports System.Text
Imports System.Web.UI.WebControls
Imports System.Windows.Forms
Imports FlexCell
Imports Steema.TeeChart.Walls
Imports UTS_Core.UTSModule.Production
Imports UTS_Core.UTSModule.Test.Command
Imports UTS_Core.UTSModule.Test.StatusMonitor
@@ -120,6 +122,7 @@ Namespace UTSModule.Station
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
@@ -132,6 +135,7 @@ Namespace UTSModule.Station
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
@@ -174,28 +178,45 @@ Namespace UTSModule.Station
End Sub
Private gCopyWholeRows As Integer '整行复制时记录行数
Private gCopyRow As Integer '整行复制时记录行数
Private gIsCopyRowDataReady As Boolean = False '整行复制时标记,只能复制一次
Public Sub MultiLineCopyData()
Dim tmpFrisRow As Integer = _grd.Selection.FirstRow
Dim tmpLastRow As Integer = _grd.Selection.LastRow
gCopyWholeRows = tmpLastRow - tmpFrisRow + 1
_grd.Range(tmpFrisRow, ColNames.Action, tmpLastRow, _grd.Cols - 1).CopyData()
''' <summary>
''' 向后导航
''' </summary>
Public Sub BackwardNavigation()
GridNavigationManager.Backward()
End Sub
Public Sub MultiLinePasteData()
Dim tmpFrisRow As Integer = _grd.Selection.FirstRow
''' <summary>
''' 向前导航
''' </summary>
Public Sub ForwardNavigation()
GridNavigationManager.Forward()
End Sub
LockGridAutoRedraw()
''' <summary>
''' 是否可以后退
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Public Function CanBackward() As Boolean
Return GridNavigationManager.CanBackward
End Function
'插入节点
NodeAdd(gCopyWholeRows)
''' <summary>
''' 是否可以前进
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Public Function CanForward() As Boolean
Return GridNavigationManager.CanForward
End Function
_grd.Range(tmpFrisRow, ColNames.Action, tmpFrisRow + gCopyWholeRows, _grd.Cols - 1).PasteData()
UnLockGridAutoRedraw()
''' <summary>
'''
''' </summary>
Public Sub ClearNavigation()
GridNavigationManager.Clear()
_lastSelction = Nothing
_lastTempSelction = Nothing
End Sub
'离开表格时活动单元格背景颜色
@@ -1265,11 +1286,41 @@ Namespace UTSModule.Station
RaiseEvent RowNodeTextChanged(sender, args)
End Sub
Private _lastSelction As GridSelectRange
Private _lastTempSelction As GridSelectRange
Private _isSelection As Boolean = False
Private Sub Grid_SelChange(sender As Object, e As Grid.SelChangeEventArgs)
'todo:更新详情表格
If _headNode Is Nothing Then Return
Dim node As RowNode = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1)
If node Is Nothing Then Return
Console.WriteLine($"Grid_SelChange: row:{e.FirstRow} col:{e.FirstCol} end row{e.LastRow} {e.LastCol}")
If Not GridNavigationManager.IsRunning Then
Dim newSelection As New GridSelectRange With {.StartRow = e.FirstRow, .StartCol = e.FirstCol, .EndRow = e.LastRow, .EndCol = e.LastCol}
If _lastSelction IsNot Nothing AndAlso _lastTempSelction IsNot Nothing Then
If _lastTempSelction IsNot Nothing AndAlso _lastTempSelction.StartRow = newSelection.StartRow AndAlso _lastTempSelction.StartCol = newSelection.StartCol Then
_isSelection = True
GridNavigationManager.RemoveForward()
GridNavigationManager.Append(New GridNavigation(_grd, _lastSelction, newSelection))
Else
If _isSelection Then
GridNavigationManager.RemoveForward()
GridNavigationManager.Append(New GridNavigation(_grd, _lastSelction, _lastTempSelction))
GridNavigationManager.Append(New GridNavigation(_grd, _lastTempSelction, newSelection))
_lastSelction = _lastTempSelction
_isSelection = False
Else
GridNavigationManager.Append(New GridNavigation(_grd, _lastTempSelction, newSelection))
If _lastSelction Is Nothing OrElse (_lastSelction.StartRow <> _lastTempSelction.StartRow AndAlso _lastSelction.StartCol <> _lastTempSelction.StartCol) Then _lastSelction = _lastTempSelction
End If
End If
_lastTempSelction = newSelection
Else
_lastTempSelction = newSelection
_lastSelction = _lastTempSelction
End If
End If
ActiveNode = node
@@ -1286,6 +1337,15 @@ Namespace UTSModule.Station
RaiseEvent PlanNodeSelectChanged(sender, event2)
End Sub
Private Sub Grid_LeaveCell(sender As Object, e As Grid.LeaveCellEventArgs)
'If Not GrdiNavigationManager.IsRunning Then
' Dim lastSelection As New GridSelectRange With {.StartRow = e.Row, .StartCol = e.Col, .EndRow = e.Row, .EndCol = e.Col}
' Dim newSelection As New GridSelectRange With {.StartRow = e.NewRow, .StartCol = e.NewCol, .EndRow = e.NewRow, .EndCol = e.NewCol}
' GrdiNavigationManager.Append(New GridNavigation(_grd, lastSelection, newSelection))
' Console.WriteLine($"GridNavigation: row:{e.NewRow} col:{e.NewCol} last row{e.Row} {e.Col}")
'End If
End Sub
Private _dropCol As Integer = 0
Private _dropRow As Integer = 0
@@ -1480,20 +1540,19 @@ Namespace UTSModule.Station
End Sub
Public Sub NodeAdd(rows As Integer)
Public Sub NodeAdd(startMoveRow As Integer, rows As Integer)
Dim idx As Integer
Dim node As RowNode
If rows < 1 Then Return
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
If _headNode Is Nothing Then Return
LockGridAutoRedraw()
Dim row As Integer = _grd.ActiveCell.Row + rows
Dim row As Integer = startMoveRow + rows
For idx = 1 To rows
node = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1)
node = _headNode.RowList(startMoveRow - _drawStartRow + 1)
If node Is Nothing Then Exit For
@@ -1519,19 +1578,18 @@ Namespace UTSModule.Station
UnLockGridAutoRedraw()
End Sub
Public Sub NodeDel(rows As Integer)
Public Sub NodeDel(startMoveRow As Integer, rows As Integer)
Dim idx As Integer
Dim node As RowNode
If rows < 1 Then Return
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
If _headNode Is Nothing Then Return
LockGridAutoRedraw()
Dim row As Integer = _grd.ActiveCell.Row - 1
Dim row As Integer = startMoveRow - 1
For idx = 1 To rows
node = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1)
node = _headNode.RowList(startMoveRow - _drawStartRow + 1)
If node Is Nothing Then Exit For
'更新内存
@@ -1578,62 +1636,220 @@ Namespace UTSModule.Station
End Sub
Public Sub NodeMoveUp(rows As Integer)
Dim node As RowNode
Dim moveDownRow As Integer '下移动前起始位置
Dim moveDownCount As Integer '下移动总量
Dim moveUpRow As Integer '上移动前起始位置
Dim moveUpCount As Integer '上移动总量
If rows < 1 Then Return
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
Public Sub NodeMoveUp(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 isMoveUp As Boolean = True
node = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1)
If node Is Nothing Then Return
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 node.PrevNode Is Nothing Then Return
If prevNode Is Nothing Then Return
moveDownRow = node.PrevNode.RowListIndex '下移动前起始位置
moveDownCount = node.PrevNode.AllChildCount + 1 '下移动总量
'获取所有移动节点信息
lstMoveNodes.Add(node)
For i As Integer = 2 To moveRows
node = _headNode.RowList(startMoveRow - _drawStartRow + i)
If node.RowLever < node.RowLever Then Exit For '高于起始节点级别不移动
If node.RowLever > node.RowLever Then Continue For '低于起始节点级别认为是子节点不记录
moveUpRow = node.RowListIndex '上移动前起始位置
moveUpCount = node.AllChildCount + 1 '上移动总量
moveUpRows += node.AllChildCount + 1
lstMoveNodes.Add(node)
Next
node.MoveUp()
'如果需要上移的节点过多则修改为上一节点下移操作
lstFixNodes.Add(prevNode)
isMoveUp = moveUpRows < prevNode.AllChildCount
UpdateGrid(_grd.Tree.SelectedNode.PrevNode, _grd.Tree.SelectedNode)
If isMoveUp Then
NodeMoveUp(lstFixNodes, lstMoveNodes)
Else
NodeMoveNext(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))
LockGridAutoRedraw()
_uploading = True
Dim grdNode As FlexCell.Node
Dim grdParentNode As FlexCell.Node
Dim preNode As RowNode = downNode(downNode.Count - 1)
For Each node As RowNode In upNode
grdNode = _grd.Tree.FindNode(node.RowListIndex)
grdParentNode = grdNode.Parent
node.Remove()
preNode.ParentNode.InsertNode(preNode.RowIndex + 1, node)
grdNode.Remove()
grdParentNode.Nodes.Insert(node.RowIndex, String.Empty)
UpdateGrid(_grd, node.RowListIndex, node)
'获取表格节点,添加其子节点
Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex)
AddGridTreeNode(pNode, node)
preNode = node
Next
'节点修改
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
_uploading = False
UnLockGridAutoRedraw()
End Sub
Public Sub NodeMoveUp(upNode As List(Of RowNode), downNode As List(Of RowNode))
LockGridAutoRedraw()
_uploading = True
Dim grdNode As FlexCell.Node
Dim grdParentNode As FlexCell.Node
Dim nextNode As RowNode = upNode(0)
For Each node As RowNode In downNode
grdNode = _grd.Tree.FindNode(node.RowListIndex)
grdParentNode = grdNode.Parent
node.Remove()
nextNode.ParentNode.InsertNode(nextNode.RowIndex, node)
grdNode.Remove()
grdParentNode.Nodes.Insert(node.RowIndex, String.Empty)
UpdateGrid(_grd, node.RowListIndex, node)
'获取表格节点,添加其子节点
Dim pNode As FlexCell.Node = _grd.Tree.FindNode(node.RowListIndex)
AddGridTreeNode(pNode, node)
nextNode = node
Next
'节点修改
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
_uploading = False
UnLockGridAutoRedraw()
_grd.Cell(node.RowListIndex, _grd.ActiveCell.Col).SetFocus()
End Sub
Public Sub NodeMoveDown()
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
Public Sub NodeMoveDown(startMoveRow As Integer, moveRows As Integer)
If _headNode Is Nothing Then Return
Dim node As RowNode = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + 1)
If node 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 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()
'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
@@ -1706,27 +1922,16 @@ Namespace UTSModule.Station
''' <summary>
''' 节点升级
''' </summary>
Public Sub NodeMoveLeft(rows As Integer)
Dim node As RowNode
Dim moveDownRow As Integer '下移动前起始位置
Dim moveDownCount As Integer '下移动总量
Dim moveUpRow As Integer '上移动前起始位置
Dim moveUpCount As Integer '上移动总量
Dim nextNode As RowNode
If rows < 1 Then Return
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
Public Sub NodeMoveLeft(startMoveRow As Integer, moveRows As Integer)
If _headNode Is Nothing Then Return
Dim moveLeftSatrtRow As Integer = _grd.ActiveCell.Row
Dim node As RowNode
Dim grdNode As FlexCell.Node
Dim grdParentNode As FlexCell.Node
LockGridAutoRedraw()
_uploading = True
For idx As Integer = 1 To rows
node = _headNode.RowList(moveLeftSatrtRow - _drawStartRow + 1)
For idx As Integer = moveRows To 1 Step -1
node = _headNode.RowList(startMoveRow - _drawStartRow + idx)
Console.WriteLine($"Index:{node.RowListIndex}")
If node Is Nothing Then Exit For
@@ -1735,28 +1940,6 @@ Namespace UTSModule.Station
grdNode = _grd.Tree.FindNode(node.RowListIndex)
grdParentNode = grdNode.Parent
'更新内存
If node.NextNode Is Nothing Then
node.MoveLeft()
grdNode.Remove()
grdParentNode.Parent.Nodes.Insert(grdParentNode.Index + 1, "")
UpdateGrid(_grd, node.RowListIndex, node)
AddGridTreeNode(_grd.Tree.FindNode(node.RowListIndex), node)
Exit For
End If
moveDownRow = node.RowListIndex '下移动前起始位置
moveDownCount = node.AllChildCount + 1 '下移动总量
moveUpRow = node.NextNode.RowListIndex '上移动前起始位置
moveUpCount = 0 '上移动总量
nextNode = node.NextNode
While nextNode IsNot Nothing
moveUpCount += nextNode.AllChildCount + 1
nextNode = nextNode.NextNode
End While
node.MoveLeft()
Console.WriteLine($"Node:{node.RowLever}")
@@ -1764,9 +1947,11 @@ Namespace UTSModule.Station
grdParentNode.Parent.Nodes.Insert(grdParentNode.Index + 1, "")
UpdateGrid(_grd, node.RowListIndex, node)
AddGridTreeNode(_grd.Tree.FindNode(node.RowListIndex), node)
_grd.Cell(node.RowListIndex, _grd.ActiveCell.Col).SetFocus()
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
Next
_uploading = False
UnLockGridAutoRedraw()
End Sub
@@ -1775,20 +1960,18 @@ Namespace UTSModule.Station
''' <summary>
''' 节点降级
''' </summary>
Public Sub NodeMoveRight(rows As Integer)
Dim node As RowNode
If rows < 1 Then Return
If _grd.ActiveCell Is Nothing OrElse _grd.Tree.SelectedNode Is Nothing Then Return
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
LockGridAutoRedraw()
_uploading = True
For idx As Integer = 1 To rows
node = _headNode.RowList(_grd.ActiveCell.Row - _drawStartRow + idx)
For idx As Integer = 1 To moveRows
node = _headNode.RowList(startMoveRow - _drawStartRow + idx)
If node Is Nothing Then Exit For
If node.RowType = RowNode.RowTypeEnum.FixedModule Then Exit For
If node.RowIndex = 0 Then Exit For
@@ -1802,11 +1985,9 @@ Namespace UTSModule.Station
grdPreNode.Nodes.Add("", "")
UpdateGrid(_grd, node.RowListIndex, node)
AddGridTreeNode(_grd.Tree.FindNode(node.RowListIndex), node)
_grd.Cell(node.RowListIndex, _grd.ActiveCell.Col).SetFocus()
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
Next
_uploading = False
UnLockGridAutoRedraw()
End Sub