關於BLOCK UI的一些控件的用法,本人曾經使用的代碼,拿出來共享:
Option Strict Off Imports NXOpen Imports NXOpen.BlockStyler Imports System.Runtime.InteropServices Namespace Bizca.NX.UIBlockStyler Public Module UIBlockStylerEx <System.Runtime.CompilerServices.Extension()> _ <Obsolete> Public Function GetPropertiesEx(ByVal block As NXOpen.BlockStyler.UIBlock) As UIBlockEx Return New UIBlockEx(block) End Function '#Region "ListBox" ' <System.Runtime.CompilerServices.Extension()> _ ' Public Sub SetListItems(ByVal ListBox As NXOpen.BlockStyler.ListBox, ByVal stringArray() As String) ' ListBox.GetProperties.SetStrings("ListItems", stringArray) ' End Sub ' <System.Runtime.CompilerServices.Extension()> _ ' Public Function GetListItems(ByVal ListBox As NXOpen.BlockStyler.ListBox) as String() ' Return ListBox.GetProperties.GetStrings("ListItems") ' End Function '#End Region End Module 'Public Class ListBoxEx ' Inherits NXOpen.BlockStyler.ListBox ' Private ower As NXOpen.BlockStyler.ListBox ' Public Sub New(ByVal block As NXOpen.BlockStyler.ListBox) ' Me.ower = block ' End Sub ' Property DDDD As String ' Public Shared Sub DSS() ' With New ListBoxEx(Nothing) ' .DDDD = "FFF" ' End With ' Dim AAAA = Function(X As NXOpen.Tag) ' Return NXOpen.Utilities.NXObjectManager.Get(X) ' End Function ' Dim WWW = AAAA(NXOpen.Tag.Null) ' End Sub 'End Class Public Class UIBlockEx Private ower As NXOpen.BlockStyler.UIBlock Public Sub New(ByVal block As NXOpen.BlockStyler.UIBlock) Me.ower = block End Sub #Region "General Properties" ''' <summary> ''' 【通用】設置UIBlock的是否不禁止 ''' </summary> ''' <value>[CSG] TRUE-Block 不禁止,FALSE-Block 禁止</value> ''' <returns>[CSG] TRUE-Block 不禁止,FALSE-Block 禁止</returns> ''' <remarks>[CSG] TRUE-Block 不禁止,FALSE-Block 禁止 </remarks> Public Property Enable As Boolean Get Return Me.ower.GetProperties.GetLogical("Enable") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("Enable", value) End Set End Property ''' <summary> ''' 【通用】設置UIBlock的是否展開(Block必須擁有自己的組) ''' </summary> ''' <value>[SG] TRUE- 展開,FALSE- 折疊</value> ''' <returns>[SG] TRUE- 展開,FALSE- 折疊</returns> ''' <remarks>Block必須擁有自己的組(設計時才可以指定)</remarks> Public Property Expanded As Boolean Get Return Me.ower.GetProperties.GetLogical("Expanded") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("Expanded", value) End Set End Property ''' <summary> ''' 【通用】標簽 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>[CSG] Any String Value </remarks> Public Property Label As String Get Return Me.ower.GetProperties.GetString("Label") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Label", value) End Set End Property ''' <summary> ''' 【通用】設置UIBlock的Show可見屬性 ''' </summary> ''' <value>[CSG] TRUE-Block 可見,FALSE-Block 不可見</value> ''' <returns>[CSG] TRUE-Block 可見,FALSE-Block 不可見</returns> ''' <remarks>Sets the visibility of the block</remarks> Public Property Show As Boolean Get Return Me.ower.GetProperties.GetLogical("Show") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("Show", value) End Set End Property #End Region #Region "Selection" ''' <summary> ''' 【選擇對象】自動推進 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>自動推進到下一個UIBlock</remarks> Public Property AutomaticProgression As Boolean Get Return Me.ower.GetProperties.GetLogical("AutomaticProgression") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("AutomaticProgression", value) End Set End Property ''' <summary> ''' 【選擇對象】提示字符串 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>狀態欄提示字符串</remarks> Public Property Cue As String Get Return Me.ower.GetProperties.GetString("Cue") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Cue", value) End Set End Property ''' <summary> ''' 【選擇對象】標簽字符串 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property LabelString As String Get Return Me.ower.GetProperties.GetString("LabelString") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("LabelString", value) End Set End Property ''' <summary> ''' 【選擇對象】點覆蓋 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>是否啟用捕捉點</remarks> Public Property PointOverlay As Boolean Get Return Me.ower.GetProperties.GetLogical("PointOverlay") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.setLogical("PointOverlay",value) End Set End Property ''' <summary> ''' 【選擇對象】設置選擇過濾器 ''' </summary> ''' <param name="maskAction"></param> ''' <param name="maskTriples"></param> ''' <remarks></remarks> Public Sub SetSelectionFilter(ByVal maskAction As NXOpen.Selection.SelectionAction, ByVal maskTriples() As NXOpen.Selection.MaskTriple) Me.ower.GetProperties.SetSelectionFilter("SelectionFilter", maskAction, maskTriples) End Sub ''' <summary> ''' 【選擇對象】選擇的對象 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property SelectedObjects As NXOpen.TaggedObject() Get Return Me.ower.GetProperties.GetTaggedObjectVector("SelectedObjects") End Get Set(ByVal value As NXOpen.TaggedObject()) If value IsNot Nothing Then Me.ower.GetProperties.SetTaggedObjectVector("SelectedObjects", value) End If End Set End Property ''' <summary> ''' 【選擇對象】最后取消選擇的對象 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public ReadOnly Property LastDeselectedObjects As NXOpen.TaggedObject() Get Return Me.ower.GetProperties.GetTaggedObjectVector("LastDeselectedObjects") End Get End Property ''' <summary> ''' 【選擇對象】最后選擇的對象 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public ReadOnly Property LastSelectedObjects As NXOpen.TaggedObject() Get Return Me.ower.GetProperties.GetTaggedObjectVector("LastSelectedObjects") End Get End Property ''' <summary> ''' 【選擇對象】步驟的狀態 ''' </summary> ''' <value>只有當初始化的時候才可以設置該屬性</value> ''' <returns></returns> ''' <remarks>CIG Required[必須] Optional[可選] Satisfied[滿意]</remarks> Public Property StepStatus As StepStatusEnum Get Return Me.ower.GetProperties.GetEnum("StepStatus") End Get Set(ByVal value As StepStatusEnum) Me.ower.GetProperties.SetEnum("StepStatus", value) End Set End Property ''' <summary> ''' 步驟的狀態 ''' </summary> ''' <remarks></remarks> Public Enum StepStatusEnum ''' <summary> ''' 必要的 ''' </summary> ''' <remarks></remarks> [Required] = 0 ''' <summary> ''' 可選的 ''' </summary> ''' <remarks></remarks> [Optional] = 1 ''' <summary> ''' 滿意的 ''' </summary> ''' <remarks></remarks> [Satisfied] = 2 End Enum ''' <summary> ''' 【選擇對象】拾取點 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>選擇對象時在屏幕上觸擊的點</remarks> Public ReadOnly Property PickPoint As NXOpen.Point3d Get Return Me.ower.GetProperties.GetPoint("PickPoint") End Get End Property ''' <summary> ''' 【指定光標位置】顯示臨時點 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>Specify Cursor Location</remarks> Public Property DisplayTemporaryPoint As Boolean Get Return Me.ower.GetProperties.GetLogical("DisplayTemporaryPoint") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("DisplayTemporaryPoint", value) End Set End Property ''' <summary> ''' 【指定光標位置】光標位置 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>Specify Cursor Location</remarks> Public Property CursorLocation As NXOpen.Point3d Get Return Me.ower.GetProperties.GetPoint("CursorLocation") End Get Set(ByVal value As NXOpen.Point3d) Me.ower.GetProperties.SetPoint("CursorLocation", value) End Set End Property ''' <summary> ''' 【Specify Point】【Specify Vector】點 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property Point As NXOpen.Point3d Get Return Me.ower.GetProperties.GetPoint("Point") End Get Set(ByVal value As NXOpen.Point3d) Me.ower.GetProperties.SetPoint("Point", value) End Set End Property ''' <summary> ''' 【Specify Vector】矢量 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property Vector As Vector3d Get Return Me.ower.GetProperties.GetVector("Vector") End Get Set(ByVal value As Vector3d) Me.ower.GetProperties.SetVector("Vector", value) End Set End Property #End Region Public Property LogicalValue As Boolean Get Return Me.ower.GetProperties.GetLogical("Value") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("Value", value) End Set End Property #Region "Enum Block" ''' <summary> ''' 【Enumeration】枚舉值 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property EnumValue As Integer Get Return Me.ower.GetProperties.GetEnum("Value") End Get Set(ByVal value As Integer) Me.ower.GetProperties.SetEnum("Value", value) End Set End Property ''' <summary> ''' 【Enumeration】枚舉字符串 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property EnumAsString As String Get Return Me.ower.GetProperties.GetEnumAsString("Value") End Get Set(ByVal value As String) Me.ower.GetProperties.SetEnumAsString("Value", value) End Set End Property ''' <summary> ''' 【Enumeration】枚舉字符串數組成員 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property EnumMembers As String() Get Return Me.ower.GetProperties.GetEnumMembers("Value") End Get Set(ByVal value As String()) Me.ower.GetProperties.SetEnumMembers("Value", value) End Set End Property #End Region #Region "Expression" ''' <summary> ''' 【表達式】【線性尺寸】【角度尺寸】【半徑尺寸】【軌跡上的尺寸(沿曲線的位置)】表達式 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property Formula As String Get Return Me.ower.GetProperties.GetString("Formula") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Formula", value) End Set End Property ''' <summary> ''' 【線性尺寸】【半徑尺寸】手柄方向 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property HandleOrientation As NXOpen.Vector3d Get Return Me.ower.GetProperties.GetVector("HandleOrientation") End Get Set(ByVal value As NXOpen.Vector3d) Me.ower.GetProperties.SetVector("HandleOrientation", value) End Set End Property ''' <summary> ''' 【角度尺寸】手柄X軸方向 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property HandleXAxis As NXOpen.Vector3d Get Return Me.ower.GetProperties.GetVector("HandleXAxis") End Get Set(ByVal value As NXOpen.Vector3d) Me.ower.GetProperties.SetVector("HandleXAxis", value) End Set End Property ''' <summary> ''' 【角度尺寸】手柄Z軸方向 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property HandleZAxis As NXOpen.Vector3d Get Return Me.ower.GetProperties.GetVector("HandleZAxis") End Get Set(ByVal value As NXOpen.Vector3d) Me.ower.GetProperties.SetVector("HandleZAxis", value) End Set End Property ''' <summary> ''' 【線性尺寸】【角度尺寸】【半徑尺寸】手柄原點 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property HandleOrigin As NXOpen.Point3d Get Return Me.ower.GetProperties.GetPoint("HandleOrigin") End Get Set(ByVal value As NXOpen.Point3d) Me.ower.GetProperties.SetPoint("HandleOrigin", value) End Set End Property ''' <summary> ''' 【線性尺寸】【角度尺寸】【半徑尺寸】【軌跡上的尺寸(沿曲線的位置)】顯示焦點手柄 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property ShowFocusHandle As Boolean Get Return Me.ower.GetProperties.GetLogical("ShowFocusHandle") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("ShowFocusHandle", value) End Set End Property ''' <summary> ''' 【線性尺寸】【角度尺寸】【半徑尺寸】顯示手柄 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property ShowHandle As Boolean Get Return Me.ower.GetProperties.GetLogical("ShowHandle") End Get Set(ByVal value As Boolean) Me.ower.GetProperties.SetLogical("ShowHandle", value) End Set End Property #End Region ''' <summary> ''' 【String】字符串值 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property StringValue As String Get Return Me.ower.GetProperties.GetString("Value") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Value", value) End Set End Property Public Property StringArrayValue As String() Get Return Me.ower.GetProperties.GetStrings("Value") End Get Set(ByVal value As String()) Me.ower.GetProperties.SetStrings("Value", value) End Set End Property Public Property IntegerValue As Integer Get Return Me.ower.GetProperties.GetInteger("Value") End Get Set(ByVal value As Integer) Me.ower.GetProperties.SetInteger("Value", value) End Set End Property Public Property DoubleValue As Double Get Return Me.ower.GetProperties.GetDouble("Value") End Get Set(ByVal value As Double) Me.ower.GetProperties.SetDouble("Value", value) End Set End Property #Region "Selection with Browse" ''' <summary> ''' 指定選擇文件或文件夾的路徑 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>任何代表有效的文件路徑或文件夾路徑的字符串。</remarks> Public Property Path As String Get Return Me.ower.GetProperties.GetString("Path") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Path", value) End Set End Property ''' <summary> ''' 指定篩選器的格式為"*.txt,*.xml"。如果未設置此屬性,嵌以.prt作為默認的過濾器。 ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks>字符串值的格式為"*.txt,*.xml"。如果空白,則以.prt作為默認的過濾器。</remarks> Public Property Filter As String Get Return Me.ower.GetProperties.GetString("Filter") End Get Set(ByVal value As String) Me.ower.GetProperties.SetString("Filter", value) End Set End Property #End Region End Class End Namespace