添加撤销,导航Call命令,节点类型根据子节点数量变化,标签和记录名去重等功能
This commit is contained in:
@@ -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
|
||||
|
||||
''' <summary>
|
||||
''' 运行命令,并将命令添加至撤销堆栈
|
||||
''' </summary>
|
||||
''' <param name="command"></param>
|
||||
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
|
||||
|
||||
''' <summary>
|
||||
''' 将命令添加至撤销堆栈
|
||||
''' </summary>
|
||||
Public Sub AddUndoCommand(command As ICommand)
|
||||
UndoCommands.Push(command)
|
||||
|
||||
If RedoCommands.Count > 0 Then
|
||||
ClearRedoCommands()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 清空撤销命令堆栈
|
||||
''' </summary>
|
||||
Public Sub ClearUndoCommands()
|
||||
UndoCommands.Clear()
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 清空重做命令堆栈
|
||||
''' </summary>
|
||||
Public Sub ClearRedoCommands()
|
||||
RedoCommands.Clear()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 清空撤销与重做命令堆栈
|
||||
''' </summary>
|
||||
Public Sub ClearCommands()
|
||||
ClearUndoCommands()
|
||||
ClearRedoCommands()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 执行撤销命令
|
||||
''' </summary>
|
||||
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
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 执行重做命令
|
||||
''' </summary>
|
||||
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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,25 @@
|
||||
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, moveEndRow As Integer)
|
||||
Me.grd = grd
|
||||
Me.startMoveRow = startMoveRow
|
||||
Me.moveRows = moveRows
|
||||
Me.moveEndRow = moveEndRow
|
||||
End Sub
|
||||
|
||||
Public Sub Redo() Implements ICommand.Redo
|
||||
grd.NodeMoveUpCommand(startMoveRow, moveRows)
|
||||
End Sub
|
||||
|
||||
Public Sub Undo() Implements ICommand.Undo
|
||||
grd.NodeMoveDownCommand(moveEndRow, moveRows)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -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
|
||||
11
UTS_Core/UTSModule/Station/GridNodeCommands/ICommand.vb
Normal file
11
UTS_Core/UTSModule/Station/GridNodeCommands/ICommand.vb
Normal file
@@ -0,0 +1,11 @@
|
||||
Public Interface ICommand
|
||||
''' <summary>
|
||||
''' 重做命令
|
||||
''' </summary>
|
||||
Sub Redo()
|
||||
|
||||
''' <summary>
|
||||
''' 撤销命令
|
||||
''' </summary>
|
||||
Sub Undo()
|
||||
End Interface
|
||||
Reference in New Issue
Block a user