diff --git a/.gitignore b/.gitignore index 6563abe..da8ee67 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ # .NET编译生成文件 [Bb]in [Oo]bj -[Dd]ebug*/ +[Dd]ebug/ *.pdb *.user *.suo diff --git a/AUTS_ProductEntry/AUTS_ProductEntry.vbproj b/AUTS_ProductEntry/AUTS_ProductEntry.vbproj index 5a05479..704463f 100644 --- a/AUTS_ProductEntry/AUTS_ProductEntry.vbproj +++ b/AUTS_ProductEntry/AUTS_ProductEntry.vbproj @@ -53,9 +53,8 @@ - - False - ..\packages\System.Data.SQLite.dll + + ..\DLL\System.Data.SQLite.dll diff --git a/AUTS_Repair/AUTS_Repair.vbproj b/AUTS_Repair/AUTS_Repair.vbproj index fd59166..2be95d6 100644 --- a/AUTS_Repair/AUTS_Repair.vbproj +++ b/AUTS_Repair/AUTS_Repair.vbproj @@ -94,9 +94,8 @@ - - False - bin\Debug\TeeChart.dll + + ..\DLL\TeeChart.dll @@ -161,9 +160,9 @@ VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb My.Resources Designer + Resources.Designer.vb diff --git a/AUTS_Repair/My Project/Resources.Designer.vb b/AUTS_Repair/My Project/Resources.Designer.vb index 6eea5ab..b9c07e2 100644 --- a/AUTS_Repair/My Project/Resources.Designer.vb +++ b/AUTS_Repair/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' 一个强类型的资源类,用于查找本地化的字符串等。 ''' - _ diff --git a/AUTS_Repair/My Project/Resources.resx b/AUTS_Repair/My Project/Resources.resx index 5e7ae2b..df47c29 100644 --- a/AUTS_Repair/My Project/Resources.resx +++ b/AUTS_Repair/My Project/Resources.resx @@ -119,6 +119,6 @@ - ..\bin\Debug\RepairImage\NoImg40_30.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\NoImg40_30.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/AUTS_Repair/Resources/NoImg40_30.png b/AUTS_Repair/Resources/NoImg40_30.png new file mode 100644 index 0000000..06d2fe5 Binary files /dev/null and b/AUTS_Repair/Resources/NoImg40_30.png differ diff --git a/DLL/TeeChart.dll b/DLL/TeeChart.dll new file mode 100644 index 0000000..f6e9728 Binary files /dev/null and b/DLL/TeeChart.dll differ diff --git a/SQLliteReading/SQLliteReading.vbproj b/SQLliteReading/SQLliteReading.vbproj index 4f146aa..f810e74 100644 --- a/SQLliteReading/SQLliteReading.vbproj +++ b/SQLliteReading/SQLliteReading.vbproj @@ -79,9 +79,8 @@ - - False - ..\packages\System.Data.SQLite.dll + + ..\DLL\System.Data.SQLite.dll diff --git a/UTS_Core/DebugLog/ApplicationLog.vb b/UTS_Core/DebugLog/ApplicationLog.vb new file mode 100644 index 0000000..050ee17 --- /dev/null +++ b/UTS_Core/DebugLog/ApplicationLog.vb @@ -0,0 +1,207 @@ +Imports System.IO +Imports System.Text +Imports System.Windows.Forms + +Namespace DebugLog + ''' + ''' 应用程序日志 + ''' + Public NotInheritable Class ApplicationLog + + ''' 日志文件所在父文件夹路径 + Private Shared _logPath As String = Application.StartupPath + + ''' 日志文件名前缀 + Private Shared _logFilePrefix As String = Application.ProductName + + ''' 日志文件所在路径 + Private Shared _logFilePath As String = $"{LogDirPath}{Path.DirectorySeparatorChar}{LogFilePrefix}_{Date.Now:yyyyMMdd}.Log" + + + + + ''' + ''' 保存日志的文件夹完整路径 + ''' + Public Shared Property LogDirPath As String + Get + If Equals(_logPath, String.Empty) Then + _logPath = Application.StartupPath + End If + Return _logPath + End Get + Set(value As String) + _logPath = value + + _logFilePath = $"{LogDirPath}{Path.DirectorySeparatorChar}{LogFilePrefix}_{Date.Now:yyyyMMdd}.Log" + End Set + End Property + + ''' + ''' 日志文件前缀 + ''' + Public Shared Property LogFilePrefix As String + Get + Return _logFilePrefix + End Get + Set(value As String) + _logFilePrefix = value + _logFilePath = $"{LogDirPath}{Path.DirectorySeparatorChar}{LogFilePrefix}_{Date.Now:yyyyMMdd}.Log" + End Set + End Property + + Public Shared ReadOnly Property LogFilePath() As String + Get + Return _logFilePath + End Get + End Property + + + + ''' + ''' 写入错误信息记录日志 + ''' + ''' + Public Shared Sub WriteErrorLog(ex As Exception) + Dim msg As New StringBuilder + + msg.Append($"{ex.StackTrace} {ex.Message}") + + WriteLog(LogTypes.Error, msg.ToString()) + End Sub + + ''' + ''' 写入流程信息记录日志 + ''' + ''' + Public Shared Sub WriteDebugLog1(msg As String) + WriteLog1(LogTypes.Debug.ToString, msg.ToString()) + End Sub + Public Shared Sub WriteDebugLog(msg As String) + WriteLog(LogTypes.Debug, msg.ToString()) + End Sub + + + ''' + ''' 写入流程信息记录日志 + ''' + ''' + Public Shared Sub WriteInfoLog(msg As String) + WriteLog(LogTypes.Info, msg.ToString()) + End Sub + + ''' + ''' 写入警告信息记录日志 + ''' + ''' + Public Shared Sub WriteWarningLog(msg As String) + WriteLog(LogTypes.Warn, msg.ToString()) + End Sub + + ''' + ''' 写入错误信息记录日志 + ''' + ''' + Public Shared Sub WriteErrorLog(msg As String) + WriteLog(LogTypes.Error, msg.ToString()) + End Sub + + ''' + ''' 写入数据库信息记录日志 + ''' + ''' + Public Shared Sub WriteFatalLog(msg As String) + WriteLog(LogTypes.Fatal, msg.ToString()) + End Sub + + + Private Shared ReadOnly LogLock As New Object() '日志锁,防止多线程同时写日志导致冲突 + + ''' + ''' 将信息入到日志 + ''' + ''' 日志类型 + ''' 日志内容 + Public Shared Sub WriteLog(logType As String, msg As String) + '写入记录入日志文件 + SyncLock LogLock + Try + Dim logString As New StringBuilder + + logString.Append($"[{Date.Now:yyyy-MM-dd HH:mm:ss:fff}]") '日志产生时间 + + logString.Append($"[{logType,-6}]") '日志类型 + + logString.Append($"[{Process.GetCurrentProcess.Id,-6}]") '日志的进程号 + + logString.Append($"[{Threading.Thread.CurrentThread.ManagedThreadId,-4}]") '日志的线程号 + + logString.Append(msg) '日志的消息主题 + + Using sw As StreamWriter = File.AppendText($"{LogDirPath}{Path.DirectorySeparatorChar}{LogFilePrefix}_{Date.Now:yyyyMMdd}.Log") + sw.WriteLine(logString.ToString()) + End Using + + Catch ex As Exception + Console.WriteLine($"Uts WriteLog Error:{ex.Message}") + End Try + + End SyncLock + End Sub + Public Shared Sub WriteLog1(logType As String, msg As String) + '写入记录入日志文件 + SyncLock LogLock + Try + Dim logString As New StringBuilder + + logString.Append($"[{Date.Now:yyyy-MM-dd HH:mm:ss:fff}]") '日志产生时间 + + logString.Append($"[{logType,-6}]") '日志类型 + + logString.Append($"[{Process.GetCurrentProcess.Id,-6}]") '日志的进程号 + + logString.Append($"[{Threading.Thread.CurrentThread.ManagedThreadId,-4}]") '日志的线程号 + + logString.Append(msg) '日志的消息主题 + + Using sw As StreamWriter = File.AppendText($"{LogDirPath}{Path.DirectorySeparatorChar}{logType}_{Date.Now:yyyyMMdd}.Log") + sw.WriteLine(logString.ToString()) + End Using + + Catch ex As Exception + Console.WriteLine($"Uts WriteLog Error:{ex.Message}") + End Try + + End SyncLock + End Sub + ''' + ''' 写日志 + ''' + Public Shared Sub WriteLog(type As LogTypes, ByVal msg As String) + WriteLog(type.ToString(), msg) + End Sub + + + + + ''' + ''' 日志类型 + ''' + Public Enum LogTypes + ''' 调试信息 + Debug + + ''' 系统运行信息 + Info + + ''' 警告信息 + Warn + + ''' 错误信息应该包含对象名、发生错误点所在的方法名称、具体错误信息 + [Error] + + ''' 致命信息 + Fatal + End Enum + End Class +End Namespace \ No newline at end of file diff --git a/UTS_Core/DebugLog/ControlRecord.vb b/UTS_Core/DebugLog/ControlRecord.vb new file mode 100644 index 0000000..53097c9 --- /dev/null +++ b/UTS_Core/DebugLog/ControlRecord.vb @@ -0,0 +1,95 @@ +Imports System.Windows.Forms + +Namespace DebugLog + ''' + ''' 考虑修改为自定义控件 + ''' + Public Class ControlRecord + + Sub New(recordControl As RichTextBox) + ShowRecord = True + SuspendLayout = False + MaxRecordCount = 512 + RtxRecord = recordControl + End Sub + + ''' + ''' 是否在添加内容时先挂起布局 + ''' + ''' + Property SuspendLayout() As Boolean + + ''' + ''' 是否添加记录到控件 + ''' + ''' + Property ShowRecord() As Boolean + + ''' + ''' 控件记录最大行数 + ''' + ''' + Property MaxRecordCount() As Integer + + + ''' + ''' 需要被添加数据记录的控件句柄 + ''' + ''' + Property RtxRecord() As RichTextBox + + ''' + ''' 清空内容 + ''' + Public Sub Clear() + If RtxRecord Is Nothing Then Return + RtxRecord.Clear() + End Sub + + Public Sub AppendRecord(logString As String) + If ShowRecord = False Then Return + If RtxRecord Is Nothing Then Return + + If RtxRecord.InvokeRequired Then '判断是否需要开委托 + RtxRecord.Invoke(New Action(Of String)(AddressOf AppendRecord), New Object() {logString}) + Return + End If + + With RtxRecord + If SuspendLayout Then + .SuspendLayout() + + If .Lines.Length > MaxRecordCount Then '超过上限则移除最初行内容 + .ReadOnly = False + .SelectionStart = 0 + .SelectionLength = .GetFirstCharIndexFromLine(1) + .SelectedText = String.Empty + .ReadOnly = True + .SelectionStart = .TextLength + End If + + .AppendText($"{Now:yyyy:MM:dd HH:mm:ss} - {logString}{vbNewLine}") + + .ScrollToCaret() + + .ResumeLayout(False) + Else + If .Lines.Length > MaxRecordCount Then '超过上限则移除最初行内容 + .ReadOnly = False + .SelectionStart = 0 + .SelectionLength = .GetFirstCharIndexFromLine(1) + .SelectedText = String.Empty + .ReadOnly = True + .SelectionStart = .TextLength + End If + + .AppendText($"{Now:yyyy:MM:dd HH:mm:ss} - {logString}{vbNewLine}") + + .ScrollToCaret() + + End If + End With + End Sub + + End Class +End Namespace \ No newline at end of file diff --git a/UTS_Core/DebugLog/CsDataLog.vb b/UTS_Core/DebugLog/CsDataLog.vb new file mode 100644 index 0000000..e27901a --- /dev/null +++ b/UTS_Core/DebugLog/CsDataLog.vb @@ -0,0 +1,94 @@ +Imports System.IO +''' +''' 日志类 +''' +Public NotInheritable Class CsDataLog + ''' + ''' 日志类型 + ''' + Public Enum LogType + ''' 堆栈跟踪信息 + Trace + ''' 警告信息 + Warning + ''' 错误信息应该包含对象名、发生错误点所在的方法名称、具体错误信息 + [Error] + ''' 与数据库相关的信息 + SQL + End Enum + + + ''' 日志文件所在路径 + Private Shared _logPath = String.Empty + + ''' 日志前缀说明信息 + Private Shared _logFilePrefix = String.Empty + + ''' + ''' 保存日志的文件夹 + ''' + Public Shared Property LogPath As String + Get + + If Equals(_logPath, String.Empty) Then + _logPath = Application.StartupPath + End If + Return _logPath + End Get + Set(ByVal value As String) + _logPath = value + End Set + End Property + + ''' + ''' 日志文件前缀 + ''' + Public Shared Property LogFilePrefix As String + Get + Return _logFilePrefix + End Get + Set(ByVal value As String) + _logFilePrefix = value + End Set + End Property + + ''' + ''' + ''' + ''' + Public Shared Sub WriteErrorLog(ex As Exception) + Dim msg As String = String.Empty + msg &= $"ErrorMessage:{ex.Message}{vbNewLine}" + msg &= $"ErrorTime:{Now}{vbNewLine}" + msg &= $"ErrorSource:{ex.Source}{vbNewLine}" + msg &= $"ErrorType:{ex.GetType}{vbNewLine}" + msg &= $"ErrorTargetSite:{ex.TargetSite}{vbNewLine}" + msg &= $"ErrorStackTrace:{ex.StackTrace}{vbNewLine}" + WriteLog(LogType.Error, msg) + End Sub + + ''' + ''' 将信息入到日志 + ''' + ''' 日志类型 + ''' 日志内容 + Public Shared Sub WriteLog(ByVal logType As String, ByVal msg As String) + Dim sw As StreamWriter = Nothing + Try + '同一天同一类日志以追加形式保存 + sw = File.AppendText($"{LogPath}{Path.DirectorySeparatorChar}{LogFilePrefix}_{Date.Now:yyyyMMdd}.Log") + sw.WriteLine(logType & "#" & Date.Now.ToString("yyyy-MM-dd HH:mm:ss: ") & msg) + Catch + Finally + sw.Close() + End Try + End Sub + + ''' + ''' 写日志 + ''' + Public Shared Sub WriteLog(type As LogType, ByVal msg As String) + WriteLog(type.ToString(), msg) + End Sub + +End Class diff --git a/UTS_Core/DebugLog/CsDebugPrint.vb b/UTS_Core/DebugLog/CsDebugPrint.vb new file mode 100644 index 0000000..56843dd --- /dev/null +++ b/UTS_Core/DebugLog/CsDebugPrint.vb @@ -0,0 +1,60 @@ +Public NotInheritable Class CsDebugPrint + Enum EnDebugType + System + ComPort + Network + Ftp + End Enum + + ''' 是否需要打印调试信息 + Public Shared Property IsDebug As Boolean = True + + + ''' + ''' 打印调试信息 + ''' + ''' 需要打印的信息 + Public Shared Sub DebugPrint(message As String) + If IsDebug Then + Console.WriteLine(message) + End If + End Sub + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As String, msg As String) + DebugPrint($"[{type}]{msg}") + End Sub + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As EnDebugType, msg As String) + DebugPrint(type.ToString, msg) + End Sub + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印信息的提示前缀 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As String, tip As String, msg As String) + DebugPrint(type, $"{tip}:{msg}") + End Sub + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印信息的提示前缀 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As EnDebugType, tip As String, msg As String) + DebugPrint(type.ToString, $"{tip}:{msg}") + End Sub +End Class diff --git a/UTS_Core/DebugLog/DebugPrint.vb b/UTS_Core/DebugLog/DebugPrint.vb new file mode 100644 index 0000000..6582eaf --- /dev/null +++ b/UTS_Core/DebugLog/DebugPrint.vb @@ -0,0 +1,119 @@ +Imports System.Text + +Namespace DebugLog + Public Class DebugPrintClass + Enum DebugPrintType + System + Comport + Database + NetWork + Ftp + End Enum + + ''' + ''' 显示所有数据,优先度最高 + ''' + ''' + Public Shared Property ShowAllData() As Boolean = True + + ''' + ''' 是否显示系统信息 + ''' + ''' + Public Shared Property ShowSystemData() As Byte = 1 + + ''' + ''' 是否显示串口信息 + ''' + ''' + Public Shared Property ShowComportData() As Byte = 1 + + ''' + ''' 是否显示数据库信息 + ''' + ''' + Public Shared Property ShowDatabaseData() As Byte = 1 + + ''' + ''' 是否显示网络信息 + ''' + ''' + Public Shared Property ShowNetWorkData() As Byte = 1 + + ''' + ''' 是否显示Ftp信息 + ''' + ''' + Public Shared Property ShowFtpData() As Byte = 1 + + ''' + ''' 显示信息的集合,对应数据位为1则打印,为0不打印 + ''' + ''' + Public Shared Property ShowDataType() As Integer = ShowSystemData >> DebugPrintType.System Or + ShowComportData >> DebugPrintType.Comport Or + ShowDatabaseData >> DebugPrintType.Database Or + ShowNetWorkData >> DebugPrintType.NetWork Or + ShowFtpData >> DebugPrintType.Ftp + + + ''' + ''' 是否添加时间前缀 + ''' + ''' + Public Shared Property ShowTime() As Boolean = True + + ''' + ''' 是否显示与上包显示的间隔 + ''' + ''' + Public Shared Property ShowTimeSpan() As Boolean = True + + + Private Shared _lastShowTime As DateTime = Now + + Private Shared _timeSpan As TimeSpan + + ''' + ''' 打印调试信息 + ''' + ''' 需要打印的信息 + Private Shared Sub DebugPrint(printString As String) + Console.WriteLine(printString) + End Sub + + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As DebugPrintType, printString As String) + If ShowAllData = False Then Return + If ((ShowDataType >> type) And 1) = 0 Then Return + + _timeSpan = Now - _lastShowTime + _lastShowTime = Now + + Dim msgBuilder As New StringBuilder + If ShowTime Then msgBuilder.Append($"{Now:yyyy-MM-dd HH:mm:ss} - ") + If ShowTimeSpan Then msgBuilder.Append($"{_timeSpan.TotalMilliseconds,8} - ") + msgBuilder.Append($"{type} - ") + msgBuilder.Append($"{printString}") + + DebugPrint(msgBuilder.ToString()) + End Sub + + + ''' + ''' 打印调试信息 + ''' + ''' 打印信息类型 + ''' 需要打印信息的提示前缀 + ''' 需要打印的信息 + Public Shared Sub DebugPrint(type As DebugPrintType, tip As String, printString As String) + DebugPrint(type, $"{tip}:{printString}") + End Sub + + End Class +End Namespace \ No newline at end of file diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeAddCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeAddCommand.vb new file mode 100644 index 0000000..d8b194b --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeAddCommand.vb @@ -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 diff --git a/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeDeleteCommand.vb b/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeDeleteCommand.vb new file mode 100644 index 0000000..e968ca1 --- /dev/null +++ b/UTS_Core/UTSModule/Station/GridNodeCommands/GridControlNodeDeleteCommand.vb @@ -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 diff --git a/UTS_Core/UTSModule/Station/StationPlanGrid.vb b/UTS_Core/UTSModule/Station/StationPlanGrid.vb index a5600df..320ea7a 100644 --- a/UTS_Core/UTSModule/Station/StationPlanGrid.vb +++ b/UTS_Core/UTSModule/Station/StationPlanGrid.vb @@ -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 + + + + ''' ''' 获取指定行的NodeIndex ''' @@ -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 + ''' + ''' 子级节点添加 + ''' + ''' + ''' + 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 + + + ''' + ''' 同级节点添加 + ''' + ''' + ''' + ''' 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) diff --git a/UTS_Core/UTS_Core.vbproj b/UTS_Core/UTS_Core.vbproj index 661d672..291373a 100644 --- a/UTS_Core/UTS_Core.vbproj +++ b/UTS_Core/UTS_Core.vbproj @@ -130,7 +130,7 @@ - ..\AUTS_Repair\bin\Debug\TeeChart.dll + ..\DLL\TeeChart.dll ..\packages\MySql.Data.8.0.26\lib\net48\Ubiety.Dns.Core.dll @@ -200,6 +200,8 @@ + +