标签:
有时候在激活一个命令按钮的时候,需要同时禁止掉另外一个或多个命令按钮
‘‘‘ <summary> ‘‘‘ 取按钮是否敏感 ‘‘‘ </summary> ‘‘‘ <param name="btnName">按钮名称</param> ‘‘‘ <returns><c>true</c> 如果敏感(没有被屏蔽), <c>false</c> 否则.</returns> Public Function GetMenuButtonSensitivity(ByVal btnName As String) As Boolean Dim menuBtn As NXOpen.MenuBar.MenuButton = NXOpen.UI.GetUI().MenuBarManager.GetButtonFromName(btnName) If menuBtn IsNot Nothing Then Return menuBtn.ButtonSensitivity = MenuButton.SensitivityStatus.Sensitive End If Return False End Function ‘‘‘ <summary> ‘‘‘ 设置按钮敏感状态 ‘‘‘ </summary> ‘‘‘ <param name="btnName">按钮名称</param> ‘‘‘ <param name="IsSensitivity">是否敏感(不屏蔽)</param> Public Sub SetMenuButtonSensitivity(ByVal btnName As String, ByVal IsSensitivity As Boolean) Dim menuBtn As NXOpen.MenuBar.MenuButton = NXOpen.UI.GetUI().MenuBarManager.GetButtonFromName(btnName) If menuBtn IsNot Nothing Then menuBtn.ButtonSensitivity = If(IsSensitivity, MenuButton.SensitivityStatus.Sensitive, MenuButton.SensitivityStatus.Insensitive) End If End Sub ‘‘‘ <summary> ‘‘‘ 取NX锁定状态 ‘‘‘ </summary> ‘‘‘ <returns><c>true</c> 如果锁定(屏蔽所有按钮), <c>false</c> 否则.</returns> Public Function GetNXLockStatus() As Boolean Return NXOpen.UI.GetUI().AskLockStatus() = NXOpen.UI.Status.Lock End Function ‘‘‘ <summary> ‘‘‘ 设置NX锁定状态 ‘‘‘ </summary> ‘‘‘ <param name="isLock">如果锁定(屏蔽所有按钮),设置为<c>true</c> .</param> Public Sub SetNXLockStatus(ByVal isLock As Boolean) If isLock Then NXOpen.UI.GetUI().LockAccess() Else NXOpen.UI.GetUI().UnlockAccess() End If End Sub
/// <summary> /// 取按钮是否敏感 /// </summary> /// <param name="btnName">按钮名称</param> /// <returns><c>true</c> 如果敏感(没有被屏蔽), <c>false</c> 否则.</returns> public bool GetMenuButtonSensitivity(string btnName) { NXOpen.MenuBar.MenuButton menuBtn = NXOpen.UI.GetUI().MenuBarManager.GetButtonFromName(btnName); if (menuBtn != null) { return menuBtn.ButtonSensitivity == MenuButton.SensitivityStatus.Sensitive; } return false; } /// <summary> /// 设置按钮敏感状态 /// </summary> /// <param name="btnName">按钮名称</param> /// <param name="IsSensitivity">是否敏感(不屏蔽)</param> public void SetMenuButtonSensitivity(string btnName, bool IsSensitivity) { NXOpen.MenuBar.MenuButton menuBtn = NXOpen.UI.GetUI().MenuBarManager.GetButtonFromName(btnName); if (menuBtn != null) { menuBtn.ButtonSensitivity = IsSensitivity ? MenuButton.SensitivityStatus.Sensitive : MenuButton.SensitivityStatus.Insensitive; } } /// <summary> /// 取NX锁定状态 /// </summary> /// <returns><c>true</c> 如果锁定(屏蔽所有按钮), <c>false</c> 否则.</returns> public bool GetNXLockStatus() { return NXOpen.UI.GetUI().AskLockStatus() == NXOpen.UI.Status.Lock; } /// <summary> /// 设置NX锁定状态 /// </summary> /// <param name="isLock">如果锁定(屏蔽所有按钮),设置为<c>true</c> .</param> public void SetNXLockStatus(bool isLock) { if (isLock) { NXOpen.UI.GetUI().LockAccess(); } else { NXOpen.UI.GetUI().UnlockAccess(); } }
标签:
原文地址:http://www.cnblogs.com/bizca/p/4747584.html