Imports FlexCell Imports FlexCell.Grid Public Class ActionParameter ''' ''' 设备对象基类信息 ''' ''' Private Dic_1, Dic_3, Dic_5, Dic_4 As List(Of String) Private Dic_2 As Dictionary(Of String, List(Of String)) Private g_BasicClasses As DeviceObjectClasses Private g_nodename As String Public g_ExecutionMode As String Public g_DevNodename As String Public KeyName As String '输入输出值 Public G_input As String Public G_Result As String Private ParamDic As Dictionary(Of String, Dictionary(Of String, String)) Private Sub ActionParameter_Load(sender As Object, e As EventArgs) Handles MyBase.Load '时间 Dic_3 = New List(Of String) '单位 Dic_4 = New List(Of String) Dic_5 = New List(Of String) ParamDic = New Dictionary(Of String, Dictionary(Of String, String)) ' 第一个为默认值 For i = 0 To 255 If i < 11 AndAlso i > 0 Then Dic_5.Add(i) End If Dic_3.Add(i) Next initCmdGrid() '第一个为默认值 Dic_4.AddRange({"秒", "毫秒", "分钟", "小时", "天"}) If String.IsNullOrEmpty(G_input) OrElse G_input.Equals("高级") Then Else setrowdata(G_input) End If ComboBox1.SelectedIndex = 0 'Button4_Click(Nothing, Nothing) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim buf() As String G_Result = "" Dim desc As String = String.Empty Dim Resli As Dictionary(Of String, String) If Not (CmdGrid.Rows > 1) Then If MsgBox("未选择设备方法!!", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() Return End If Return End If Dim gparstr As String = String.Empty For i = 1 To CmdGrid.Rows - 1 gparstr = CmdGrid.Cell(i, 2).Text Resli = ParamDic.Item(gparstr) For Each index In Resli G_Result = $"{G_Result}{index.Value }{index.Key },{gparstr}{vbLf }" Next Next If G_Result.Length > 0 Then G_Result = G_Result.Substring(0, G_Result.Length - 1) End If Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() Return End Sub Public Sub GetEquipmentParameter(devtype As String, datastr As String, BasicClasses As DeviceObjectClasses) If IsNothing(BasicClasses) Then MsgBox("基类加载失败!") Return End If g_BasicClasses = BasicClasses g_nodename = devtype GetDevTypeParameter(devtype) initTable() AddTableRow() ComboBox1.Items.AddRange(Dic_1.ToArray) inittable2(Dic_1) G_input = datastr End Sub Public Sub inittable2(li As List(Of String)) If IsNothing(li) Then Return Grid1.Rows = li.Count + 1 Grid1.Cols = 2 Grid1.ExtendLastCol = True Grid1.Column(0).Visible = True Grid1.Locked = True Grid1.Cell(0, 1).Text = "设备方法名稱" For index = 0 To li.Count - 1 Grid1.Cell(index + 1, 1).Text = li.Item(index) Next End Sub Private Sub setrowdata(datastr As String) If String.IsNullOrEmpty(datastr) Then Return Dim cmdpar() As String = datastr.Split(vbLf) If IsNothing(cmdpar) OrElse cmdpar.Length = 0 Then Return Dim bli As Dictionary(Of String, String) For Each node In cmdpar Dim bufstr() As String = node.Split(",") Dim keystr As String = String.Empty If bufstr.Length > 2 Then keystr = $"{ bufstr(bufstr.Length - 1)}" If ParamDic.ContainsKey(keystr) Then bli = ParamDic.Item(keystr) Dim cvstr As String = String.Empty For Each nodeindex In bufstr If nodeindex.Equals(bufstr(bufstr.Length - 2)) Then Exit For End If cvstr = $"{cvstr}{nodeindex}," Next If cvstr.Length > 0 Then bli.Add(bufstr(bufstr.Length - 2), cvstr) End If Else bli = New Dictionary(Of String, String) Dim cvstr As String = String.Empty For Each nodeindex In bufstr If nodeindex.Equals(bufstr(bufstr.Length - 2)) Then Exit For End If cvstr = $"{cvstr}{nodeindex}," Next If cvstr.Length > 0 Then bli.Add(bufstr(bufstr.Length - 2), cvstr) ParamDic.Add(keystr, bli) CmdGrid.AddItem("") CmdGrid.Cell(CmdGrid.Rows - 1, 1).Text = bufstr(bufstr.Length - 2) CmdGrid.Cell(CmdGrid.Rows - 1, 2).Text = bufstr(bufstr.Length - 1) End If End If End If Next 'Dim buf() As String = node.Split(",") 'For i = 0 To Dic_1.Count - 1 ' Dim Index As String = Dic_1(i) ' If Index.Equals(buf(buf.Length - 1)) Then ' ComboBox1.SelectedIndex = i ' Exit For ' End If 'Next 'Dim timeint As Integer = -1 'Dim timecint As Integer = -1 'If Not (Integer.TryParse(buf(0), timeint) And Integer.TryParse(buf(1), timecint)) Then ' Return 'End If 'If Table_Grid1.Rows > 2 Then ' If timeint >= 0 OrElse timeint <= 255 Then ' Table_Grid1.Cell(1, 2).Text = timeint.ToString ' End If ' If timecint >= 1 OrElse timecint <= 5 Then ' Table_Grid1.Cell(2, 2).Text = FGetDelayUnit(timecint) ' End If 'End If 'Dim parbuf() As String 'If Not IsNothing(Dic_2) AndAlso Dic_2.Count > 0 Then ' If Table_Grid1.Rows > (Dic_2.Count) Then ' For i = 0 To Dic_2.Count - 3 ' Dim li As List(Of String) = Dic_2.Item(Table_Grid1.Cell(i + 3, 1).Text) ' For Each strinf In li ' parbuf = strinf.Split(" ") ' If buf(2 + i).Equals(parbuf(0)) Then ' Table_Grid1.Cell(3 + i, 2).Text = strinf ' End If ' Next ' Next ' End If 'End If End Sub Private Sub AddTableRow() ' Table_Grid1.AddItem("") 'Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "设备方法" End Sub Private Sub GetDevTypeParameter(devtype As String) Dic_1 = New List(Of String) For Each node In g_BasicClasses.DeviceClass If node.Name.ToUpper.Equals(devtype) Then For Each Anode In node.Methods Dic_1.Add(Anode.Name) Next End If Next End Sub Private Sub Table_Grid1_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs) Handles Table_Grid1.ComboDropDown If e.Row > 0 Then Me.Table_Grid1.ComboBox(e.Col).Items.Clear() Dim liname As String = Table_Grid1.Cell(e.Row, 1).Text Dim liname2 As String = Table_Grid1.Cell(e.Row - 1, 2).Text Dim li As List(Of String) = Dic_2.Item(liname) Me.Table_Grid1.ComboBox(e.Col).Items.AddRange(li.ToArray) If ComboBox1.Text.Equals("音量高级设置") AndAlso liname.Equals("选项") AndAlso liname2.Equals("1 静音") Then Me.Table_Grid1.ComboBox(e.Col).Items.RemoveAt(0) Me.Table_Grid1.ComboBox(e.Col).Items.RemoveAt(0) End If End If End Sub Public Sub AddParameterrow() Dim rcon As Integer = Table_Grid1.Rows - 1 Dim delete As Integer = 0 Dim nodename As String = ComboBox1.Text Dic_2 = New Dictionary(Of String, List(Of String)) Dic_2.Clear() For i = 0 To rcon If i > 0 Then Table_Grid1.Row(Table_Grid1.Rows - 1).Delete() End If Next Dic_2.Add("延时时间", Dic_3) Table_Grid1.AddItem("") Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "延时时间" Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = "0" Dic_2.Add("延时单位", Dic_4) Dic_2.Add("音量值", Dic_5) Table_Grid1.AddItem("") Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "延时单位" Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = "秒" For Each node In g_BasicClasses.DeviceClass If node.Name.ToUpper.Equals(g_nodename) Then For Each Anode In node.Methods If Anode.Name.Equals(nodename) Then For Each index In Anode.Params Dim li As New List(Of String) If index.Name.Equals("无") Then li.Add(0) Else If index.DataType.Equals("List") Then Dim tbuf() As String = index.DataRange.Split(",") li.AddRange(tbuf) li.Remove(tbuf(0)) li.Insert(0, tbuf(0)) ElseIf index.DataType.Equals("Integer") Then Dim buf() As String = index.DataRange.Split(",") Dim startint As Integer = 0 Dim endint As Integer = 1 Integer.TryParse(buf(0), startint) Integer.TryParse(buf(1), endint) 'li.Add(startint) For i = startint To endint li.Add(i) Next li.Remove(index.DataDefault) li.Insert(0, index.DataDefault) End If End If If Not Dic_2.ContainsKey(index.Name) Then Dic_2.Add(index.Name, li) End If Table_Grid1.AddItem("") Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = index.Name Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = index.DataDefault Next Exit For End If Next End If Next 'Console.WriteLine(g_nodename) 'If g_nodename.ToUpper.Contains("MUSIC") Then ' Dim li As New List(Of String) ' For i = 0 To 100 ' li.Add(i) ' Next ' Dic_2.Add("音量", li) ' Table_Grid1.AddItem("") ' Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "音量" ' Table_Grid1.Cell(Table_Grid1.Rows - 1, 2).Text = "0" 'End If End Sub Public Sub initTable() Table_Grid1.Rows = 1 Table_Grid1.Cols = 3 Table_Grid1.ExtendLastCol = True Table_Grid1.DrawMode = DrawModeEnum.OwnerDraw Table_Grid1.Cell(0, 1).Text = "属性" Table_Grid1.Cell(0, 2).Text = "属性值" ' Table_Grid1.Cell(0, 3).Text = "设备端口" Table_Grid1.Column(1).Width = 130 Table_Grid1.Column(2).Width = 100 Table_Grid1.Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter With Table_Grid1.Column(2) .Alignment = FlexCell.AlignmentEnum.CenterCenter .CellType = CellTypeEnum.ComboBox End With Table_Grid1.Column(1).Locked = True 'Table_Grid1.ComboBox(2).Locked = True End Sub Private Function GetDelayUnit(str As String) As String Dim result As Integer Select Case str Case "毫秒" result = 1 Case "秒" result = 2 Case "分钟" result = 3 Case "小时" result = 4 Case "天" result = 5 Case Else result = 1 End Select Return result.ToString End Function Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged AddParameterrow() Select Case g_nodename Case "PB_STRIP_DEVICE", "PB_LINE_CONTROL" Case "DIMMING", "RELAY", "Temp" For i = 2 To Grid1.Rows - 1 If Grid1.Cell(Grid1.Rows - 1, 1).Text.Equals("全局调光") Then Continue For Else 'Grid1.Row(Grid1.Rows - 1).Delete() ’czh 2025 5 24 End If Next Select Case ComboBox1.Text Case "开关机功能" ',"循环调光", "控制灯光", If Table_Grid1.Rows > 3 Then Table_Grid1.Row(3).Visible = False End If End Select Case "MUSIC" Dim ExecutionModebuf() = g_ExecutionMode.Split(",") If ExecutionModebuf.Length > 2 Then Dim row As Integer Dim roC As Integer = Grid1.Rows - 1 Dim strE As String For i = 0 To roC row = roC - i strE = Grid1.Cell(row, 1).Text Console.WriteLine(strE) Select Case strE Case "设置播放音量", "设置全局百分比", "设置开关机" Grid1.Row(row).Delete() End Select If g_DevNodename.Equals("HOSTSERVICE") AndAlso ExecutionModebuf(1).Equals("1") Then 'If strE.Contains("欢迎词") OrElse strE.Contains("提示音") Then ' Continue For 'Else ' If row >= Grid1.Rows Then ' Continue For ' End If ' Grid1.Row(row).Delete() 'End If Else Select Case ExecutionModebuf(1) Case "6" If strE.Contains("助眠") OrElse strE.Contains("提示音") Then Continue For Else If row >= Grid1.Rows Then Continue For End If Grid1.Row(row).Delete() End If Case Else If strE.Contains("助眠") Then Grid1.Row(row).Delete() End If If (KeyName.Equals("插卡") OrElse KeyName.Equals("拔卡")) AndAlso strE.Contains("播放门铃") Then Grid1.Row(row).Delete() End If End Select End If Next Select Case ComboBox1.Text Case "播放提示音", "播放助眠", "播放助眠冥想", "播放助眠海浪", "播放助眠森林" Table_Grid1.Row(4).Visible = False 'Table_Grid1.Row(3).Visible = False Case "设置播放状态", "设置播放状态1", "按键控制播放音量" Table_Grid1.Row(3).Visible = False Case "播放音乐" Table_Grid1.Row(3).Visible = False Case "设置全局百分比" Case "设置开关机" Case "播放门铃", "播放欢迎词" Table_Grid1.Row(4).Visible = False Table_Grid1.Row(3).Visible = False Case "小宝功能设置" Table_Grid1.Row(4).Visible = False Table_Grid1.Row(5).Visible = False Case "小宝音量设置" Table_Grid1.Row(4).Visible = False End Select End If Case "485MUSIC" Dim row As Integer Dim roC As Integer = Grid1.Rows - 1 Dim strE As String If Grid1.Rows > 2 Then For i = 0 To roC row = roC - i strE = Grid1.Cell(row, 1).Text If Not strE.Contains("华尔思音乐控制") Then Grid1.Row(row).Delete() End If Next End If Case "485FRESHAIR" Dim strE As String = String.Empty Dim Estrbuf As New List(Of String) Estrbuf.Add("3 风速高速") Estrbuf.Add("2 风速中速") Estrbuf.Add("1 风速低速") Grid1.Row(Grid1.Rows - 1).Delete() strE = Grid1.Cell(1, 1).Text If strE.Equals("开关机功能") Then Table_Grid1.Row(3).Visible = False Table_Grid1.AddItem("") Dic_2.Add("设置风速", Estrbuf) Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "设置风速" End If Case "485FloorHeat".ToUpper Dim strE As String = String.Empty Dim Estrbuf As New List(Of String) For i = 16 To 32 Estrbuf.Add(i) Next Grid1.Row(Grid1.Rows - 1).Delete() strE = Grid1.Cell(1, 1).Text If strE.Equals("开关机功能") Then Table_Grid1.Row(3).Visible = False Table_Grid1.AddItem("") Dic_2.Add("设置温度", Estrbuf) Table_Grid1.Cell(Table_Grid1.Rows - 1, 1).Text = "设置温度" End If End Select 'Select Case ComboBox1.Text ' Case "控制温控器" ' If Table_Grid1.Rows > 6 Then ' Table_Grid1.Row(6).Visible = False ' End If 'End Select End Sub Public oldrow As Integer = 0 Private Sub Grid1_Click(Sender As Object, e As EventArgs) Handles Grid1.Click If Grid1.ActiveCell.Row > 0 Then Grid1.Cell(oldrow, 1).BackColor = Color.White For Index = 0 To ComboBox1.Items.Count - 1 If ComboBox1.Items(Index).ToString.Equals(Grid1.Cell(Grid1.ActiveCell.Row, 1).Text) Then ComboBox1.SelectedIndex = Index Grid1.Cell(Grid1.ActiveCell.Row, 1).BackColor = Color.LightBlue oldrow = Grid1.ActiveCell.Row End If Next End If End Sub Public IsCellChange As Boolean Private Sub Table_Grid1_CellChange(Sender As Object, e As Grid.CellChangeEventArgs) Handles Table_Grid1.CellChange If e.Row > 0 AndAlso IsCellChange = False Then Dim liname As String = Table_Grid1.Cell(e.Row, 1).Text Dim lival As String = Table_Grid1.Cell(e.Row, 2).Text Dim li As List(Of String) = Dic_2.Item(liname) For Each index In li If index.Equals(lival) Then Return End If Next Table_Grid1.Cell(e.Row, 2).Text = li(0) End If End Sub Private Function FGetDelayUnit(str As String) As String Dim result As String = String.Empty Select Case str Case "1" result = "毫秒" Case "2" result = "秒" Case "3" result = "分钟" Case "4" result = "小时" Case "5" result = "天" Case Else End Select Return result.ToString End Function Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If Table_Grid1.Rows > 0 Then Dim buf() As String Dim Result As String = String.Empty Dim displystr As String = String.Empty Dim Resli As New Dictionary(Of String, String) If Not (Table_Grid1.Rows > 1) Then MsgBox("未选择设备方法!!") Return End If For i = 1 To Table_Grid1.Rows - 1 If String.IsNullOrEmpty(Table_Grid1.Cell(i, 2).Text) Then MsgBox($"第{i}行,方法参数为空!!") Return End If If Table_Grid1.Row(i).Visible = True Then displystr = $"{displystr}{Table_Grid1.Cell(i, 2).Text}*" End If Select Case g_nodename Case "485FRESHAIR" If i = Table_Grid1.Rows - 1 Then Dim ti As String = Table_Grid1.Cell(1, 2).Text Dim tid As String = Table_Grid1.Cell(2, 2).Text buf = tid.Split(" ") Dim tidv As String = Table_Grid1.Cell(i, 2).Text Dim bufv = tidv.Split(" ") Dim addinten = $"{ti},{GetDelayUnit(buf(0))},4,{bufv(0)}," Resli.Add("设置风速功能", addinten) Continue For End If Case "485FloorHeat".ToUpper If i = Table_Grid1.Rows - 1 Then Dim ti As String = Table_Grid1.Cell(1, 2).Text Dim tid As String = Table_Grid1.Cell(2, 2).Text buf = tid.Split(" ") Dim tidv As String = Table_Grid1.Cell(i, 2).Text Dim bufv = tidv.Split(" ") Dim addinten = $"{ti},{GetDelayUnit(buf(0))},3,{bufv(0)}," Resli.Add("设置温度功能", addinten) Continue For End If End Select buf = Table_Grid1.Cell(i, 2).Text.Split(" ") If i = 2 Then Result = $"{Result}{GetDelayUnit(buf(0))}," Else Result = $"{Result}{buf(0)}," End If Next Resli.Add(ComboBox1.Text, Result) If Not String.IsNullOrEmpty(displystr) Then displystr = displystr.Substring(0, displystr.Length - 1) End If If ParamDic.ContainsKey(displystr.Trim) Then MsgBox("已添加相同指令!请勿重复添加!") Return Else ParamDic.Add(displystr.Trim, Resli) End If If Resli.Count > 0 Then 'Result = $"{G_Result}{ComboBox1.Text }" ' For Each index In Resli CmdGrid.AddItem("") CmdGrid.Cell(CmdGrid.Rows - 1, 1).Text = ComboBox1.Text CmdGrid.Cell(CmdGrid.Rows - 1, 2).Text = displystr.Trim 'CmdGrid.Cell(CmdGrid.Rows - 1, 2).Text = index.Value.Substring(0, index.Value.Length - 1) ' Next End If End If End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click If CmdGrid.ActiveCell.Row > 0 Then Dim gparstr = CmdGrid.Cell(CmdGrid.ActiveCell.Row, 2).Text If String.IsNullOrEmpty(gparstr) OrElse IsNothing(ParamDic) OrElse Not ParamDic.ContainsKey(gparstr) Then Else ParamDic.Remove(gparstr) End If CmdGrid.Row(CmdGrid.ActiveCell.Row).Delete() End If End Sub Public CmdGridoldrow As Integer = 0 Private Sub CmdGrid_Click(Sender As Object, e As EventArgs) Handles CmdGrid.Click If CmdGrid.ActiveCell.Row > 0 AndAlso CmdGridoldrow < CmdGrid.ActiveCell.Row Then CmdGrid.Range(CmdGridoldrow, 0, CmdGridoldrow, 2).BackColor = Color.White CmdGrid.Range(CmdGrid.ActiveCell.Row, 0, CmdGrid.ActiveCell.Row, 2).BackColor = Color.LightBlue CmdGridoldrow = CmdGrid.ActiveCell.Row End If End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Dim b As Boolean If Button4.Text.Equals("显示") Then Button4.Text = "隐藏" b = True Else Button4.Text = "显示" If Grid1.Rows > 1 Then Grid1.Cell(1, 1).SetFocus() Grid1_Click(Nothing, Nothing) End If b = False End If For i = 2 To Grid1.Rows - 1 Grid1.Row(i).Visible = b Next End Sub Private Sub Table_Grid1_OwnerDrawCell(Sender As Object, e As Grid.OwnerDrawCellEventArgs) Handles Table_Grid1.OwnerDrawCell If e.Row < 1 OrElse e.Col < 1 Then Return If e.Col = 2 Then Try Dim pen As New System.Drawing.Pen(Color.CornflowerBlue, 1) pen.DashStyle = Drawing2D.DashStyle.Solid Dim Trect As New Rectangle(e.Bounds.Right - 15, CInt(e.Bounds.Top + ((e.Bounds.Height - 9) / 2)), 8, 8) Dim rect As New Rectangle(e.Bounds.Right - 18, CInt(e.Bounds.Top), 17, (e.Bounds.Height)) e.Graphics.FillRectangle(Brushes.LightGray, rect) e.Graphics.DrawRectangle(Pens.LightGray, rect) e.Graphics.DrawLine(Pens.Gray, Trect.Left, Trect.Top + 4, Trect.Left + 4, Trect.Bottom) e.Graphics.DrawLine(Pens.Gray, Trect.Left + 4, Trect.Bottom, Trect.Right, Trect.Top + 4) e.Graphics.DrawLine(Pens.Gray, Trect.Left, Trect.Top + 3, Trect.Left + 4, Trect.Bottom - 1) e.Graphics.DrawLine(Pens.Gray, Trect.Left + 4, Trect.Bottom - 1, Trect.Right, Trect.Top + 3) ' '文字 Dim bColor As New SolidBrush(Table_Grid1.Cell(e.Row, e.Col).ForeColor) bColor.Color = Color.Black With Table_Grid1.Cell(e.Row, e.Col) Dim ft = .Font e.Graphics.DrawString(.Text, ft, bColor, e.Bounds.Left, e.Bounds.Top + (e.Bounds.Height - e.Graphics.MeasureString(.Text, .Font).Height) / 2 + 1) End With Catch ex As Exception End Try e.Handled = True Else Return End If End Sub Private Sub Table_Grid1_CellChanging(Sender As Object, e As CellChangingEventArgs) Handles Table_Grid1.CellChanging If ComboBox1.Text.Equals("播放提示音") AndAlso Table_Grid1.Rows > 5 Then If (Table_Grid1.Cell(3, 2).Text.Equals("2 播放(提示音)") OrElse Table_Grid1.Cell(3, 2).Text.Equals("1 静音(提示音)")) Then Table_Grid1.Row(5).Visible = False Else Table_Grid1.Row(5).Visible = True End If IsCellChange = True If e.Row = 3 Then If (Table_Grid1.Cell(3, 2).Text.Equals("5 音量加") OrElse Table_Grid1.Cell(3, 2).Text.Equals("6 音量减")) Then Table_Grid1.Cell(5, 2).Text = Dic_2.Item("音量值")(0) Table_Grid1.Cell(5, 1).Text = "音量值" Else Table_Grid1.Cell(5, 2).Text = Dic_2.Item("播放文件序号").Item(0) Table_Grid1.Cell(5, 1).Text = "播放文件序号" End If End If IsCellChange = False ElseIf ComboBox1.Text.Equals("播放音乐") AndAlso Table_Grid1.Rows > 5 AndAlso IsCellChange = False Then If (Table_Grid1.Cell(4, 2).Text.Equals("5 音量加") OrElse Table_Grid1.Cell(4, 2).Text.Equals("6 音量减")) Then Table_Grid1.Row(5).Visible = True Else Table_Grid1.Row(5).Visible = False End If ElseIf ComboBox1.Text.Equals("华尔思音乐控制") AndAlso Table_Grid1.Rows > 6 Then If Table_Grid1.Cell(3, 2).Text.Equals("2 关机") Then For i As Integer = 4 To Table_Grid1.Rows - 1 Table_Grid1.Row(i).Visible = False Next Else For i As Integer = 4 To Table_Grid1.Rows - 2 Table_Grid1.Row(i).Visible = True Next If Table_Grid1.Cell(5, 2).Text.Contains("音量") Then Table_Grid1.Row(6).Visible = True Else Table_Grid1.Row(6).Visible = False End If End If End If End Sub Private Sub Table_Grid1_Click(Sender As Object, e As EventArgs) Handles Table_Grid1.Click Try Dim point As Point = Table_Grid1.PointToClient(System.Windows.Forms.Cursor.Position) Dim cel As Cell = Table_Grid1.HitTest(point.X, point.Y) If cel Is Nothing Then Return If cel.Row < 1 OrElse cel.Col <> 2 Then Return Dim rect As New Rectangle(cel.Bounds.Right - 18, CInt(cel.Bounds.Top), 17, (cel.Bounds.Height)) 'Dim rect As New Rectangle(cel.Bounds.Left + 2, cel.Bounds.Top + ((cel.Bounds.Height - 9) \ 2), 8, 8) If rect.Contains(point) = False Then Return Table_Grid1.Cell(cel.Row, cel.Col).SetFocus() Table_Grid1.ComboBox(cel.Col).DropDown() Catch ex As Exception Console.WriteLine($"Grid_Click Error:{ex.Message}") End Try End Sub Public Shared Function CheckDataIsOk(devtype As String, datastr As String, BasicClasses As DeviceObjectClasses) As Boolean If String.IsNullOrEmpty(datastr) Then Return True Dim cmdpar() As String = datastr.Split(vbLf) For Each FPnode In cmdpar Dim buf() As String = FPnode.Split(",") Dim timeint As Integer = -1 Dim timecint As Integer = -1 If buf.Length < 2 Then Return False If Not (Integer.TryParse(buf(0), timeint) And Integer.TryParse(buf(1), timecint)) Then Return False End If If timeint < 0 OrElse timeint > 255 Then Return False End If If timecint < 1 OrElse timecint > 5 Then Return False End If Dim namebuf() As String Dim Anamebuf() As String Dim isok As Boolean = False For Each node In BasicClasses.DeviceClass If node.Name.ToUpper.Equals(devtype) Then For Each Anode In node.Methods If Anode.Name.Equals(buf(buf.Length - 2).Trim) Then If (buf.Length - 4) = Anode.Params.Count Then For inex = 0 To Anode.Params.Count - 1 Dim Index As DeviceChildNodeMethodParam = Anode.Params(inex) Dim li As New List(Of String) isok = False If Index.Name.Equals("无") And buf(2 + inex) = 0 Then Continue For End If If Index.DataType.Equals("List") Then namebuf = Index.DataRange.Split(",") For Each cindex In namebuf Anamebuf = cindex.Split(" ") If Anamebuf(0).Equals(buf(2 + inex)) Then isok = True Exit For End If Next If isok Then Continue For Else Return False End If ElseIf Index.DataType.Equals("Integer") Then Dim parbuf() As String = Index.DataRange.Split(",") Dim startint As Integer = 0 Dim endint As Integer = 1 Dim parint As Integer = -1 Integer.TryParse(parbuf(0), startint) Integer.TryParse(parbuf(1), endint) Integer.TryParse(buf(2 + inex), parint) If parint >= startint AndAlso parint <= endint Then Continue For Else Return False End If End If Next Return True Else Return False End If End If Next Return False End If Next Next Return False End Function Private Sub initCmdGrid() With CmdGrid .NewFile() .Cols = 3 .Rows = 1 .ExtendLastCol = True .Cell(0, 1).Text = "设备方法名" ' .Cell(0, 2).Text = "方法参数值" .Cell(0, 2).Text = "参数描述" 'Table_Grid1.Cell(0, 3).Text = "设备端口" .Column(1).Width = 130 .Column(2).Width = 100 .Column(1).Alignment = FlexCell.AlignmentEnum.CenterCenter .Column(2).Alignment = FlexCell.AlignmentEnum.CenterCenter .Column(1).Locked = True .Column(2).Locked = True .SelectionMode = SelectionModeEnum.ByCell End With End Sub End Class