初始化
This commit is contained in:
7
BLV_Studio/ModelGrid/Command/GridCommand.vb
Normal file
7
BLV_Studio/ModelGrid/Command/GridCommand.vb
Normal file
@@ -0,0 +1,7 @@
|
||||
Public MustInherit Class GridCommand
|
||||
Implements ICommand
|
||||
|
||||
Public MustOverride Sub Redo() Implements ICommand.Redo
|
||||
|
||||
Public MustOverride Sub Undo() Implements ICommand.Undo
|
||||
End Class
|
||||
1291
BLV_Studio/ModelGrid/Command/MoveUpCommand.vb
Normal file
1291
BLV_Studio/ModelGrid/Command/MoveUpCommand.vb
Normal file
File diff suppressed because it is too large
Load Diff
65
BLV_Studio/ModelGrid/ConfigActionConcitons.vb
Normal file
65
BLV_Studio/ModelGrid/ConfigActionConcitons.vb
Normal file
@@ -0,0 +1,65 @@
|
||||
Imports System.Xml.Serialization
|
||||
|
||||
|
||||
<Serializable>
|
||||
<XmlRoot(ElementName:="ConfigConcitons")>
|
||||
Public Class ConfigActionConcitons
|
||||
''' <summary>
|
||||
''' 条件信息
|
||||
''' </summary>
|
||||
<XmlArray("CondictionGroup"), XmlArrayItem("Conction", GetType(Conction))>
|
||||
Public Conction As List(Of Conction)
|
||||
|
||||
''' <summary>
|
||||
''' 执行方式
|
||||
''' </summary>
|
||||
<XmlArray("ExecludeMode"), XmlArrayItem("Conction", GetType(Conction))>
|
||||
Public ExeMode As List(Of Conction)
|
||||
|
||||
Sub New()
|
||||
Conction = New List(Of Conction)
|
||||
ExeMode = New List(Of Conction)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Conction
|
||||
''' <summary>
|
||||
''' 条件名
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 条件数据类型
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public DataType As String
|
||||
|
||||
''' <summary>
|
||||
''' 条件数据范围
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public DataRange As String
|
||||
|
||||
''' <summary>
|
||||
''' 条件数据取值
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public DataRangeValue As String
|
||||
|
||||
''' <summary>
|
||||
''' 条件数据默认值
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public DataDefault As String
|
||||
|
||||
''' <summary>
|
||||
''' 条件描述
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public Desc As String
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
5551
BLV_Studio/ModelGrid/DeviceEventModel.vb
Normal file
5551
BLV_Studio/ModelGrid/DeviceEventModel.vb
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
360
BLV_Studio/ModelGrid/DeviceModelInfo.vb
Normal file
360
BLV_Studio/ModelGrid/DeviceModelInfo.vb
Normal file
@@ -0,0 +1,360 @@
|
||||
Imports System.Xml.Serialization
|
||||
|
||||
<Serializable>
|
||||
<XmlRoot(ElementName:="DeviceModeInfo")>
|
||||
Public Class DeviceModel
|
||||
''' <summary>
|
||||
''' 客户名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore> '忽略,字段不参与序列号和反序列化
|
||||
Public Property VerdorName As String
|
||||
''' <summary>
|
||||
''' 设备文件名
|
||||
''' </summary>
|
||||
Public filename As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore>
|
||||
Public Property HotelName As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店房型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore>
|
||||
Public Property HotelRoomType As String
|
||||
|
||||
''' <summary>
|
||||
''' 模型名称
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 模型说明
|
||||
''' </summary>
|
||||
<XmlElement("Description")>
|
||||
Public Desc As DeviceDescription
|
||||
|
||||
''' <summary>
|
||||
''' 模型配置信息
|
||||
''' </summary>
|
||||
<XmlArray("Common_Configuration"), XmlArrayItem("ConfigurationGroup", GetType(DeviceModelConfigGroup))>
|
||||
Public Config As List(Of DeviceModelConfigGroup)
|
||||
|
||||
''' <summary>
|
||||
''' 模型子节点
|
||||
''' </summary>
|
||||
<XmlArray("DeviceObjectNodes"), XmlArrayItem("DeviceClass", GetType(DeviceChildNodeClass))>
|
||||
Public Nodes As List(Of DeviceChildNodeClass)
|
||||
|
||||
Sub New()
|
||||
|
||||
Desc = New DeviceDescription
|
||||
|
||||
Config = New List(Of DeviceModelConfigGroup)
|
||||
|
||||
Nodes = New List(Of DeviceChildNodeClass)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
<XmlRoot(ElementName:="Description")>
|
||||
Public Class DeviceDescription
|
||||
''' <summary>
|
||||
''' 设备名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_NAME")>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备商标
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_BRAND")>
|
||||
Public Property Brand As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备模型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_MN")>
|
||||
Public Property Model As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL")>
|
||||
Public Property Protocol As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议数据
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL_DATA")>
|
||||
Public Property ProtocolData As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议版本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL_VER")>
|
||||
Public Property ProtocolVer As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备接口
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_INTERFACE")>
|
||||
Public Property DevInterface As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备类型数据
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_TYPE_DATA")>
|
||||
Public Property DevTypeData As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备数据模型版本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_DATA_MODEL_VER")>
|
||||
Public Property DevDataModelVer As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备说明
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_DESCRIPTION")>
|
||||
Public Property DevDescription As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备说明
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("IconKey")>
|
||||
Public Property IconKey As String
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 引用基类的名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_BASIC_CLASS_FILENAME")>
|
||||
Public Property DevBasicClassFilename As String
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 引用条件的名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_CONDICTION_FILENAME")>
|
||||
Public Property DevCondictionFilename As String
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class DeviceChildNodeClass
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property [Interface] As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property DEV_TYPE_DATA As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property PROTOCOL_VER As String
|
||||
|
||||
|
||||
<XmlElement("Node")>
|
||||
Public Nodes As List(Of DeviceChildNode)
|
||||
|
||||
Sub New()
|
||||
Nodes = New List(Of DeviceChildNode)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class DeviceChildNode
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property DefaultAliasName As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property [Interface] As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property LoopAddr As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property DefaultClass As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property Description As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象类型可选对象类型集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("BaseClassSelect")>
|
||||
Public Property BaseClasses As BaseClasses
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class BaseClasses
|
||||
|
||||
<XmlElement("BaseClass")>
|
||||
Public Classes As List(Of BaseClass)
|
||||
|
||||
<XmlIgnore> '忽略,字段不参与序列号和反序列化‘Classes的元素个数’
|
||||
Public ClassesLstCnt As Integer
|
||||
|
||||
Sub New()
|
||||
Classes = New List(Of BaseClass)
|
||||
ClassesLstCnt = 0
|
||||
End Sub
|
||||
|
||||
Public Function GetAllClassName() As String()
|
||||
Dim s As New List(Of String)
|
||||
For Each base As BaseClass In Classes
|
||||
s.Add(base.Name)
|
||||
Next
|
||||
ClassesLstCnt = s.Count
|
||||
Return s.ToArray
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Public Class BaseClass
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property [Interface] As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
End Class
|
||||
|
||||
Public Class DeviceModelConfigGroup
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property CFG_Type As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property CFG_Value As String
|
||||
|
||||
<XmlElement("Configuration")>
|
||||
Public Attributes As List(Of DeviceChildNodeAttribute)
|
||||
|
||||
Sub New()
|
||||
Attributes = New List(Of DeviceChildNodeAttribute)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeAttribute
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataType")>
|
||||
Public Property DataType As String
|
||||
|
||||
<XmlAttribute("DataRange")>
|
||||
Public Property DataRange As String
|
||||
|
||||
<XmlAttribute("DataRangeValue")>
|
||||
Public Property DataRangeValue As String
|
||||
|
||||
<XmlAttribute("DataDefault")>
|
||||
Public Property DataDefault As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
Sub New()
|
||||
DataRangeValue = ""
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeEvent
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataValue")>
|
||||
Public Property DataValue As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeMethod
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlArray("Params"), XmlArrayItem("Param", GetType(DeviceChildNodeMethodParam))>
|
||||
Public Params As List(Of DeviceChildNodeMethodParam)
|
||||
|
||||
Sub New()
|
||||
Params = New List(Of DeviceChildNodeMethodParam)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeMethodParam
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataType")>
|
||||
Public Property DataType As String
|
||||
|
||||
<XmlAttribute("DataRange")>
|
||||
Public Property DataRange As String
|
||||
|
||||
<XmlAttribute("DataRangeValue")>
|
||||
Public Property DataRangeValue As String
|
||||
|
||||
<XmlAttribute("DataDefault")>
|
||||
Public Property DataDefault As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
Sub New()
|
||||
DataRangeValue = ""
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
Imports System.Xml.Serialization
|
||||
|
||||
<Serializable>
|
||||
<XmlRoot(ElementName:="DeviceModeInfo")>
|
||||
Public Class DeviceModel
|
||||
''' <summary>
|
||||
''' 客户名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore> '忽略,字段不参与序列号和反序列化
|
||||
Public Property VerdorName As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore>
|
||||
Public Property HotelName As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店房型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlIgnore>
|
||||
Public Property HotelRoomType As String
|
||||
|
||||
''' <summary>
|
||||
''' 模型名称
|
||||
''' </summary>
|
||||
<XmlAttribute>
|
||||
Public Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 模型说明
|
||||
''' </summary>
|
||||
<XmlElement("Description")>
|
||||
Public Desc As DeviceDescription
|
||||
|
||||
''' <summary>
|
||||
''' 模型配置信息
|
||||
''' </summary>
|
||||
<XmlArray("Common_Configuration"), XmlArrayItem("ConfigurationGroup", GetType(DeviceModelConfigGroup))>
|
||||
Public Config As List(Of DeviceModelConfigGroup)
|
||||
|
||||
''' <summary>
|
||||
''' 模型子节点
|
||||
''' </summary>
|
||||
<XmlArray("DeviceObjectNodes"), XmlArrayItem("DeviceClass", GetType(DeviceChildNodeClass))>
|
||||
Public Nodes As List(Of DeviceChildNodeClass)
|
||||
|
||||
Sub New()
|
||||
|
||||
Desc = New DeviceDescription
|
||||
|
||||
Config = New List(Of DeviceModelConfigGroup)
|
||||
|
||||
Nodes = New List(Of DeviceChildNodeClass)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
<XmlRoot(ElementName:="Description")>
|
||||
Public Class DeviceDescription
|
||||
''' <summary>
|
||||
''' 设备名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_NAME")>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备商标
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_BRAND")>
|
||||
Public Property Brand As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备模型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_MN")>
|
||||
Public Property Model As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL")>
|
||||
Public Property Protocol As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议数据
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL_DATA")>
|
||||
Public Property ProtocolData As String
|
||||
|
||||
''' <summary>
|
||||
''' 协议版本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("PROTOCOL_VER")>
|
||||
Public Property ProtocolVer As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备接口
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_INTERFACE")>
|
||||
Public Property DevInterface As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备类型数据
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_TYPE_DATA")>
|
||||
Public Property DevTypeData As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备数据模型版本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_DATA_MODEL_VER")>
|
||||
Public Property DevDataModelVer As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备说明
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_DESCRIPTION")>
|
||||
Public Property DevDescription As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备说明
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("IconKey")>
|
||||
Public Property IconKey As String
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 引用基类的名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_BASIC_CLASS_FILENAME")>
|
||||
Public Property DevBasicClassFilename As String
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 引用条件的名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("DEV_CONDICTION_FILENAME")>
|
||||
Public Property DevCondictionFilename As String
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class DeviceChildNodeClass
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlElement("Node")>
|
||||
Public Nodes As List(Of DeviceChildNode)
|
||||
|
||||
Sub New()
|
||||
Nodes = New List(Of DeviceChildNode)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class DeviceChildNode
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property DefaultAliasName As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property [Interface] As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property LoopAddr As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property DefaultClass As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property Description As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象类型可选对象类型集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<XmlElement("BaseClassSelect")>
|
||||
Public Property BaseClasses As BaseClasses
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Public Class BaseClasses
|
||||
|
||||
<XmlElement("BaseClass")>
|
||||
Public Classes As List(Of BaseClass)
|
||||
|
||||
<XmlIgnore> '忽略,字段不参与序列号和反序列化‘Classes的元素个数’
|
||||
Public ClassesLstCnt As Integer
|
||||
|
||||
Sub New()
|
||||
Classes = New List(Of BaseClass)
|
||||
ClassesLstCnt = 0
|
||||
End Sub
|
||||
|
||||
Public Function GetAllClassName() As String()
|
||||
Dim s As New List(Of String)
|
||||
For Each base As BaseClass In Classes
|
||||
s.Add(base.Name)
|
||||
Next
|
||||
ClassesLstCnt = s.Count
|
||||
Return s.ToArray
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Public Class BaseClass
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property [Interface] As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
End Class
|
||||
|
||||
Public Class DeviceModelConfigGroup
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property CFG_Type As String
|
||||
|
||||
<XmlAttribute>
|
||||
Public Property CFG_Value As String
|
||||
|
||||
<XmlElement("Configuration")>
|
||||
Public Attributes As List(Of DeviceChildNodeAttribute)
|
||||
|
||||
Sub New()
|
||||
Attributes = New List(Of DeviceChildNodeAttribute)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeAttribute
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataType")>
|
||||
Public Property DataType As String
|
||||
|
||||
<XmlAttribute("DataRange")>
|
||||
Public Property DataRange As String
|
||||
|
||||
<XmlAttribute("DataRangeValue")>
|
||||
Public Property DataRangeValue As String
|
||||
|
||||
<XmlAttribute("DataDefault")>
|
||||
Public Property DataDefault As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
Sub New()
|
||||
DataRangeValue = ""
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeEvent
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataValue")>
|
||||
Public Property DataValue As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeMethod
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlArray("Params"), XmlArrayItem("Param", GetType(DeviceChildNodeMethodParam))>
|
||||
Public Params As List(Of DeviceChildNodeMethodParam)
|
||||
|
||||
Sub New()
|
||||
Params = New List(Of DeviceChildNodeMethodParam)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class DeviceChildNodeMethodParam
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("DataType")>
|
||||
Public Property DataType As String
|
||||
|
||||
<XmlAttribute("DataRange")>
|
||||
Public Property DataRange As String
|
||||
|
||||
<XmlAttribute("DataRangeValue")>
|
||||
Public Property DataRangeValue As String
|
||||
|
||||
<XmlAttribute("DataDefault")>
|
||||
Public Property DataDefault As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlText>
|
||||
Public Property Value As String
|
||||
|
||||
Sub New()
|
||||
DataRangeValue = ""
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
47
BLV_Studio/ModelGrid/DeviceObjectClasses.vb
Normal file
47
BLV_Studio/ModelGrid/DeviceObjectClasses.vb
Normal file
@@ -0,0 +1,47 @@
|
||||
Imports System.Xml.Serialization
|
||||
|
||||
<XmlRoot("DeviceObjects")>
|
||||
Public Class DeviceObjectClasses
|
||||
|
||||
<XmlElement("DeviceClass")>
|
||||
Public DeviceClass As List(Of DeviceObjectType)
|
||||
|
||||
|
||||
Sub New()
|
||||
DeviceClass = New List(Of DeviceObjectType)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function FindDeviceClass(name As String) As DeviceObjectType
|
||||
For Each device As DeviceObjectType In DeviceClass
|
||||
If String.Compare(name, device.Name, True) = 0 Then Return device
|
||||
Next
|
||||
Return Nothing
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
Public Class DeviceObjectType
|
||||
<XmlAttribute("Name")>
|
||||
Public Property Name As String
|
||||
|
||||
<XmlAttribute("Desc")>
|
||||
Public Property Desc As String
|
||||
|
||||
<XmlArray("Attributes"), XmlArrayItem("Attribute", GetType(DeviceChildNodeAttribute))>
|
||||
Public Attributes As List(Of DeviceChildNodeAttribute)
|
||||
|
||||
<XmlArray("Events"), XmlArrayItem("Event", GetType(DeviceChildNodeEvent))>
|
||||
Public Events As List(Of DeviceChildNodeEvent)
|
||||
|
||||
<XmlArray("Methods"), XmlArrayItem("Method", GetType(DeviceChildNodeMethod))>
|
||||
Public Methods As List(Of DeviceChildNodeMethod)
|
||||
|
||||
Sub New()
|
||||
Attributes = New List(Of DeviceChildNodeAttribute)
|
||||
|
||||
Events = New List(Of DeviceChildNodeEvent)
|
||||
|
||||
Methods = New List(Of DeviceChildNodeMethod)
|
||||
End Sub
|
||||
End Class
|
||||
729
BLV_Studio/ModelGrid/RowNode.vb
Normal file
729
BLV_Studio/ModelGrid/RowNode.vb
Normal file
@@ -0,0 +1,729 @@
|
||||
Public NotInheritable Class RowNode
|
||||
''' <summary>可见节点总数 </summary>
|
||||
Friend _visibleCount As Integer
|
||||
|
||||
''' <summary>节点等级 </summary>
|
||||
Private _lever As Integer
|
||||
|
||||
''' <summary>动作是否执行 </summary>
|
||||
Private _action As Boolean
|
||||
|
||||
Public Sub New()
|
||||
RowType = RowTypeEnum.DeviceEventAction
|
||||
|
||||
_action = True
|
||||
Compile = True
|
||||
|
||||
DeviceAlias = String.Empty
|
||||
Description = String.Empty
|
||||
DelayTime = "0"
|
||||
DelayUnit = "ms"
|
||||
Params = New List(Of AttributeRowNodeTag)
|
||||
|
||||
Expanded = True
|
||||
Visible = True
|
||||
AllChildCount = 0
|
||||
_lever = 0
|
||||
_visibleCount = 0
|
||||
Nodes = New RowNodes(Me)
|
||||
|
||||
RowListIndex = 0
|
||||
RowList = New List(Of RowNode)()
|
||||
RowList.Add(Me)
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "节点特有属性"
|
||||
|
||||
''' <summary>
|
||||
''' 事件编号
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property eventId As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowType As RowTypeEnum
|
||||
|
||||
''' <summary>
|
||||
''' 节点名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点接口属性,从XML读出来,仅对设备对象有效
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property [Interface] As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点显示文本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Text As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点描述
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Description As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备别名
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceAlias As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备是否具有别名
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HasAlias As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 设备类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceType As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceName As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备方法
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceMothed As String
|
||||
|
||||
''' <summary>
|
||||
''' 延时时间
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DelayTime As String
|
||||
|
||||
''' <summary>
|
||||
''' DEV_TYPE_DATA
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DEV_TYPE_DATA As String
|
||||
|
||||
''' <summary>
|
||||
''' PROTOCOL_VER
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property PROTOCOL_VER As String
|
||||
|
||||
|
||||
|
||||
Public Enum CfgTypeEnum
|
||||
''' <summary>
|
||||
''' 0.默认类型
|
||||
''' </summary>
|
||||
CfgType_Default
|
||||
|
||||
''' <summary>
|
||||
''' 1.小宝命令集
|
||||
''' </summary>
|
||||
CfgType_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 2.设备存在
|
||||
''' </summary>
|
||||
CfgType_DeviceExists
|
||||
End Enum
|
||||
|
||||
Public Enum RowTypeEnum
|
||||
''' <summary>
|
||||
''' 0.根节点
|
||||
''' </summary>
|
||||
RootNode
|
||||
|
||||
''' <summary>
|
||||
''' 1.酒店组
|
||||
''' </summary>
|
||||
HotelGroup
|
||||
|
||||
''' <summary>
|
||||
''' 2.酒店项目
|
||||
''' </summary>
|
||||
Hotel
|
||||
|
||||
''' <summary>
|
||||
''' 3.酒店户型
|
||||
''' </summary>
|
||||
HotelRoomType
|
||||
|
||||
''' <summary>
|
||||
''' 4.主机模型
|
||||
''' </summary>
|
||||
Model
|
||||
|
||||
''' <summary>
|
||||
''' 5.主机模型属性集
|
||||
''' </summary>
|
||||
ModelAttributes
|
||||
|
||||
''' <summary>
|
||||
''' 6.主机模型属性分组
|
||||
''' </summary>
|
||||
ModelAttributeGroup
|
||||
|
||||
''' <summary>
|
||||
''' 7.主机模型属性
|
||||
''' </summary>
|
||||
ModelAttribute
|
||||
|
||||
''' <summary>
|
||||
''' 8.模型外设组
|
||||
''' </summary>
|
||||
DeviceGroup
|
||||
|
||||
''' <summary>
|
||||
''' 9.模型外设对象
|
||||
''' </summary>
|
||||
DeviceObject
|
||||
|
||||
''' <summary>
|
||||
''' 10.模型外设属性组
|
||||
''' </summary>
|
||||
DeviceAttributes
|
||||
|
||||
''' <summary>
|
||||
''' 11.模型外设方法组
|
||||
''' </summary>
|
||||
DeviceMothods
|
||||
|
||||
''' <summary>
|
||||
''' 12.模型外设事件组
|
||||
''' </summary>
|
||||
DeviceEvents
|
||||
|
||||
''' <summary>
|
||||
''' 13.模型外设属性
|
||||
''' </summary>
|
||||
DeviceAttribute
|
||||
|
||||
''' <summary>
|
||||
''' 14.模型外设方法
|
||||
''' </summary>
|
||||
DeviceMothod
|
||||
|
||||
''' <summary>
|
||||
''' 15.模型外设事件
|
||||
''' </summary>
|
||||
DeviceEvent
|
||||
|
||||
''' <summary>
|
||||
''' 16.模型外设事件动作执行方式组
|
||||
''' </summary>
|
||||
DeviceEventActionModeGroup
|
||||
|
||||
''' <summary>
|
||||
''' 17.模型外设事件动作执行方式
|
||||
''' </summary>
|
||||
DeviceEventActionMode
|
||||
|
||||
''' <summary>
|
||||
''' 18.模型外设事件条件
|
||||
''' </summary>
|
||||
DeviceEventConditionItem
|
||||
|
||||
''' <summary>
|
||||
''' 19.模型外设事件条件
|
||||
''' </summary>
|
||||
DeviceEventAllConditions
|
||||
|
||||
''' <summary>
|
||||
''' 20.条件组节点
|
||||
''' </summary>
|
||||
DeviceEventConditions
|
||||
|
||||
''' <summary>
|
||||
''' 21.模型外设事件执行动作组集合
|
||||
''' </summary>
|
||||
DeviceEventAllActions
|
||||
|
||||
''' <summary>
|
||||
''' 22.模型外设事件执行动作组
|
||||
''' </summary>
|
||||
DeviceEventActions
|
||||
|
||||
''' <summary>
|
||||
''' 23.模型外设事件执行动作
|
||||
''' </summary>
|
||||
DeviceEventAction
|
||||
|
||||
''' <summary>
|
||||
''' 24.情景模式组
|
||||
''' </summary>
|
||||
ContextualModels
|
||||
|
||||
''' <summary>
|
||||
''' 25.情景模式
|
||||
''' </summary>
|
||||
ContextualModel
|
||||
|
||||
''' <summary>
|
||||
''' 26.外设模型
|
||||
''' </summary>
|
||||
ExternalModel
|
||||
|
||||
''' <summary>
|
||||
''' 27.属性集 = XiaoBaoCMD
|
||||
''' </summary>
|
||||
ModelAttributes_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 28.属性 = XiaoBaoCMD
|
||||
''' </summary>
|
||||
ModelAttribute_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 29.属性集 = 设备存在
|
||||
''' </summary>
|
||||
ModelAttributes_DeviceExists
|
||||
|
||||
''' <summary>
|
||||
''' 30.属性 = 设备存在
|
||||
''' </summary>
|
||||
ModelAttribute_DeviceExists
|
||||
|
||||
End Enum
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 延时单位
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DelayUnit As String
|
||||
|
||||
''' <summary>
|
||||
''' 动作执行参数
|
||||
''' </summary>
|
||||
Public Params As List(Of AttributeRowNodeTag)
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 动作是否执行,仅代表表格上的勾选状态,参与编译属性参考Compile属性
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Action As Boolean
|
||||
Get
|
||||
Return _action
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
_action = value
|
||||
|
||||
UpdateCompile()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 动作是否参与编译
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Compile As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点标签
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Tag As Object
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点公共属性"
|
||||
|
||||
''' <summary>
|
||||
''' 节点是否处于展开状态
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Expanded() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点是否处于可见状态
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Visible() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点的级别,可见节点级别从0开始
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Lever As Integer
|
||||
Get
|
||||
Return _lever
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
_lever = value
|
||||
For Each node As RowNode In Nodes
|
||||
node.Lever = _lever + 1
|
||||
Next
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 节点在父节点中的索引,可见节点级别从0开始
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Index As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 下一级子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property Count() As Integer
|
||||
Get
|
||||
Return Nodes.Count
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 所有子节点中,可见子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property VisibleNodesCount() As Integer
|
||||
Get
|
||||
Return _visibleCount
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 所有子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property AllChildCount() As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点树的起始节点
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HeadNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的父节点
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property ParentNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的同级上一节点,若当前节点为首节点则返回nothing
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property PrevNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的同级下一节点,若当前节点为尾节点则返回nothing
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property NextNode() As RowNode
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点所属节点数组的位置,从0开始,即头结点的的索引
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowListIndex As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点树的所有节点集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowList As List(Of RowNode)
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 子节点集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Nodes As RowNodes
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点操作"
|
||||
''' <summary>
|
||||
''' 更新节点参与编译属性
|
||||
''' </summary>
|
||||
Friend Sub UpdateCompile()
|
||||
If ParentNode Is Nothing Then
|
||||
Compile = Action
|
||||
Else
|
||||
Compile = Action AndAlso ParentNode.Compile
|
||||
End If
|
||||
|
||||
For Each node As RowNode In Nodes
|
||||
node.Compile = Action AndAlso node.ParentNode.Compile
|
||||
|
||||
node.UpdateCompile()
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 获取所有子节点
|
||||
''' </summary>
|
||||
Friend Function GetAllChildsNodeList(argRowNode As RowNode, ByVal lstChildNodeList As List(Of RowNode)) As Boolean
|
||||
If argRowNode.Nodes.Count < 1 Then Return False
|
||||
|
||||
'将指定节点的所有子节点平铺加入到lstChildNodeList列表中
|
||||
For Each tmpNode As RowNode In argRowNode.Nodes
|
||||
lstChildNodeList.Add(tmpNode)
|
||||
'如有子节点则递归调用,直到子节点数量为零(没有子节点)
|
||||
If tmpNode.Nodes.Count > 0 Then GetAllChildsNodeList(tmpNode, lstChildNodeList)
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 更新可见子节点总数
|
||||
''' </summary>
|
||||
''' <param name="count"></param>
|
||||
Friend Sub UpdateVisibleCount(count As Integer)
|
||||
_visibleCount += count
|
||||
If ParentNode IsNot Nothing Then ParentNode.UpdateVisibleCount(count)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 更新子节点可见
|
||||
''' </summary>
|
||||
Friend Sub UpdateVisible(Optional isForceSetVisible As Boolean = False,
|
||||
Optional isVisible As Boolean = True)
|
||||
For Each node As RowNode In Nodes
|
||||
'Momo 0416 增加强制参数,某些情况下通过传参强制设定visible状态
|
||||
If isForceSetVisible = True Then
|
||||
node.Visible = isVisible
|
||||
Else
|
||||
node.Visible = Expanded AndAlso Visible
|
||||
End If
|
||||
|
||||
node.UpdateVisible()
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 展开节点
|
||||
''' </summary>
|
||||
Public Sub Expand()
|
||||
If Expanded Then Return
|
||||
Expanded = True
|
||||
|
||||
Dim num As Integer
|
||||
For Each node As RowNode In Nodes
|
||||
num += node.VisibleNodesCount + 1
|
||||
Next
|
||||
UpdateVisibleCount(num)
|
||||
|
||||
'更新子节点是否可见
|
||||
UpdateVisible()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 展开所有节点包括子节点
|
||||
''' </summary>
|
||||
Public Sub ExpandAll()
|
||||
Expand()
|
||||
|
||||
'展开所有节点
|
||||
For Each node As RowNode In Nodes
|
||||
node.ExpandAll()
|
||||
'展开的同时,设置属性为可见
|
||||
node.Visible = True
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 折叠节点
|
||||
''' </summary>
|
||||
Public Sub Collapse()
|
||||
If Expanded = False Then Return
|
||||
Expanded = False
|
||||
|
||||
'更新可见总数
|
||||
Dim num As Integer
|
||||
For Each node As RowNode In Nodes
|
||||
num += node.VisibleNodesCount + 1
|
||||
Next
|
||||
UpdateVisibleCount(0 - num)
|
||||
|
||||
'更新子节点是否可见
|
||||
UpdateVisible()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 收缩所有节点包括子节点
|
||||
''' </summary>
|
||||
Public Sub CollapseAll()
|
||||
Collapse()
|
||||
|
||||
'收缩所有节点
|
||||
For Each node As RowNode In Nodes
|
||||
node.CollapseAll()
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 展开或折叠节点
|
||||
''' </summary>
|
||||
Public Sub Toggle()
|
||||
If Expanded Then
|
||||
Collapse()
|
||||
Else
|
||||
Expand()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 增加子节点
|
||||
''' </summary>
|
||||
Public Sub AddNode(node As RowNode)
|
||||
Nodes.Add(node)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 插入子节点
|
||||
''' </summary>
|
||||
Public Sub InsertNode(index As Integer, childNode As RowNode)
|
||||
Nodes.Insert(index, childNode)
|
||||
End Sub
|
||||
|
||||
|
||||
Public Sub RemoveChildNode(childNode As RowNode)
|
||||
|
||||
Nodes.Remove(childNode)
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveChildAt(index As Integer)
|
||||
If index >= Nodes.Count Then Return
|
||||
Dim child As RowNode = CType(Nodes.Item(index), RowNode)
|
||||
Nodes.RemoveAt(index)
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 移除本身节点
|
||||
''' </summary>
|
||||
Public Function Remove() As Boolean
|
||||
ParentNode.Nodes.Remove(Me)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 清空节点所有子节点
|
||||
''' </summary>
|
||||
Public Sub Clear()
|
||||
Nodes.Clear()
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点上移
|
||||
''' </summary>
|
||||
Public Sub MoveUp()
|
||||
If Index = 0 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
ParentNode.Nodes.Insert(Index - 1, Me)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 节点下移
|
||||
''' </summary>
|
||||
Public Sub MoveDown()
|
||||
If Index = ParentNode.Nodes.Count - 1 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
ParentNode.Nodes.Insert(Index + 1, Me)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 节点左移
|
||||
''' </summary>
|
||||
Public Sub MoveLeft()
|
||||
If _lever = 0 Then Return
|
||||
If Remove() = False Then Return
|
||||
ParentNode.ParentNode.Nodes.Insert(ParentNode.Index + 1, Me)
|
||||
|
||||
'更新节点可见与可见子节点数
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点右移
|
||||
''' </summary>
|
||||
Public Sub MoveRight()
|
||||
If Index = 0 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
Dim rNode As RowNode = CType(ParentNode.Nodes(Index - 1), RowNode)
|
||||
rNode.Nodes.Add(Me)
|
||||
|
||||
'更新节点可见与可见子节点数
|
||||
End Sub
|
||||
|
||||
'''' <summary>
|
||||
'''' 交换两个节点信息 err
|
||||
'''' </summary>
|
||||
'''' <returns></returns>
|
||||
'Public Function Exchange(ByRef argRowNode1 As RowNode,
|
||||
' ByRef argRowNode2 As RowNode,
|
||||
' ByRef argErrMsg As String) As Boolean
|
||||
' Try
|
||||
' If argRowNode1.RowType <> argRowNode2.RowType Then
|
||||
' argErrMsg = "两个节点类型不同,不可进行交换!"
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
' Dim tmpNode As RowNode = argRowNode1
|
||||
|
||||
' argRowNode1 = argRowNode2
|
||||
' argRowNode2 = tmpNode
|
||||
' Catch ex As Exception
|
||||
' argErrMsg = ex.Message.ToString
|
||||
' Return False
|
||||
' End Try
|
||||
|
||||
' Return True
|
||||
'End Function
|
||||
|
||||
''' <summary>
|
||||
''' 节点深复制,创建一个完全相同信息的节点(功能待测试)
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function Clone() As RowNode
|
||||
Dim cpNode As New RowNode
|
||||
|
||||
With cpNode
|
||||
.RowType = RowType
|
||||
|
||||
.Action = Action
|
||||
|
||||
.Nodes = New RowNodes(cpNode)
|
||||
|
||||
'todo:克隆功能待重写
|
||||
End With
|
||||
|
||||
Return cpNode
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点类型"
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
3137
BLV_Studio/ModelGrid/RowNodeCompile.vb
Normal file
3137
BLV_Studio/ModelGrid/RowNodeCompile.vb
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
489
BLV_Studio/ModelGrid/RowNodeTag.vb
Normal file
489
BLV_Studio/ModelGrid/RowNodeTag.vb
Normal file
@@ -0,0 +1,489 @@
|
||||
Imports System.Net
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public Class RowNodeTag
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public Class HotelRoomTypeRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 客户名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property VerdorName As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HotelName As String
|
||||
|
||||
''' <summary>
|
||||
''' 酒店房型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HotelRoomType As String
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 模块级别节点附带信息
|
||||
''' </summary>
|
||||
Public Class ModelRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Desc As DeviceDescription
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 属性级别节点附带信息
|
||||
''' </summary>
|
||||
Public Class AttributeRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
''' <summary>当前选择参数索引</summary>
|
||||
Private _selectIndex As Integer
|
||||
|
||||
''' <summary>数值型参数下限</summary>
|
||||
Private _lower As Integer
|
||||
|
||||
''' <summary>数值型参数上限</summary>
|
||||
Private _upper As Integer
|
||||
|
||||
''' <summary>参数字符串</summary>
|
||||
Private _value As String
|
||||
|
||||
''' <summary>参数字符串集合</summary>
|
||||
Private _range As List(Of String)
|
||||
|
||||
''' <summary>参数字符串对应数据集合</summary>
|
||||
Private _rangeValue As List(Of String)
|
||||
'CZH 2023-04-18
|
||||
|
||||
'Private _IPadd As IPAddress
|
||||
''' <summary>
|
||||
''' 参数名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 当前参数类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Type As DataTypes
|
||||
|
||||
''' <summary>
|
||||
''' 当前参数字符串
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Value As String
|
||||
Get
|
||||
Return _value
|
||||
End Get
|
||||
Set(value As String)
|
||||
_value = value
|
||||
|
||||
If Type = DataTypes.List Then _selectIndex = GetSelectIndex()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 当前参数对应数据
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<JsonIgnore>
|
||||
Public ReadOnly Property ValueData As String
|
||||
Get
|
||||
If Type = DataTypes.List Then
|
||||
If _selectIndex > -1 AndAlso _selectIndex <= _rangeValue.Count - 1 Then
|
||||
Return _rangeValue(_selectIndex)
|
||||
Else
|
||||
Return "0"
|
||||
End If
|
||||
Else
|
||||
Return Value
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 原限定范围字符串
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RangeString As String
|
||||
|
||||
''' <summary>
|
||||
''' 原范围对照值
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DataRangeValue As String
|
||||
|
||||
''' <summary>
|
||||
''' 参数说明
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Description As String
|
||||
|
||||
''' <summary>
|
||||
''' 默认的参数值
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DefalutValue As String
|
||||
|
||||
Sub New()
|
||||
Name = String.Empty
|
||||
Type = DataTypes.List
|
||||
|
||||
RangeString = String.Empty
|
||||
Description = String.Empty
|
||||
DefalutValue = String.Empty
|
||||
DataRangeValue = String.Empty
|
||||
|
||||
_selectIndex = -1
|
||||
_value = String.Empty
|
||||
_range = New List(Of String)
|
||||
_rangeValue = New List(Of String)
|
||||
DealRangeString()
|
||||
End Sub
|
||||
|
||||
|
||||
Sub New(name As String, rangeStr() As String, rangeValue() As String, Optional argValue As String = "", Optional desc As String = "", Optional defalut As String = "")
|
||||
MyBase.New()
|
||||
|
||||
_range = New List(Of String)
|
||||
_range.AddRange(rangeStr)
|
||||
|
||||
_rangeValue = New List(Of String)
|
||||
_rangeValue.AddRange(rangeValue)
|
||||
|
||||
Me.Name = name
|
||||
RangeString = String.Join(",", rangeStr)
|
||||
DataRangeValue = String.Join(",", rangeValue)
|
||||
Description = desc
|
||||
DefalutValue = defalut
|
||||
Value = DefalutValue
|
||||
Type = DataTypes.List
|
||||
End Sub
|
||||
|
||||
|
||||
Sub New(name As String,
|
||||
type As String,
|
||||
rangeStr As String,
|
||||
rangeValue As String,
|
||||
Optional desc As String = "",
|
||||
Optional defalut As String = "")
|
||||
MyBase.New()
|
||||
|
||||
_range = New List(Of String)
|
||||
_rangeValue = New List(Of String)
|
||||
|
||||
Me.Name = name
|
||||
RangeString = rangeStr
|
||||
DataRangeValue = rangeValue
|
||||
Description = desc
|
||||
DefalutValue = defalut
|
||||
|
||||
|
||||
If [Enum].TryParse(type, Me.Type) Then
|
||||
DealRangeString()
|
||||
Else
|
||||
Throw New Exception($"未知DataType:{type}")
|
||||
End If
|
||||
|
||||
Value = DefalutValue
|
||||
End Sub
|
||||
|
||||
Private Function GetSelectIndex() As Integer
|
||||
Return _range.IndexOf(_value)
|
||||
End Function
|
||||
|
||||
Public Sub DealRangeString()
|
||||
Select Case Type
|
||||
Case DataTypes.Boolean
|
||||
|
||||
Case DataTypes.DateTime
|
||||
|
||||
Case DataTypes.Integer
|
||||
If String.IsNullOrEmpty(RangeString) Then
|
||||
_lower = Integer.MinValue
|
||||
_upper = Integer.MaxValue
|
||||
Else
|
||||
Dim sp() As String = RangeString.Split(","c)
|
||||
If sp.Length = 1 Then
|
||||
_lower = sp(0)
|
||||
_upper = sp(0)
|
||||
ElseIf sp.Length = 2 Then
|
||||
_lower = sp(0)
|
||||
_upper = sp(1)
|
||||
Else
|
||||
_lower = Integer.MinValue
|
||||
_upper = Integer.MaxValue
|
||||
End If
|
||||
End If
|
||||
Case DataTypes.List
|
||||
If String.IsNullOrEmpty(RangeString) Then
|
||||
_range.Clear()
|
||||
Else
|
||||
Dim sp() As String = RangeString.Split(","c)
|
||||
_range.Clear()
|
||||
_range.AddRange(sp)
|
||||
End If
|
||||
|
||||
If String.IsNullOrEmpty(DataRangeValue) Then
|
||||
_rangeValue.Clear()
|
||||
Else
|
||||
Dim sp() As String = DataRangeValue.Split(","c)
|
||||
_rangeValue.Clear()
|
||||
_rangeValue.AddRange(sp)
|
||||
End If
|
||||
Case DataTypes.String
|
||||
|
||||
Case DataTypes.IPAddr 'CZH 2023-04-18
|
||||
|
||||
|
||||
Case Else
|
||||
Throw New Exception($"未知的数据类型:{Type}")
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function GetRangeArray() As String()
|
||||
Return _range.ToArray
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 当前值是否在参数允许的范围内
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function IsRange(val As String) As Boolean
|
||||
Dim result As Boolean
|
||||
Select Case Type
|
||||
Case DataTypes.Boolean
|
||||
Try
|
||||
Boolean.Parse(val)
|
||||
result = True
|
||||
Catch ex As Exception
|
||||
If val = "1" OrElse val = "0" Then
|
||||
result = True
|
||||
Else
|
||||
result = False
|
||||
End If
|
||||
End Try
|
||||
Case DataTypes.Integer
|
||||
Dim tmp As Integer
|
||||
If Integer.TryParse(val, tmp) Then
|
||||
If tmp >= _lower AndAlso tmp <= _upper Then
|
||||
result = True
|
||||
Else
|
||||
result = False
|
||||
End If
|
||||
Else
|
||||
result = False
|
||||
End If
|
||||
Case DataTypes.DateTime
|
||||
Dim tmp As Date
|
||||
result = Date.TryParse(val, tmp)
|
||||
Case DataTypes.List
|
||||
result = _range.Contains(val)
|
||||
Case DataTypes.String
|
||||
result = True
|
||||
Case DataTypes.IPAddr 'CZH 2023-04-18
|
||||
If String.IsNullOrEmpty(val) Then
|
||||
result = False
|
||||
Else
|
||||
result = True
|
||||
Dim ipstr() As String = val.Trim.Split(".")
|
||||
Dim ipint As Integer = -1
|
||||
If ipstr.Length = 4 Then
|
||||
For Each ipchr In ipstr
|
||||
If Integer.TryParse(ipchr, ipint) Then
|
||||
If ipint < 0 OrElse ipint > 255 Then
|
||||
result = False
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
result = False
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
result = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Case Else
|
||||
Throw New Exception($"未知的数据类型:{Type}")
|
||||
End Select
|
||||
Return result
|
||||
End Function
|
||||
|
||||
|
||||
Enum DataTypes
|
||||
''' <summary>
|
||||
''' 只允许出现真假结果
|
||||
''' </summary>
|
||||
[Boolean]
|
||||
|
||||
''' <summary>
|
||||
''' 格式必须能够转换为时间
|
||||
''' </summary>
|
||||
DateTime
|
||||
|
||||
''' <summary>
|
||||
''' 只允许出现数值结果
|
||||
''' </summary>
|
||||
[Integer]
|
||||
|
||||
''' <summary>
|
||||
''' 至允许出现列表范围中的数据
|
||||
''' </summary>
|
||||
[List]
|
||||
|
||||
''' <summary>
|
||||
''' 允许用户输入
|
||||
''' </summary>
|
||||
[String]
|
||||
'CZH 2023-04-18
|
||||
''' <summary>
|
||||
''' 允许用户输入
|
||||
''' </summary>
|
||||
IPAddr
|
||||
End Enum
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象级别节点附带信息
|
||||
''' </summary>
|
||||
Public Class DeviceObjectRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
Public Device As DeviceChildNode
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象事件节点附带信息
|
||||
''' </summary>
|
||||
Public Class DeviceEventRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 参与编译的事件编号
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DataValue As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象说明信息
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Description As String
|
||||
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象事件条件节点附带信息
|
||||
''' </summary>
|
||||
Public Class DeviceEventConditionRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
''' <summary>
|
||||
''' 条件执行时间
|
||||
''' </summary>
|
||||
Public ActionTime As AttributeRowNodeTag
|
||||
|
||||
''' <summary>
|
||||
''' 条件执行条件
|
||||
''' </summary>
|
||||
Public ActionCondition As AttributeRowNodeTag
|
||||
|
||||
''' <summary>
|
||||
''' 条件执行方式
|
||||
''' </summary>
|
||||
Public ActionTypes As AttributeRowNodeTag
|
||||
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 设备对象事件动作节点附带信息
|
||||
''' </summary>
|
||||
Public Class DeviceEventActionRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
Sub New()
|
||||
MyBase.New()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Public Class XiaoBaoRowNodeTag
|
||||
Inherits RowNodeTag
|
||||
|
||||
Sub New(type As String, addr As String)
|
||||
MyBase.New()
|
||||
DevType = type
|
||||
Address = addr
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 小宝输入类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DevType As String
|
||||
|
||||
''' <summary>
|
||||
''' 小宝输入地址
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Address As String
|
||||
End Class
|
||||
|
||||
|
||||
@@ -0,0 +1,702 @@
|
||||
Public NotInheritable Class RowNode
|
||||
''' <summary>可见节点总数 </summary>
|
||||
Friend _visibleCount As Integer
|
||||
|
||||
''' <summary>节点等级 </summary>
|
||||
Private _lever As Integer
|
||||
|
||||
''' <summary>动作是否执行 </summary>
|
||||
Private _action As Boolean
|
||||
|
||||
Public Sub New()
|
||||
RowType = RowTypeEnum.DeviceEventAction
|
||||
|
||||
_action = True
|
||||
Compile = True
|
||||
|
||||
DeviceAlias = String.Empty
|
||||
Description = String.Empty
|
||||
DelayTime = "0"
|
||||
DelayUnit = "ms"
|
||||
Params = New List(Of AttributeRowNodeTag)
|
||||
|
||||
Expanded = True
|
||||
Visible = True
|
||||
AllChildCount = 0
|
||||
_lever = 0
|
||||
_visibleCount = 0
|
||||
Nodes = New RowNodes(Me)
|
||||
|
||||
RowListIndex = 0
|
||||
RowList = New List(Of RowNode)()
|
||||
RowList.Add(Me)
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "节点特有属性"
|
||||
''' <summary>
|
||||
''' 节点类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowType As RowTypeEnum
|
||||
|
||||
''' <summary>
|
||||
''' 节点名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Name As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点显示文本
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Text As String
|
||||
|
||||
''' <summary>
|
||||
''' 节点描述
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Description As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备别名
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceAlias As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备是否具有别名
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HasAlias As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 设备类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceType As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceName As String
|
||||
|
||||
''' <summary>
|
||||
''' 设备方法
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DeviceMothed As String
|
||||
|
||||
''' <summary>
|
||||
''' 延时时间
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DelayTime As String
|
||||
|
||||
Public Enum CfgTypeEnum
|
||||
''' <summary>
|
||||
''' 0.默认类型
|
||||
''' </summary>
|
||||
CfgType_Default
|
||||
|
||||
''' <summary>
|
||||
''' 1.小宝命令集
|
||||
''' </summary>
|
||||
CfgType_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 2.设备存在
|
||||
''' </summary>
|
||||
CfgType_DeviceExists
|
||||
End Enum
|
||||
|
||||
Public Enum RowTypeEnum
|
||||
''' <summary>
|
||||
''' 0.根节点
|
||||
''' </summary>
|
||||
RootNode
|
||||
|
||||
''' <summary>
|
||||
''' 1.酒店组
|
||||
''' </summary>
|
||||
HotelGroup
|
||||
|
||||
''' <summary>
|
||||
''' 2.酒店项目
|
||||
''' </summary>
|
||||
Hotel
|
||||
|
||||
''' <summary>
|
||||
''' 3.酒店户型
|
||||
''' </summary>
|
||||
HotelRoomType
|
||||
|
||||
''' <summary>
|
||||
''' 4.主机模型
|
||||
''' </summary>
|
||||
Model
|
||||
|
||||
''' <summary>
|
||||
''' 5.主机模型属性集
|
||||
''' </summary>
|
||||
ModelAttributes
|
||||
|
||||
''' <summary>
|
||||
''' 6.主机模型属性分组
|
||||
''' </summary>
|
||||
ModelAttributeGroup
|
||||
|
||||
''' <summary>
|
||||
''' 7.主机模型属性
|
||||
''' </summary>
|
||||
ModelAttribute
|
||||
|
||||
''' <summary>
|
||||
''' 8.模型外设组
|
||||
''' </summary>
|
||||
DeviceGroup
|
||||
|
||||
''' <summary>
|
||||
''' 9.模型外设对象
|
||||
''' </summary>
|
||||
DeviceObject
|
||||
|
||||
''' <summary>
|
||||
''' 10.模型外设属性组
|
||||
''' </summary>
|
||||
DeviceAttributes
|
||||
|
||||
''' <summary>
|
||||
''' 11.模型外设方法组
|
||||
''' </summary>
|
||||
DeviceMothods
|
||||
|
||||
''' <summary>
|
||||
''' 12.模型外设事件组
|
||||
''' </summary>
|
||||
DeviceEvents
|
||||
|
||||
''' <summary>
|
||||
''' 13.模型外设属性
|
||||
''' </summary>
|
||||
DeviceAttribute
|
||||
|
||||
''' <summary>
|
||||
''' 14.模型外设方法
|
||||
''' </summary>
|
||||
DeviceMothod
|
||||
|
||||
''' <summary>
|
||||
''' 15.模型外设事件
|
||||
''' </summary>
|
||||
DeviceEvent
|
||||
|
||||
''' <summary>
|
||||
''' 16.模型外设事件动作执行方式组
|
||||
''' </summary>
|
||||
DeviceEventActionModeGroup
|
||||
|
||||
''' <summary>
|
||||
''' 17.模型外设事件动作执行方式
|
||||
''' </summary>
|
||||
DeviceEventActionMode
|
||||
|
||||
''' <summary>
|
||||
''' 18.模型外设事件条件
|
||||
''' </summary>
|
||||
DeviceEventConditionItem
|
||||
|
||||
''' <summary>
|
||||
''' 19.模型外设事件条件
|
||||
''' </summary>
|
||||
DeviceEventAllConditions
|
||||
|
||||
''' <summary>
|
||||
''' 20.条件组节点
|
||||
''' </summary>
|
||||
DeviceEventConditions
|
||||
|
||||
''' <summary>
|
||||
''' 21.模型外设事件执行动作组集合
|
||||
''' </summary>
|
||||
DeviceEventAllActions
|
||||
|
||||
''' <summary>
|
||||
''' 22.模型外设事件执行动作组
|
||||
''' </summary>
|
||||
DeviceEventActions
|
||||
|
||||
''' <summary>
|
||||
''' 23.模型外设事件执行动作
|
||||
''' </summary>
|
||||
DeviceEventAction
|
||||
|
||||
''' <summary>
|
||||
''' 24.情景模式组
|
||||
''' </summary>
|
||||
ContextualModels
|
||||
|
||||
''' <summary>
|
||||
''' 25.情景模式
|
||||
''' </summary>
|
||||
ContextualModel
|
||||
|
||||
''' <summary>
|
||||
''' 26.外设模型
|
||||
''' </summary>
|
||||
ExternalModel
|
||||
|
||||
''' <summary>
|
||||
''' 27.属性集 = XiaoBaoCMD
|
||||
''' </summary>
|
||||
ModelAttributes_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 28.属性 = XiaoBaoCMD
|
||||
''' </summary>
|
||||
ModelAttribute_XiaoBaoCMD
|
||||
|
||||
''' <summary>
|
||||
''' 29.属性集 = 设备存在
|
||||
''' </summary>
|
||||
ModelAttributes_DeviceExists
|
||||
|
||||
''' <summary>
|
||||
''' 30.属性 = 设备存在
|
||||
''' </summary>
|
||||
ModelAttribute_DeviceExists
|
||||
|
||||
End Enum
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 延时单位
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property DelayUnit As String
|
||||
|
||||
''' <summary>
|
||||
''' 动作执行参数
|
||||
''' </summary>
|
||||
Public Params As List(Of AttributeRowNodeTag)
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 动作是否执行,仅代表表格上的勾选状态,参与编译属性参考Compile属性
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Action As Boolean
|
||||
Get
|
||||
Return _action
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
_action = value
|
||||
|
||||
UpdateCompile()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 动作是否参与编译
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Compile As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点标签
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Tag As Object
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点公共属性"
|
||||
|
||||
''' <summary>
|
||||
''' 节点是否处于展开状态
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Expanded() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点是否处于可见状态
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Visible() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 节点的级别,可见节点级别从0开始
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Lever As Integer
|
||||
Get
|
||||
Return _lever
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
_lever = value
|
||||
For Each node As RowNode In Nodes
|
||||
node.Lever = _lever + 1
|
||||
Next
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 节点在父节点中的索引,可见节点级别从0开始
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Index As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 下一级子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property Count() As Integer
|
||||
Get
|
||||
Return Nodes.Count
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' 所有子节点中,可见子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public ReadOnly Property VisibleNodesCount() As Integer
|
||||
Get
|
||||
Return _visibleCount
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 所有子节点总数
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property AllChildCount() As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点树的起始节点
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property HeadNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的父节点
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property ParentNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的同级上一节点,若当前节点为首节点则返回nothing
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property PrevNode() As RowNode
|
||||
|
||||
''' <summary>
|
||||
''' 当前节点的同级下一节点,若当前节点为尾节点则返回nothing
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property NextNode() As RowNode
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点所属节点数组的位置,从0开始,即头结点的的索引
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowListIndex As Integer
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点树的所有节点集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property RowList As List(Of RowNode)
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 子节点集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Nodes As RowNodes
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点操作"
|
||||
''' <summary>
|
||||
''' 更新节点参与编译属性
|
||||
''' </summary>
|
||||
Friend Sub UpdateCompile()
|
||||
If ParentNode Is Nothing Then
|
||||
Compile = Action
|
||||
Else
|
||||
Compile = Action AndAlso ParentNode.Compile
|
||||
End If
|
||||
|
||||
For Each node As RowNode In Nodes
|
||||
node.Compile = Action AndAlso node.ParentNode.Compile
|
||||
|
||||
node.UpdateCompile()
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 获取所有子节点
|
||||
''' </summary>
|
||||
Friend Function GetAllChildsNodeList(argRowNode As RowNode, ByVal lstChildNodeList As List(Of RowNode)) As Boolean
|
||||
If argRowNode.Nodes.Count < 1 Then Return False
|
||||
|
||||
'将指定节点的所有子节点平铺加入到lstChildNodeList列表中
|
||||
For Each tmpNode As RowNode In argRowNode.Nodes
|
||||
lstChildNodeList.Add(tmpNode)
|
||||
'如有子节点则递归调用,直到子节点数量为零(没有子节点)
|
||||
If tmpNode.Nodes.Count > 0 Then GetAllChildsNodeList(tmpNode, lstChildNodeList)
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 更新可见子节点总数
|
||||
''' </summary>
|
||||
''' <param name="count"></param>
|
||||
Friend Sub UpdateVisibleCount(count As Integer)
|
||||
_visibleCount += count
|
||||
If ParentNode IsNot Nothing Then ParentNode.UpdateVisibleCount(count)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 更新子节点可见
|
||||
''' </summary>
|
||||
Friend Sub UpdateVisible(Optional isForceSetVisible As Boolean = False,
|
||||
Optional isVisible As Boolean = True)
|
||||
For Each node As RowNode In Nodes
|
||||
'Momo 0416 增加强制参数,某些情况下通过传参强制设定visible状态
|
||||
If isForceSetVisible = True Then
|
||||
node.Visible = isVisible
|
||||
Else
|
||||
node.Visible = Expanded AndAlso Visible
|
||||
End If
|
||||
|
||||
node.UpdateVisible()
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 展开节点
|
||||
''' </summary>
|
||||
Public Sub Expand()
|
||||
If Expanded Then Return
|
||||
Expanded = True
|
||||
|
||||
Dim num As Integer
|
||||
For Each node As RowNode In Nodes
|
||||
num += node.VisibleNodesCount + 1
|
||||
Next
|
||||
UpdateVisibleCount(num)
|
||||
|
||||
'更新子节点是否可见
|
||||
UpdateVisible()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 展开所有节点包括子节点
|
||||
''' </summary>
|
||||
Public Sub ExpandAll()
|
||||
Expand()
|
||||
|
||||
'展开所有节点
|
||||
For Each node As RowNode In Nodes
|
||||
node.ExpandAll()
|
||||
'展开的同时,设置属性为可见
|
||||
node.Visible = True
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 折叠节点
|
||||
''' </summary>
|
||||
Public Sub Collapse()
|
||||
If Expanded = False Then Return
|
||||
Expanded = False
|
||||
|
||||
'更新可见总数
|
||||
Dim num As Integer
|
||||
For Each node As RowNode In Nodes
|
||||
num += node.VisibleNodesCount + 1
|
||||
Next
|
||||
UpdateVisibleCount(0 - num)
|
||||
|
||||
'更新子节点是否可见
|
||||
UpdateVisible()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 收缩所有节点包括子节点
|
||||
''' </summary>
|
||||
Public Sub CollapseAll()
|
||||
Collapse()
|
||||
|
||||
'收缩所有节点
|
||||
For Each node As RowNode In Nodes
|
||||
node.CollapseAll()
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 展开或折叠节点
|
||||
''' </summary>
|
||||
Public Sub Toggle()
|
||||
If Expanded Then
|
||||
Collapse()
|
||||
Else
|
||||
Expand()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 增加子节点
|
||||
''' </summary>
|
||||
Public Sub AddNode(node As RowNode)
|
||||
Nodes.Add(node)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 插入子节点
|
||||
''' </summary>
|
||||
Public Sub InsertNode(index As Integer, childNode As RowNode)
|
||||
Nodes.Insert(index, childNode)
|
||||
End Sub
|
||||
|
||||
|
||||
Public Sub RemoveChildNode(childNode As RowNode)
|
||||
|
||||
Nodes.Remove(childNode)
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveChildAt(index As Integer)
|
||||
If index >= Nodes.Count Then Return
|
||||
Dim child As RowNode = CType(Nodes.Item(index), RowNode)
|
||||
Nodes.RemoveAt(index)
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 移除本身节点
|
||||
''' </summary>
|
||||
Public Function Remove() As Boolean
|
||||
ParentNode.Nodes.Remove(Me)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 清空节点所有子节点
|
||||
''' </summary>
|
||||
Public Sub Clear()
|
||||
Nodes.Clear()
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点上移
|
||||
''' </summary>
|
||||
Public Sub MoveUp()
|
||||
If Index = 0 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
ParentNode.Nodes.Insert(Index - 1, Me)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 节点下移
|
||||
''' </summary>
|
||||
Public Sub MoveDown()
|
||||
If Index = ParentNode.Nodes.Count - 1 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
ParentNode.Nodes.Insert(Index + 1, Me)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 节点左移
|
||||
''' </summary>
|
||||
Public Sub MoveLeft()
|
||||
If _lever = 0 Then Return
|
||||
If Remove() = False Then Return
|
||||
ParentNode.ParentNode.Nodes.Insert(ParentNode.Index + 1, Me)
|
||||
|
||||
'更新节点可见与可见子节点数
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 节点右移
|
||||
''' </summary>
|
||||
Public Sub MoveRight()
|
||||
If Index = 0 Then Return
|
||||
|
||||
If Remove() = False Then Return
|
||||
Dim rNode As RowNode = CType(ParentNode.Nodes(Index - 1), RowNode)
|
||||
rNode.Nodes.Add(Me)
|
||||
|
||||
'更新节点可见与可见子节点数
|
||||
End Sub
|
||||
|
||||
'''' <summary>
|
||||
'''' 交换两个节点信息 err
|
||||
'''' </summary>
|
||||
'''' <returns></returns>
|
||||
'Public Function Exchange(ByRef argRowNode1 As RowNode,
|
||||
' ByRef argRowNode2 As RowNode,
|
||||
' ByRef argErrMsg As String) As Boolean
|
||||
' Try
|
||||
' If argRowNode1.RowType <> argRowNode2.RowType Then
|
||||
' argErrMsg = "两个节点类型不同,不可进行交换!"
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
' Dim tmpNode As RowNode = argRowNode1
|
||||
|
||||
' argRowNode1 = argRowNode2
|
||||
' argRowNode2 = tmpNode
|
||||
' Catch ex As Exception
|
||||
' argErrMsg = ex.Message.ToString
|
||||
' Return False
|
||||
' End Try
|
||||
|
||||
' Return True
|
||||
'End Function
|
||||
|
||||
''' <summary>
|
||||
''' 节点深复制,创建一个完全相同信息的节点(功能待测试)
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function Clone() As RowNode
|
||||
Dim cpNode As New RowNode
|
||||
|
||||
With cpNode
|
||||
.RowType = RowType
|
||||
|
||||
.Action = Action
|
||||
|
||||
.Nodes = New RowNodes(cpNode)
|
||||
|
||||
'todo:克隆功能待重写
|
||||
End With
|
||||
|
||||
Return cpNode
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "节点类型"
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
420
BLV_Studio/ModelGrid/RowNodes.vb
Normal file
420
BLV_Studio/ModelGrid/RowNodes.vb
Normal file
@@ -0,0 +1,420 @@
|
||||
|
||||
Public Class RowNodes
|
||||
Implements IList, ICollection, IEnumerable
|
||||
|
||||
Private ReadOnly _owner As RowNode
|
||||
|
||||
Private nodes As List(Of RowNode)
|
||||
|
||||
Friend Sub New(node As RowNode)
|
||||
_owner = node
|
||||
nodes = New List(Of RowNode)
|
||||
End Sub
|
||||
|
||||
|
||||
Default Public Property Item(index As Integer) As Object Implements IList.Item
|
||||
Get
|
||||
Return nodes.Item(index)
|
||||
End Get
|
||||
Set(value As Object)
|
||||
nodes(index) = CType(value, RowNode)
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
Public ReadOnly Property IsReadOnly As Boolean Implements IList.IsReadOnly
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property IsFixedSize As Boolean Implements IList.IsFixedSize
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Count As Integer Implements ICollection.Count
|
||||
Get
|
||||
Return nodes.Count
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property SyncRoot As Object Implements ICollection.SyncRoot
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property IsSynchronized As Boolean Implements ICollection.IsSynchronized
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 更新节点的上一节点指向
|
||||
''' </summary>
|
||||
''' <param name="node">需要更新的节点</param>
|
||||
Private Sub AddNodeUpdatePrevNode(node As RowNode)
|
||||
If node.Index > 0 Then
|
||||
node.PrevNode = node.ParentNode.Nodes(node.Index - 1)
|
||||
|
||||
'更新上一节点的下一节点指向
|
||||
node.PrevNode.NextNode = node
|
||||
Else
|
||||
node.PrevNode = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 更新节点的下一节点指向
|
||||
''' </summary>
|
||||
''' <param name="node">需要更新的节点</param>
|
||||
Private Sub AddNodeUpdateNextNode(node As RowNode)
|
||||
If node.Index < node.ParentNode.Nodes.Count - 1 Then
|
||||
node.NextNode = node.ParentNode.Nodes(node.Index + 1)
|
||||
|
||||
'更新下一节点的上一节点指向
|
||||
node.NextNode.PrevNode = node
|
||||
Else
|
||||
node.NextNode = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 新增节点后,更新父节点的所有子节点计数
|
||||
''' </summary>
|
||||
''' <param name="node">新增的节点</param>
|
||||
Private Sub AddNodeUpdateAllChildCount(node As RowNode)
|
||||
Dim pNode As RowNode = node.ParentNode
|
||||
|
||||
While pNode IsNot Nothing
|
||||
pNode.AllChildCount += (node.AllChildCount + 1)
|
||||
|
||||
pNode = pNode.ParentNode
|
||||
End While
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 删除节点后,更新父节点的所有子节点计数
|
||||
''' </summary>
|
||||
''' <param name="node">被删除的节点</param>
|
||||
''' <param name="include">包含当前节点</param>
|
||||
Private Sub DelNodeUpdateAllChildCount(node As RowNode, Optional include As Boolean = True)
|
||||
|
||||
Dim removeCount As Integer
|
||||
|
||||
If include Then
|
||||
removeCount = node.AllChildCount + 1
|
||||
Else
|
||||
removeCount = node.AllChildCount
|
||||
End If
|
||||
|
||||
Dim pNode As RowNode = node.ParentNode
|
||||
While pNode IsNot Nothing
|
||||
pNode.AllChildCount -= removeCount
|
||||
|
||||
pNode = pNode.ParentNode
|
||||
End While
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 插入节点后,更新节点下方节点的索引
|
||||
''' </summary>
|
||||
''' <param name="node">需要更新下方节点索引的节点</param>
|
||||
Private Sub AddNodeUpdateRowIndex(node As RowNode)
|
||||
While node.NextNode IsNot Nothing
|
||||
node.NextNode.Index = node.Index + 1
|
||||
node = node.NextNode
|
||||
End While
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 删除节点后,更新节点下方节点的索引
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
Private Sub DelNodeUpdateRowIndex(node As RowNode)
|
||||
If node.NextNode Is Nothing Then Return
|
||||
node.NextNode.Index = node.Index
|
||||
node = node.NextNode
|
||||
|
||||
While node.NextNode IsNot Nothing
|
||||
node.NextNode.Index = node.Index + 1
|
||||
node = node.NextNode
|
||||
End While
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 获取新添加的节点的链状目录索引
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
''' <returns></returns>
|
||||
Private Function GetRowListIndex(node As RowNode) As Integer
|
||||
Dim rowListIndex As Integer
|
||||
If node.Index = 0 Then
|
||||
rowListIndex = node.ParentNode.RowListIndex + 1
|
||||
Else
|
||||
rowListIndex = node.PrevNode.RowListIndex + node.PrevNode.AllChildCount + 1
|
||||
End If
|
||||
Return rowListIndex
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 更新节点的所有子节点的链式结合的指向
|
||||
''' </summary>
|
||||
''' <param name="pNode"></param>
|
||||
''' <param name="node"></param>
|
||||
Private Sub AddNodeUpdateRowList(pNode As RowNode, node As RowNode)
|
||||
node.RowList = pNode.RowList
|
||||
node.RowListIndex = GetRowListIndex(node)
|
||||
node.RowList.Insert(node.RowListIndex, node)
|
||||
|
||||
For Each cNode As RowNode In node.Nodes
|
||||
AddNodeUpdateRowList(node, cNode)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 删除节点后,更新链状列表
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
''' <param name="include">包含当前节点</param>
|
||||
Private Sub DelNodeUpdateRowList(node As RowNode, Optional include As Boolean = True)
|
||||
Dim index As Integer
|
||||
|
||||
If include Then
|
||||
index = node.RowListIndex
|
||||
node.RowList.RemoveAt(index)
|
||||
Else
|
||||
index = node.RowListIndex + 1
|
||||
End If
|
||||
|
||||
Dim removeCount As Integer = node.AllChildCount
|
||||
While removeCount > 0
|
||||
node.RowList.RemoveAt(index)
|
||||
removeCount -= 1
|
||||
End While
|
||||
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 插入节点后,更新链状目录中受影响节点的索引
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
Private Sub AddNodeUpdateRowListIndex(node As RowNode)
|
||||
Dim startIndex As Integer = node.RowListIndex + node.AllChildCount + 1
|
||||
|
||||
For index As Integer = startIndex To node.RowList.Count - 1
|
||||
node.RowList(index).RowListIndex = index
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 删除节点后,更新链状目录中受影响节点的索引
|
||||
''' </summary>
|
||||
''' <param name="node">删除的节点</param>
|
||||
''' <param name="include">是否保存该节点</param>
|
||||
Private Sub DelNodeUpdateRowListIndex(node As RowNode, Optional include As Boolean = True)
|
||||
Dim startIndex As Integer = node.RowListIndex
|
||||
If include = False Then startIndex += 1
|
||||
For i As Integer = startIndex To node.RowList.Count - 1
|
||||
_owner.RowList(i).RowListIndex = i
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function Add(value As Object) As Integer Implements IList.Add
|
||||
Dim node As RowNode
|
||||
Try
|
||||
node = CType(value, RowNode)
|
||||
Catch ex As Exception
|
||||
Return -1
|
||||
End Try
|
||||
|
||||
nodes.Add(node)
|
||||
node.HeadNode = _owner.HeadNode
|
||||
node.ParentNode = _owner
|
||||
node.Lever = _owner.Lever + 1
|
||||
node.Index = nodes.Count - 1
|
||||
node.RowList = _owner.RowList
|
||||
node.Visible = _owner.Visible And _owner.Expanded
|
||||
|
||||
'更新节点可见属性
|
||||
node.UpdateVisible()
|
||||
|
||||
'更新节点参与编译
|
||||
node.UpdateCompile()
|
||||
|
||||
'更新节点可见节点数
|
||||
' If _owner.Expanded Then _owner.UpdateVisibleCount(1 + node.VisibleNodesCount)
|
||||
If node.Visible Then _owner.UpdateVisibleCount(1 + node.VisibleNodesCount)
|
||||
|
||||
'更新父节点总子节点计数
|
||||
AddNodeUpdateAllChildCount(node)
|
||||
|
||||
'更新上一节点指向
|
||||
AddNodeUpdatePrevNode(node)
|
||||
|
||||
'更新下一节点指向
|
||||
node.NextNode = Nothing
|
||||
|
||||
'将节点及其子节点插入到链状目录中,并更新链状目指向
|
||||
AddNodeUpdateRowList(_owner, node)
|
||||
|
||||
'更新下方节点链状索引
|
||||
AddNodeUpdateRowListIndex(node)
|
||||
|
||||
Return nodes.Count
|
||||
End Function
|
||||
|
||||
|
||||
Public Sub Insert(index As Integer, value As Object) Implements IList.Insert
|
||||
Dim node As RowNode = CType(value, RowNode)
|
||||
nodes.Insert(index, node)
|
||||
node.HeadNode = _owner.HeadNode
|
||||
node.ParentNode = _owner
|
||||
node.Lever = _owner.Lever + 1
|
||||
node.Index = index
|
||||
node.RowList = _owner.RowList
|
||||
node.Visible = _owner.Visible And _owner.Expanded
|
||||
'node.Compile = _owner.Compile AndAlso node.Action
|
||||
|
||||
'更新节点可见属性
|
||||
node.UpdateVisible()
|
||||
|
||||
'更新节点参与编译
|
||||
node.UpdateCompile()
|
||||
|
||||
'更新节点可见节点数
|
||||
'If _owner.Expanded Then _owner.UpdateVisibleCount(1 + node.VisibleNodesCount)
|
||||
If node.Visible Then _owner.UpdateVisibleCount(1 + node.VisibleNodesCount)
|
||||
|
||||
'更新父节点总子节点计数
|
||||
AddNodeUpdateAllChildCount(node)
|
||||
|
||||
'更新上一节点指向
|
||||
AddNodeUpdatePrevNode(node)
|
||||
|
||||
'更新下一节点指向
|
||||
AddNodeUpdateNextNode(node)
|
||||
|
||||
'更新下方节点树状索引
|
||||
AddNodeUpdateRowIndex(node)
|
||||
|
||||
'将节点及其子节点插入到链状目录中,并更新链状目指向
|
||||
AddNodeUpdateRowList(_owner, node)
|
||||
|
||||
'更新下方节点链状索引
|
||||
AddNodeUpdateRowListIndex(node)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 移除指定节点
|
||||
''' </summary>
|
||||
''' <param name="value"></param>
|
||||
Public Sub Remove(value As Object) Implements IList.Remove
|
||||
Dim node As RowNode = CType(value, RowNode)
|
||||
nodes.Remove(node)
|
||||
|
||||
_owner.UpdateVisibleCount(0 - (1 + node.VisibleNodesCount))
|
||||
|
||||
'更新父节点总子节点计数
|
||||
DelNodeUpdateAllChildCount(node)
|
||||
|
||||
'更新上一节点的下一节点指向
|
||||
If node.PrevNode IsNot Nothing Then
|
||||
node.PrevNode.NextNode = node.NextNode
|
||||
End If
|
||||
|
||||
'更新下一节点的上一节点指向
|
||||
If node.NextNode IsNot Nothing Then
|
||||
node.NextNode.PrevNode = node.PrevNode
|
||||
End If
|
||||
|
||||
'更新下方节点树状索引
|
||||
DelNodeUpdateRowIndex(node)
|
||||
|
||||
|
||||
|
||||
'链状目录移除被删除的节点
|
||||
DelNodeUpdateRowList(node)
|
||||
|
||||
'更新链状目录中的节点索引
|
||||
DelNodeUpdateRowListIndex(node)
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveAt(index As Integer) Implements IList.RemoveAt
|
||||
Dim node As RowNode = nodes(index)
|
||||
nodes.RemoveAt(index)
|
||||
|
||||
_owner.UpdateVisibleCount(0 - (1 + node.VisibleNodesCount))
|
||||
|
||||
'更新父节点总子节点计数
|
||||
DelNodeUpdateAllChildCount(node)
|
||||
|
||||
'更新上一节点的下一节点指向
|
||||
If node.PrevNode IsNot Nothing Then
|
||||
node.PrevNode.NextNode = node.NextNode
|
||||
End If
|
||||
|
||||
'更新下一节点的上一节点指向
|
||||
If node.NextNode IsNot Nothing Then
|
||||
node.NextNode.PrevNode = node.PrevNode
|
||||
End If
|
||||
|
||||
'更新下方节点树状索引
|
||||
DelNodeUpdateRowIndex(node)
|
||||
|
||||
|
||||
|
||||
'链状目录移除被删除的节点
|
||||
DelNodeUpdateRowList(node)
|
||||
|
||||
'更新链状目录中的节点索引
|
||||
DelNodeUpdateRowListIndex(node)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 清空节点
|
||||
''' </summary>
|
||||
Public Sub Clear() Implements IList.Clear
|
||||
_owner.UpdateVisibleCount(0 - _owner.VisibleNodesCount)
|
||||
|
||||
'清空树状目录子节点
|
||||
nodes.Clear()
|
||||
|
||||
'更新父节点总子节点计数
|
||||
DelNodeUpdateAllChildCount(_owner, False)
|
||||
|
||||
'链状目录移除被删除的节点
|
||||
DelNodeUpdateRowList(_owner, False)
|
||||
|
||||
'更新链状目录中的节点索引
|
||||
DelNodeUpdateRowListIndex(_owner, False)
|
||||
|
||||
'更新总子节点计数
|
||||
_owner.AllChildCount = 0
|
||||
End Sub
|
||||
Public Sub CopyTo(array As Array, index As Integer) Implements ICollection.CopyTo
|
||||
nodes.CopyTo(CType(array, RowNode()), index)
|
||||
End Sub
|
||||
|
||||
Public Function Contains(value As Object) As Boolean Implements IList.Contains
|
||||
Return nodes.Contains(CType(value, RowNode))
|
||||
End Function
|
||||
|
||||
Public Function IndexOf(value As Object) As Integer Implements IList.IndexOf
|
||||
Return nodes.IndexOf(CType(value, RowNode))
|
||||
End Function
|
||||
|
||||
Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
|
||||
Return nodes.GetEnumerator
|
||||
End Function
|
||||
End Class
|
||||
147
BLV_Studio/ModelGrid/UsedDeviceTypes.vb
Normal file
147
BLV_Studio/ModelGrid/UsedDeviceTypes.vb
Normal file
@@ -0,0 +1,147 @@
|
||||
Imports System.Threading
|
||||
|
||||
Public Class UsedDeviceTypes
|
||||
Private Shared _object As UsedDeviceTypes
|
||||
Private Shared _lock As New Object
|
||||
|
||||
'当前已使用的设备类型,键为类型,值为节点
|
||||
Private _usedDevTypes As Dictionary(Of String, List(Of RowNode))
|
||||
|
||||
''' <summary>
|
||||
''' 创建已使用设备类型单例
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Shared Function CreateSingleton() As UsedDeviceTypes
|
||||
If _object Is Nothing Then '懒汉,双锁
|
||||
SyncLock _lock
|
||||
If _object Is Nothing Then
|
||||
Thread.MemoryBarrier()
|
||||
_object = New UsedDeviceTypes
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
|
||||
Return _object
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub New()
|
||||
_usedDevTypes = New Dictionary(Of String, List(Of RowNode))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 获取所有设备类型
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function GetAllDeviceTypes(Optional type As GetsEnum = GetsEnum.All) As String()
|
||||
Dim lst As New List(Of String)
|
||||
Select Case type
|
||||
Case GetsEnum.All
|
||||
lst.AddRange(_usedDevTypes.Keys.ToArray)
|
||||
Case GetsEnum.Action
|
||||
For Each str As String In _usedDevTypes.Keys
|
||||
If str.CompareTo("场景") = 0 Then Continue For
|
||||
lst.Add(str)
|
||||
Next
|
||||
|
||||
Case GetsEnum.Xiaobao
|
||||
For Each str As String In _usedDevTypes.Keys
|
||||
If str.CompareTo("动作组") = 0 Then Continue For
|
||||
lst.Add(str)
|
||||
Next
|
||||
|
||||
Case Else
|
||||
lst.AddRange(_usedDevTypes.Keys.ToArray)
|
||||
End Select
|
||||
|
||||
Return lst.ToArray
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 获取当前设备类型是否已使用
|
||||
''' </summary>
|
||||
''' <param name="type"></param>
|
||||
''' <returns></returns>
|
||||
Public Function ContainsDeviceType(type As String) As Boolean
|
||||
Return _usedDevTypes.ContainsKey(type)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 获取当前设备类型先所有行节点内容
|
||||
''' </summary>
|
||||
''' <param name="type"></param>
|
||||
''' <returns></returns>
|
||||
Public Function GetRowNodes(type As String) As RowNode()
|
||||
If _usedDevTypes.ContainsKey(type) Then
|
||||
Return _usedDevTypes(type).ToArray
|
||||
Else
|
||||
Return New RowNode() {}
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 添加行节点到已使用设备类型,设备类型为空则忽略添加
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
Public Sub AddNode(node As RowNode)
|
||||
'检测设备类型是否非法
|
||||
If String.IsNullOrEmpty(node.DeviceType) Then Return
|
||||
|
||||
'设备节点过滤
|
||||
If node.RowType <> RowNode.RowTypeEnum.DeviceObject AndAlso
|
||||
node.RowType <> RowNode.RowTypeEnum.DeviceEventActions AndAlso
|
||||
node.RowType <> RowNode.RowTypeEnum.DeviceEvent AndAlso
|
||||
node.RowType <> RowNode.RowTypeEnum.ContextualModel Then Return
|
||||
|
||||
'添加行的设备类型
|
||||
If _usedDevTypes.ContainsKey(node.DeviceType) = False Then
|
||||
_usedDevTypes.Add(node.DeviceType, New List(Of RowNode))
|
||||
End If
|
||||
|
||||
'添加设备类型节点
|
||||
If _usedDevTypes(node.DeviceType).Contains(node) = False Then _usedDevTypes(node.DeviceType).Add(node)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 移除行节点从已使用设备类型
|
||||
''' </summary>
|
||||
''' <param name="node"></param>
|
||||
Public Sub RemoveNode(node As RowNode)
|
||||
If String.IsNullOrEmpty(node.DeviceType) Then Return
|
||||
|
||||
If _usedDevTypes.ContainsKey(node.DeviceType) Then
|
||||
_usedDevTypes(node.DeviceType).Remove(node)
|
||||
|
||||
If _usedDevTypes(node.DeviceType).Count = 0 Then
|
||||
_usedDevTypes.Remove(node.DeviceType)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 清空所有设备类型信息
|
||||
''' </summary>
|
||||
Public Sub Clear()
|
||||
_usedDevTypes.Clear()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 获取类型
|
||||
''' </summary>
|
||||
Enum GetsEnum
|
||||
''' <summary>
|
||||
''' 全部获取
|
||||
''' </summary>
|
||||
All
|
||||
|
||||
''' <summary>
|
||||
''' 动作相关
|
||||
''' </summary>
|
||||
Action
|
||||
|
||||
''' <summary>
|
||||
''' 小宝相关
|
||||
''' </summary>
|
||||
Xiaobao
|
||||
End Enum
|
||||
End Class
|
||||
12
BLV_Studio/ModelGrid/rsmTreeNode.vb
Normal file
12
BLV_Studio/ModelGrid/rsmTreeNode.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Option Explicit On
|
||||
|
||||
Public Class rsmTreeNode
|
||||
Inherits TreeNode
|
||||
|
||||
#Region "公共变量"
|
||||
|
||||
Public rowNodeIdx As Integer '用于保存节点的行号,方便双击节点导航到表格对应的行
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user